This is really strange but for some reason, I can't use dput
with my dataframe.
When I run this:
df_reconstituted <- structure(list(region = c("alabama", "alaska", "arizona", "arkansas",
"california", "colorado", "connecticut", "delaware", "district of columbia",
"florida", "georgia", "hawaii", "idaho", "illinois", "indiana",
"iowa", "kansas", "kentucky", "louisiana", "maine", "maryland",
"massachusetts", "michigan", "minnesota", "mississippi", "missouri",
"montana", "nebraska", "nevada", "new hampshire", "new jersey",
"new mexico", "new york", "north carolina", "north dakota", "ohio",
"oklahoma", "oregon", "pennsylvania", "rhode island", "south carolina",
"south dakota", "tennessee", "texas", "utah", "virginia", "washington",
"west virginia", "wisconsin", "wyoming"), decade = c(1980, 1980,
1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980,
1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980,
1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980,
1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980,
1980, 1980, 1980, 1980), value = c(628L, 92L, 1636L, 232L, 12690L,
580L, 1070L, 28L, 460L, 6997L, 210L, 884L, 70L, 3276L, 1775L,
186L, 250L, 1376L, 2273L, 350L, 921L, 1152L, 3848L, 704L, 502L,
698L, 146L, 404L, 6678L, 94L, 11270L, 148L, 5957L, 484L, 158L,
2474L, 1827L, 858L, 3942L, 284L, 1136L, 142L, 1817L, 6887L, 88L,
1306L, 578L, 648L, 404L, 20L)), class = c("grouped_df", "tbl_df",
"tbl", "data.frame"), row.names = c(NA, -50L), .Names = c("region",
"decade", "value"), vars = list(region))
I get:
`Error in structure(list(region = c("alabama", "alaska", "arizona", "arkansas", :
object 'region' not found`
I can't imagine why. It looks like the column 'region' is included. My only thought is that perhaps it's an issue the the original df. I used a lot of dplyr
on it, so maybe it is in some format that dput
doesn't handle. It looks like this:
> str(df)
Classes ‘grouped_df’, ‘tbl_df’, ‘tbl’ and 'data.frame': 50 obs. of 3 variables:
$ region: chr "alabama" "alaska" "arizona" "arkansas" ...
$ decade: num 1980 1980 1980 1980 1980 1980 1980 1980 1980 1980 ...
$ value : int 628 92 1636 232 12690 580 1070 28 460 6997 ...
- attr(*, "vars")=List of 1
..$ : symbol region
Thanks for any advice.