Is there a build-in ordinal sequence vector in R?
up vote
1
down vote
favorite
I need a long ordinal sequence vector in R. As a simple example of what I want:
OS <- c("First","Second","Third")
Is there a build-in vector like that?
r
add a comment |
up vote
1
down vote
favorite
I need a long ordinal sequence vector in R. As a simple example of what I want:
OS <- c("First","Second","Third")
Is there a build-in vector like that?
r
Not built-in, because it'd have to be part of the locale.
– alistaire
Nov 5 at 2:16
@alistaire Make sense. Thanks!
– Leonhardt Guass
Nov 5 at 2:19
1
You could pull it out of Unicode CLDR maybe, though that may be as much work as typing out yourself, depending on how far you need to go.
– alistaire
Nov 5 at 2:23
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I need a long ordinal sequence vector in R. As a simple example of what I want:
OS <- c("First","Second","Third")
Is there a build-in vector like that?
r
I need a long ordinal sequence vector in R. As a simple example of what I want:
OS <- c("First","Second","Third")
Is there a build-in vector like that?
r
r
asked Nov 5 at 2:12
Leonhardt Guass
14210
14210
Not built-in, because it'd have to be part of the locale.
– alistaire
Nov 5 at 2:16
@alistaire Make sense. Thanks!
– Leonhardt Guass
Nov 5 at 2:19
1
You could pull it out of Unicode CLDR maybe, though that may be as much work as typing out yourself, depending on how far you need to go.
– alistaire
Nov 5 at 2:23
add a comment |
Not built-in, because it'd have to be part of the locale.
– alistaire
Nov 5 at 2:16
@alistaire Make sense. Thanks!
– Leonhardt Guass
Nov 5 at 2:19
1
You could pull it out of Unicode CLDR maybe, though that may be as much work as typing out yourself, depending on how far you need to go.
– alistaire
Nov 5 at 2:23
Not built-in, because it'd have to be part of the locale.
– alistaire
Nov 5 at 2:16
Not built-in, because it'd have to be part of the locale.
– alistaire
Nov 5 at 2:16
@alistaire Make sense. Thanks!
– Leonhardt Guass
Nov 5 at 2:19
@alistaire Make sense. Thanks!
– Leonhardt Guass
Nov 5 at 2:19
1
1
You could pull it out of Unicode CLDR maybe, though that may be as much work as typing out yourself, depending on how far you need to go.
– alistaire
Nov 5 at 2:23
You could pull it out of Unicode CLDR maybe, though that may be as much work as typing out yourself, depending on how far you need to go.
– alistaire
Nov 5 at 2:23
add a comment |
2 Answers
2
active
oldest
votes
up vote
3
down vote
accepted
from library(english)
ordinal(1:5)
# [1] first second third fourth fifth
add a comment |
up vote
0
down vote
I googled "R cardinal numbers" and got to the vignette for the toOrdinal package, but unfortunately it doesn't actually get you words.
library(toOrdinal)
sapply(1:5,toOrdinal)
## [1] "1st" "2nd" "3rd" "4th" "5th"
The docs say
convert_to: OPTIONAL. Output type that provided 'cardinal_number' is
converted into. Default is 'ordinal_number' which refers to
the 'cardinal_number' followed by the appropriate ordinal
indicator. Additional options planned include 'ordinal_word'.
so maybe this will eventually do what you want ...
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
from library(english)
ordinal(1:5)
# [1] first second third fourth fifth
add a comment |
up vote
3
down vote
accepted
from library(english)
ordinal(1:5)
# [1] first second third fourth fifth
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
from library(english)
ordinal(1:5)
# [1] first second third fourth fifth
from library(english)
ordinal(1:5)
# [1] first second third fourth fifth
answered Nov 5 at 2:45
dww
13.5k22551
13.5k22551
add a comment |
add a comment |
up vote
0
down vote
I googled "R cardinal numbers" and got to the vignette for the toOrdinal package, but unfortunately it doesn't actually get you words.
library(toOrdinal)
sapply(1:5,toOrdinal)
## [1] "1st" "2nd" "3rd" "4th" "5th"
The docs say
convert_to: OPTIONAL. Output type that provided 'cardinal_number' is
converted into. Default is 'ordinal_number' which refers to
the 'cardinal_number' followed by the appropriate ordinal
indicator. Additional options planned include 'ordinal_word'.
so maybe this will eventually do what you want ...
add a comment |
up vote
0
down vote
I googled "R cardinal numbers" and got to the vignette for the toOrdinal package, but unfortunately it doesn't actually get you words.
library(toOrdinal)
sapply(1:5,toOrdinal)
## [1] "1st" "2nd" "3rd" "4th" "5th"
The docs say
convert_to: OPTIONAL. Output type that provided 'cardinal_number' is
converted into. Default is 'ordinal_number' which refers to
the 'cardinal_number' followed by the appropriate ordinal
indicator. Additional options planned include 'ordinal_word'.
so maybe this will eventually do what you want ...
add a comment |
up vote
0
down vote
up vote
0
down vote
I googled "R cardinal numbers" and got to the vignette for the toOrdinal package, but unfortunately it doesn't actually get you words.
library(toOrdinal)
sapply(1:5,toOrdinal)
## [1] "1st" "2nd" "3rd" "4th" "5th"
The docs say
convert_to: OPTIONAL. Output type that provided 'cardinal_number' is
converted into. Default is 'ordinal_number' which refers to
the 'cardinal_number' followed by the appropriate ordinal
indicator. Additional options planned include 'ordinal_word'.
so maybe this will eventually do what you want ...
I googled "R cardinal numbers" and got to the vignette for the toOrdinal package, but unfortunately it doesn't actually get you words.
library(toOrdinal)
sapply(1:5,toOrdinal)
## [1] "1st" "2nd" "3rd" "4th" "5th"
The docs say
convert_to: OPTIONAL. Output type that provided 'cardinal_number' is
converted into. Default is 'ordinal_number' which refers to
the 'cardinal_number' followed by the appropriate ordinal
indicator. Additional options planned include 'ordinal_word'.
so maybe this will eventually do what you want ...
answered Nov 5 at 2:47
Ben Bolker
130k11219305
130k11219305
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147450%2fis-there-a-build-in-ordinal-sequence-vector-in-r%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Not built-in, because it'd have to be part of the locale.
– alistaire
Nov 5 at 2:16
@alistaire Make sense. Thanks!
– Leonhardt Guass
Nov 5 at 2:19
1
You could pull it out of Unicode CLDR maybe, though that may be as much work as typing out yourself, depending on how far you need to go.
– alistaire
Nov 5 at 2:23