r - Use an external object as plotted size with maps and geom_point -


i have working code refers csv (mapdata) plot 2 sets of data on top of map. interested in building in user input allows user running script select columns of data want plot on map, , update geom_point() command accordingly.

i have been working as.numeric , readline() categorize request each set of data

# select first variable use: selectfirst <- function()  {    as.numeric(readline("please enter number select first: \n 1-clinical_trial\n 2- comparative_study\n 3-evaluation_studies\n 4-in_vitro\n 5- journal_article\n 6-consensus_development_conference\n 7-guideline\n 8-research_support_nonusgovt\n 9-total>>> "))  }  input_first <- selectfirst()  print(input_first)  # define first variable based on numeric input first <- "error" if(input_first == 1){     first <- 'clinical_trial' } else if(input_first == 2){.....  

and on, resulting in 2 variables (first , second). define

all_states <- map_data("state") g <- ggplot()   g <- g + geom_polygon(data=all_states, aes(x=long, y=lat, group = group),                       colour="grey", fill="white" )  print(g)  plot.new()  mappoints <- g + geom_point(data = mapdata,                             aes(x=lon, y=lat, size = [first or second]),                          color = "#1100e7", bg = "#43c9e7", alpha = .75,                             shape = 21) + scale_size(range=c(3,15)) 

what make size variable within aes refer first , second variables designated outside geom_point function. possible given geom_point() structure?


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -