[datatable-help] using functions which return a vector

Matthew Dowle mdowle at mdowle.plus.com
Fri Aug 31 00:47:21 CEST 2012


Hi,

> IRIS[, as.list(quantile(Sepal.Length)), by = Species]
      Species  0%   25% 50% 75% 100%
1:     setosa 4.3 4.800 5.0 5.2  5.8
2: versicolor 4.9 5.600 5.9 6.3  7.0
3:  virginica 4.9 6.225 6.5 6.9  7.9

Matthew

>
> Hello,
>
> Sorry for the simple question, but how do I use a function, such as
> quantile, which returns multiple values.
>
> For example,
>
> data(iris)
> IRIS  <- as.data.table(iris)
> IRIS[, quantile(Sepal.Length), by = Species]
>
> ## returns the following.
>        Species    V1
>  1:     setosa 4.300
>  2:     setosa 4.800
>  3:     setosa 5.000
>  4:     setosa 5.200
>  5:     setosa 5.800
>  6: versicolor 4.900
>  7: versicolor 5.600
>  8: versicolor 5.900
> ....
>
> I would like the values returned as columns or a vector with the column
> names returned by the quantile function.
>
> Thanks,
>
> Matt
>  		 	   		  _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help




More information about the datatable-help mailing list