How do I use the usmap package to convert the state variable to the FIPS code?









up vote
0
down vote

favorite












I also want to change the state column to be in terms of the FIPS code. Just not sure what parameters to use and how to do this since I am new to R.



Here are the parameters given by R:



plot_usmap(regions = c("states", "state", "counties", "county"),
include = c(), data = data.frame(), values = "values",
theme = theme_map(), lines = "black", labels = FALSE,
label_color = "black")









share|improve this question

























    up vote
    0
    down vote

    favorite












    I also want to change the state column to be in terms of the FIPS code. Just not sure what parameters to use and how to do this since I am new to R.



    Here are the parameters given by R:



    plot_usmap(regions = c("states", "state", "counties", "county"),
    include = c(), data = data.frame(), values = "values",
    theme = theme_map(), lines = "black", labels = FALSE,
    label_color = "black")









    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I also want to change the state column to be in terms of the FIPS code. Just not sure what parameters to use and how to do this since I am new to R.



      Here are the parameters given by R:



      plot_usmap(regions = c("states", "state", "counties", "county"),
      include = c(), data = data.frame(), values = "values",
      theme = theme_map(), lines = "black", labels = FALSE,
      label_color = "black")









      share|improve this question













      I also want to change the state column to be in terms of the FIPS code. Just not sure what parameters to use and how to do this since I am new to R.



      Here are the parameters given by R:



      plot_usmap(regions = c("states", "state", "counties", "county"),
      include = c(), data = data.frame(), values = "values",
      theme = theme_map(), lines = "black", labels = FALSE,
      label_color = "black")






      r parameters usmap






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 at 21:04









      nathan

      666




      666






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          It is unclear exactly what you are trying to achieve without an example, but here is how I was able to convert a column state in a data.frame from the abbreviation to the FIPS code:



          > library(usmap)
          > df <- statepop[1:5, -1]
          > names(df)[1] <- 'state'
          > df
          # A tibble: 5 x 3
          state full pop_2015
          <chr> <chr> <dbl>
          1 AL Alabama 4858979
          2 AK Alaska 738432
          3 AZ Arizona 6828065
          4 AR Arkansas 2978204
          5 CA California 39144818
          > df$fips <- fips(df$state)
          > df
          # A tibble: 5 x 4
          state full pop_2015 fips
          <chr> <chr> <dbl> <chr>
          1 AL Alabama 4858979 01
          2 AK Alaska 738432 02
          3 AZ Arizona 6828065 04
          4 AR Arkansas 2978204 05
          5 CA California 39144818 06





          share|improve this answer






















          • how do I call statepop? I also get an error saying select doesn't exist
            – nathan
            Nov 9 at 21:31






          • 1




            statepop is built in to the usmap package. I updated my answer to show that I loaded the library and to remove the call to select, which is from another package.
            – C. Braun
            Nov 9 at 21:40










          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%2f53233246%2fhow-do-i-use-the-usmap-package-to-convert-the-state-variable-to-the-fips-code%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          It is unclear exactly what you are trying to achieve without an example, but here is how I was able to convert a column state in a data.frame from the abbreviation to the FIPS code:



          > library(usmap)
          > df <- statepop[1:5, -1]
          > names(df)[1] <- 'state'
          > df
          # A tibble: 5 x 3
          state full pop_2015
          <chr> <chr> <dbl>
          1 AL Alabama 4858979
          2 AK Alaska 738432
          3 AZ Arizona 6828065
          4 AR Arkansas 2978204
          5 CA California 39144818
          > df$fips <- fips(df$state)
          > df
          # A tibble: 5 x 4
          state full pop_2015 fips
          <chr> <chr> <dbl> <chr>
          1 AL Alabama 4858979 01
          2 AK Alaska 738432 02
          3 AZ Arizona 6828065 04
          4 AR Arkansas 2978204 05
          5 CA California 39144818 06





          share|improve this answer






















          • how do I call statepop? I also get an error saying select doesn't exist
            – nathan
            Nov 9 at 21:31






          • 1




            statepop is built in to the usmap package. I updated my answer to show that I loaded the library and to remove the call to select, which is from another package.
            – C. Braun
            Nov 9 at 21:40














          up vote
          1
          down vote













          It is unclear exactly what you are trying to achieve without an example, but here is how I was able to convert a column state in a data.frame from the abbreviation to the FIPS code:



          > library(usmap)
          > df <- statepop[1:5, -1]
          > names(df)[1] <- 'state'
          > df
          # A tibble: 5 x 3
          state full pop_2015
          <chr> <chr> <dbl>
          1 AL Alabama 4858979
          2 AK Alaska 738432
          3 AZ Arizona 6828065
          4 AR Arkansas 2978204
          5 CA California 39144818
          > df$fips <- fips(df$state)
          > df
          # A tibble: 5 x 4
          state full pop_2015 fips
          <chr> <chr> <dbl> <chr>
          1 AL Alabama 4858979 01
          2 AK Alaska 738432 02
          3 AZ Arizona 6828065 04
          4 AR Arkansas 2978204 05
          5 CA California 39144818 06





          share|improve this answer






















          • how do I call statepop? I also get an error saying select doesn't exist
            – nathan
            Nov 9 at 21:31






          • 1




            statepop is built in to the usmap package. I updated my answer to show that I loaded the library and to remove the call to select, which is from another package.
            – C. Braun
            Nov 9 at 21:40












          up vote
          1
          down vote










          up vote
          1
          down vote









          It is unclear exactly what you are trying to achieve without an example, but here is how I was able to convert a column state in a data.frame from the abbreviation to the FIPS code:



          > library(usmap)
          > df <- statepop[1:5, -1]
          > names(df)[1] <- 'state'
          > df
          # A tibble: 5 x 3
          state full pop_2015
          <chr> <chr> <dbl>
          1 AL Alabama 4858979
          2 AK Alaska 738432
          3 AZ Arizona 6828065
          4 AR Arkansas 2978204
          5 CA California 39144818
          > df$fips <- fips(df$state)
          > df
          # A tibble: 5 x 4
          state full pop_2015 fips
          <chr> <chr> <dbl> <chr>
          1 AL Alabama 4858979 01
          2 AK Alaska 738432 02
          3 AZ Arizona 6828065 04
          4 AR Arkansas 2978204 05
          5 CA California 39144818 06





          share|improve this answer














          It is unclear exactly what you are trying to achieve without an example, but here is how I was able to convert a column state in a data.frame from the abbreviation to the FIPS code:



          > library(usmap)
          > df <- statepop[1:5, -1]
          > names(df)[1] <- 'state'
          > df
          # A tibble: 5 x 3
          state full pop_2015
          <chr> <chr> <dbl>
          1 AL Alabama 4858979
          2 AK Alaska 738432
          3 AZ Arizona 6828065
          4 AR Arkansas 2978204
          5 CA California 39144818
          > df$fips <- fips(df$state)
          > df
          # A tibble: 5 x 4
          state full pop_2015 fips
          <chr> <chr> <dbl> <chr>
          1 AL Alabama 4858979 01
          2 AK Alaska 738432 02
          3 AZ Arizona 6828065 04
          4 AR Arkansas 2978204 05
          5 CA California 39144818 06






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 9 at 21:39

























          answered Nov 9 at 21:25









          C. Braun

          2,456428




          2,456428











          • how do I call statepop? I also get an error saying select doesn't exist
            – nathan
            Nov 9 at 21:31






          • 1




            statepop is built in to the usmap package. I updated my answer to show that I loaded the library and to remove the call to select, which is from another package.
            – C. Braun
            Nov 9 at 21:40
















          • how do I call statepop? I also get an error saying select doesn't exist
            – nathan
            Nov 9 at 21:31






          • 1




            statepop is built in to the usmap package. I updated my answer to show that I loaded the library and to remove the call to select, which is from another package.
            – C. Braun
            Nov 9 at 21:40















          how do I call statepop? I also get an error saying select doesn't exist
          – nathan
          Nov 9 at 21:31




          how do I call statepop? I also get an error saying select doesn't exist
          – nathan
          Nov 9 at 21:31




          1




          1




          statepop is built in to the usmap package. I updated my answer to show that I loaded the library and to remove the call to select, which is from another package.
          – C. Braun
          Nov 9 at 21:40




          statepop is built in to the usmap package. I updated my answer to show that I loaded the library and to remove the call to select, which is from another package.
          – C. Braun
          Nov 9 at 21:40

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233246%2fhow-do-i-use-the-usmap-package-to-convert-the-state-variable-to-the-fips-code%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Use pre created SQLite database for Android project in kotlin

          Darth Vader #20

          Ondo