How can I transform a three column data frame into a binary-table in R?
0
0
Entering edit mode
22 months ago

Hello, I have a data frame with three columns, where the first of them is the samples ID, the second one are the genes that have been found mutated in these samples (cancer samples) and the last one indicates the source where the sample was obtained. Please do notice that every gene is in a row, so if a sample has three genes mutated, the sample ID and the source information will be repeated in every row. I would like to transform the gene column into multiple column names, and if a sample had mutated that gene, it should show a "1". On the other hand, if the gene were not mutated, it should show a "0", so every gene should not be repeated.

is it possible to do that? how can I get it using R?

Thanks in advance!

rstudio • 419 views
ADD COMMENT
0
Entering edit mode

Please, post example data as well as what you have already tried!

ADD REPLY

Login before adding your answer.

Traffic: 2567 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6