> library(reshape2)
> library(data.table)
> library(ggplot2)
> library(ggmap)
> library(maps)
> library(mapdata)
> library(purrr)
> library(plyr)
> library(tidyverse)
> #made with help from R Studio Community
> # build vectors
> county <- c(demographics_dat$county.name)
> state <- c(demographics_dat$state.name)
> pop <- c(demographics_dat$pop.size)
> poverty <- c(demographics_dat$poverty)
> # now we assemble into data frame from vectors
> pov <- data.frame(county, state, pop, poverty)
> # assembled pipe
> stateandpov <- pov %>% group_by(state) %>% summarize(mean_pov = mean(poverty))
> #Join both mean pop and mean pov together
> meanandpov <- join(stateandpov,stateandmeanpop, by='state')
> hist(meanandpov$mean_pov)
> plot(meanandpov$mean_pov)
> #Create dataframe for states
> states <- map_data("state")
> USA <- map_data("usa")
> dim(states)
[1] 15537 6
> #Test it out
> ggplot(data = states) + ggplot(data = stateandmeanpop$mean_pop) +
+ geom_polygon(aes(x = long, y = lat, fill = region, group = group),
+ color = "white") +
+ coord_fixed(1.3) +
+ guides(fill=FALSE)
Error: `data` must be a data frame, or other object coercible by `fortify()`, not a numeric vector
Just wondering why I keep getting the error also, first attempt at cleaning this up before posting let see how i did
okay so not good I am sorry!!!
I am sorry to everyone who has to strain to read this post