[R] using "dcast" function ?
Ulrik Stervbo
ulrik.stervbo at gmail.com
Fri May 26 12:45:05 CEST 2017
It is correct and will produce a data.frame. But I guess the result is not
what you intend since the resulting data.frame nothing but NA and Samples
in the diagonal:
df1 <- data.frame(x = letters[1:5], y = letters[6:10])
reshape2::dcast(df1, x ~ y)
You are missing values somewhere. If you want all possible combinations of
Cancer_Gene and Sample, look at expand.grid:
expand.grid(df1)
HTH
Ulrik
On Fri, 26 May 2017 at 11:26 Bogdan Tanasa <tanasa at gmail.com> wrote:
> Dear all, I would like to double-check with you please the use of "acast"
> or "dcast" function from "reshape2"package.
>
> I am starting with a data frame Y of GENES and SAMPLES,eg :
>
> Cancer_Gene Sample
> 1 ABL2 WT_10T
> 2 ABL2 WT_6T
> 3 ADGRA2 HB_8R
> 4 AFF4 EWS_13R
>
> and I would like to have a dataframe/matrix of CANCER_GENES * SAMPLES.
>
> Shall I do " dcast(Y, Cancer_Gene ~ Sample)", would it be correct ? thank
> you !
>
> -- bogdan
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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]]
More information about the R-help
mailing list