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")
r parameters usmap
add a comment |
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")
r parameters usmap
add a comment |
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")
r parameters usmap
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
r parameters usmap
asked Nov 9 at 21:04
nathan
666
666
add a comment |
add a comment |
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
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 theusmap
package. I updated my answer to show that I loaded the library and to remove the call toselect
, which is from another package.
– C. Braun
Nov 9 at 21:40
add a comment |
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
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 theusmap
package. I updated my answer to show that I loaded the library and to remove the call toselect
, which is from another package.
– C. Braun
Nov 9 at 21:40
add a comment |
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
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 theusmap
package. I updated my answer to show that I loaded the library and to remove the call toselect
, which is from another package.
– C. Braun
Nov 9 at 21:40
add a comment |
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
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
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 theusmap
package. I updated my answer to show that I loaded the library and to remove the call toselect
, which is from another package.
– C. Braun
Nov 9 at 21:40
add a comment |
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 theusmap
package. I updated my answer to show that I loaded the library and to remove the call toselect
, 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
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
Required, but never shown
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
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
Required, but never shown
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
Required, but never shown
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
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