[R] Can nested data frame be used in machine learning?
Jeff Newmiller
jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Sun Oct 13 23:08:02 CEST 2019
predict doesn't know about nesting. You can either unnest or use lapply or purrr:map to create new nested data frames with predicted results, but it is up to you to decide where you want to put the results.
On October 13, 2019 10:03:36 AM PDT, vod vos via R-help <r-help using r-project.org> wrote:
>Hello,
>
>If we got a data frame like below, how to use "data" to predict type,
> if "data" is another data frame (called nested data frame):
>
>
>by_subject
>#> # A tibble: 1000 x 3
>#> subject type data
>#> <fct> <fct> <list>
>#> 1 subject1 aa <tibble [100 × 10]>
>#> 2 subject2 bb <tibble [100 × 10]>
>#> 3 subject3 cc <tibble [100 × 10]>
>#> # … with 997 more rows
>
>
>by_subject$data[[1]]
>#> # A tibble: 100 x 10
>#> parts weight length height
>#> <int> <dbl> <int> <dbl>
>#> 1 1 28.8 100 170
>#> 2 2 30.3 105 169
>#> 2 3 10.5 109 189
>#> # … with 97 more rows
>
>Sincerely yours,
>
>______________________________________________
>R-help using 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.
--
Sent from my phone. Please excuse my brevity.
More information about the R-help
mailing list