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?










share|improve this question






















  • 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















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?










share|improve this question






















  • 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













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?










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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












2 Answers
2






active

oldest

votes

















up vote
3
down vote



accepted










from library(english)



ordinal(1:5)
# [1] first second third fourth fifth





share|improve this answer




























    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 ...






    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      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
































      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





      share|improve this answer

























        up vote
        3
        down vote



        accepted










        from library(english)



        ordinal(1:5)
        # [1] first second third fourth fifth





        share|improve this answer























          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          from library(english)



          ordinal(1:5)
          # [1] first second third fourth fifth





          share|improve this answer












          from library(english)



          ordinal(1:5)
          # [1] first second third fourth fifth






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 5 at 2:45









          dww

          13.5k22551




          13.5k22551
























              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 ...






              share|improve this answer

























                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 ...






                share|improve this answer























                  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 ...






                  share|improve this answer












                  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 ...







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 5 at 2:47









                  Ben Bolker

                  130k11219305




                  130k11219305






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      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




















































































                      這個網誌中的熱門文章

                      Tangent Lines Diagram Along Smooth Curve

                      Yusuf al-Mu'taman ibn Hud

                      Zucchini