[R] data.frame with a column containing an array

Georg Kindermann Georg@K|nderm@nn @end|ng |rom gmx@@t
Mon May 29 07:11:35 CEST 2023


Maybe a better solution instead of "don't do it!" might be to change:

x[[j]] <- if(length(dim(xj)) != 2L) xj[i] else xj[i, , drop = FALSE]

at: https://github.com/wch/r-source/blob/trunk/src/library/base/R/dataframe.R#L712

to:

x[[j]] <- if(length(dim(xj)) < 2L) xj[i] else do.call("[",c(list(xj,i), rep(list(bquote()), length(dim(xj))-1L), list(drop = FALSE)))

Would this be possible and work?
Thanks!
Georg

 

Gesendet: Freitag, 26. Mai 2023 um 21:05 Uhr
Von: "Bert Gunter" <bgunter.4567 using gmail.com>
An: "Georg Kindermann" <Georg.Kindermann using gmx.at>
Cc: "Rui Barradas" <ruipbarradas using sapo.pt>, r-help using r-project.org, "Jeff Newmiller" <jdnewmil using dcn.davis.ca.us>
Betreff: Re: Re: Re: [R] data.frame with a column containing an array
Please refer to Jeff Newmiller's response. I believe that your further
exploration of indexing a data frame containing an array column
demonstrates his point: don't do it!

As this discussion could now devolve into a morass of personal opinion
(such as the above), if you or others care to continue, please do so
**offlist**. However, I have nothing further to say in any case.

Cheers,
Bert



More information about the R-help mailing list