Hello, I am new in Rstudio. After trying for a week to create it by myself I will be glad if you could help me -
I am trying to create a map of us cities and show using different colors the distribution of a specific variable across us cities. I guess that my confusion is due to the number of codes there are to generate a map and I am not sure which code to use and also if I should draw the map across cities or counties. I guess it is a simple question but for me it is not simple at all. Thank you for all your help.
I have tried using this code:
mapdata <- read.csv("C:/Users//Data/2014.csv", header=TRUE, stringsAsFactors=FALSE)
data(mapdata)
mapdata$per_credit = mapdata$loan_amount_000s / sum(mapdata$loan_amount_000s)
names(mapdata)
(mapdata1 <- mapdata[, c(21, 23, 25, 14, 24, 26, 28, 79)])
View(mapdata1)
aggregate(mapdata1$loan_amount_000s, by=list(state_code=mapdata1$state_code), FUN=sum)
(mapdata1 <- mapdata[, c(21, 23, 25, 14, 24, 26, 28, 79)])
View(mapdata1)
aggregate(mapdata1$loan_amount_000s, by=list(state_code=mapdata1$state_code), FUN=sum)
mapdata$per_credit = mapdata$loan_amount_000s / sum(mapdata$loan_amount_000s)
all_states <- map_data("state")
all_states
head(all_states)
Map<-mapdata1 %>%
rename(
region = state_name
)
Map$region<-tolower(Map$region)
Total <- merge(all_states, Map, by=region)
And here I am stuck because the merger does not work.
Any help will be highly beneficial.