It would make helping you easier if you presented your data
in a format that others could copy and paste into R. E.g.,
z <- list(data.frame(favoriteValue=c(23527,21837),
Classification=c("xxxx","xyxy")),
data.frame(favoriteValue=c(25427,21237,21997),
Classification=c("xxxx","xyxy","xyxy")),
data.frame(favoriteValue=c(99427),
Classification=c("xxxx")))
You asked from something that "looks like" comma-separated strings of
numerals.
> zAll <- do.call(rbind, z)
> zAll$ID <- rep(seq_along(z), vapply(z, nrow, 0)) # which data.frame each
row came from> zAll
favoriteValue Classification ID
1 23527 xxxx 1
2 21837 xyxy 1
3 25427 xxxx 2
4 21237 xyxy 2
5 21997 xyxy 2
6 99427 xxxx 3> library(dplyr)
> zAll %>% group_by(ID) %>% summarize(favoriteValue =
paste(favoriteValue,
collapse=","))
# A tibble: 3 x 2
ID favoriteValue
<int> <chr>
1 1 23527,21837
2 2 25427,21237,21997
3 3 99427
It is usually better say how you intend the use the result of your data
manipulation, rather that how it looks when printed. The comma-separated
strings are not handy for answering questions like "what are the most
common favoriteValues?" or "who has the most favoriteValues?" -
the format
used in zAll is better for that.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Nov 6, 2018 at 11:06 AM, JEFFERY REICHMAN <reichmanj at
sbcglobal.net>
wrote:
> r-help Forum
>
> With a bit of r-help yesterday I was able to structure a JSON file such
> that I can read it within the R environment and export what I need except
> for one list object.
>
> So when I run ....
>
> location <- json.raw[["favorites"]]
> thead(location)
>
> # R returns something like ...
>
> [[1]]
> favoriteValue favoriteType Classification
> 1 23527 https:// ..... xxxx
> 2 21837 https:// ..... xyxy
>
> [[2]]
> favoriteValue favoriteType Classification
> 1 25427 https:// ..... xxxx
> 2 21237 https:// ..... xyxy
> 3 21997 https:// ..... xyxy
>
> [[3]]
> favoriteValue favoriteType Classification
> 1 99427 https:// ..... xxxx
>
>
> What I want (need) is a data frame that looks like
>
> favoriteValue
> 1 23527, 21837
> 2 25427, 21237, 21997
> 3 99427
>
> Jeff Reichman
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]