I have a dataframe where there are multiple cities. I need a separate json object for each state.
so the observation looks like the following:
name country state
Lake Forest VT, CA, IL, NJ, NC
the object is
"location":[{
"name": "Lake Forest",
"state": "VT",
"country": ""},{
"name": "Lake Forest",
"state": "CA",
"country": ""},{
"name": "Lake Forest",
"state": "IL",
"country": ""},{
"name": "Lake Forest",
"state": "NJ",
"country": ""},{
"name": "Lake Forest",
"state": "NC",
"country": ""}]
some sample data (with the dput) is given below:
structure(list(name = c("Lake Forest", "Yale,UC Berkeley", "Harvard,Emory,the University of Denver,the University of Washington,Vassar College,Lake Forest,Texas Christian University", "MIT,Princeton,Yale,UCLA,NYU,Emory,UC Berkeley,UNC-Chapel Hill,American,the University of Washington,Lake Forest College,the University of Texas at Austin", "Princeton,Yale"), country = c("", "", "", "", ""), state = list(c("VT", "CA", "IL", "NJ", "NC"), character(0), character(0), character(0), c("CA", "CO", "CT", "FL", "GA", "IL", "IN", "MD", "MA", "MI", "MN", "MO", "NV", "NH", "NJ", "NY", "NC", "OH", "OR", "PA", "RI", "TN", "TX", "VA", "WA"))), .Names = c("name",
"country", "state"), row.names = c(3265L, 3755L, 3756L, 3757L, 3759L), class = "data.frame")