[R] reshaping the data
Bogdan Tanasa
tanasa at gmail.com
Mon Jul 3 09:22:07 CEST 2017
Dear all,
I would appreciate please a piece of help regarding the use of acast/dcast
functions in reshape2 package.
Specifically, I'm working with a data frame, that has information about
SAMPLE, GENE, and TYPE of MUTATION (as shown below):
Sample Gene Type
22M AEBP1 SNV
17M AEBP1 SNV
22M ATR INDEL
22M ATR SNV
11M BTK SNV
11M BTK INDEL
I would like to transform this DATAFRAME into a MATRIX that has GENE on
ROWS, SAMPLE on COLUMNS, and the elements of the matrix are SNV or INDEL
(ie the types of mutations).
The R code starts with :
y <- data.frame(Sample = x$Sample, Gene = x$Gene, Type=x$Type)
z <- acast(y, Cancer_Gene ~ Sample)
although in z, I do not have the information on Type (i.e.SNV or INDEL).
thanks a lot,
-- bogdan
[[alternative HTML version deleted]]
More information about the R-help
mailing list