Best way to store variable-length data in an R data.frame?

前端 未结 5 1183
日久生厌
日久生厌 2021-02-06 02:59

I have some mixed-type data that I would like to store in an R data structure of some sort. Each data point has a set of fixed attributes which may be 1-d numeric, factors, or

5条回答
  •  醉酒成梦
    2021-02-06 03:54

    I would also use strings for the variable length data, but as in the following example: "c(5,5)" for the first phrase. One needs to use eval(parse(text=...)) to carry out computations.

    For example, the mean can be computed as follows:

    sapply(data$token_lengths,function(str) mean(eval(parse(text=str))))

提交回复
热议问题