Question: convert one column values into row values based on other row values
0
gravatar for newbiebio
4.2 years ago by
newbiebio80
newbiebio80 wrote:

I have two columns, one column is the name of wells, the other column is the ct values. ex

well    ct
A    10
A    9
A    NA
A    19

Now I want to put the ct values into one row based on well name. Each column is one ct value, NA is a value too. ex

Well ct
A    10   9    NA   19

I tried to used aggregae in r, but it omits NA and put all the values in a vector into one columns,

R • 2.2k views
ADD COMMENTlink modified 4.2 years ago by venu6.8k • written 4.2 years ago by newbiebio80
1

This is a programming question not a Bioinformatics one!

ADD REPLYlink written 4.2 years ago by Deepak Tanwar4.1k

It's a thin line, considering that this issue is clearly a bio-application which OP tries to solve informatically...

ADD REPLYlink written 4.2 years ago by WouterDeCoster45k
2
gravatar for venu
4.2 years ago by
venu6.8k
Germany
venu6.8k wrote:

An alternate (to R) quick solution

cat file.txt | datamash -H -s -g 1 collapse 2 > result.txt

result.txt

GroupBy(well)   collapse(ct)
A   10,9,NA,19
B   11,12

P.S: datamash & add | tr ',' '\t' at the end of the command if it is nesessary to convert commas into tabs

ADD COMMENTlink modified 4.2 years ago • written 4.2 years ago by venu6.8k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2406 users visited in the last hour
_