Dear all,
I have one problem and did not find any solution.
I have attached the question in text file also because sometimes spacing is not
good in mail.
I have a file(file.txt) attached with this mail.I am reading it using this code
to make a data frame (file)-
file=read.table("file.txt",fill=T,colClasses = "character",header=T)
file looks like this-
Chr Pos CaseA CaseC CaseG CaseT
10 135344110 0.000000 24.000000 0.000000 0.000000
10 135344110 0.000000 0.000000 24.000000 0.000000
10 135344110 0.000000 0.000000 24.000000 0.000000
10 135344113 0.000000 0.000000 24.000000 0.000000
10 135344114 24.000000 0.000000 0.000000 0.000000
10 135344114 24.000000 0.000000 0.000000 0.000000
10 135344116 0.000000 0.000000 0.000000 24.000000
10 135344118 0.000000 24.000000 0.000000 0.000000
10 135344118 0.000000 0.000000 0.000000 24.000000
10 135344122 24.000000 0.000000 0.000000 0.000000
10 135344122 0.000000 24.000000 0.000000 0.000000
10 135344123 0.000000 24.000000 0.000000 0.000000
10 135344123 0.000000 24.000000 0.000000 0.000000
10 135344123 0.000000 0.000000 0.000000 24.000000
10 135344126 0.000000 0.000000 24.000000 0.000000
Now some of the values in column Pos are same.For these same positions i want
to add the values of columns 3:6
I will explain with an example-
The output of first row should be-
Chr Pos CaseA CaseC CaseG CaseT
10 135344110 0.000000 24.000000 48.000000 0.000000
because first three rows have same value in Pos column.
so the whole output for above input should be-
Chr Pos CaseA CaseC CaseG CaseT
10 135344110 0.000000 24.000000 48.000000 0.000000
10 135344113 0.000000 0.000000 24.000000 0.000000
10 135344114 48.000000 0.000000 0.000000 0.000000
10 135344116 0.000000 0.000000 0.000000 24.000000
10 135344118 0.000000 24.000000 0.000000 24.000000
10 135344122 24.000000 24.000000 0.000000 0.000000
10 135344123 0.000000 48.000000 0.000000 24.000000
10 135344126 0.000000 0.000000 24.000000 0.000000
Can you please help me.
Thanking you,
Warm Regards
Vikas Bansal
Msc Bioinformatics
Kings College London
Dear all,
I have one problem and did not find any solution.
I have a file(file.txt) attached with this mail.I am reading it using this code
to make a data frame (file)-
file=read.table("file.txt",fill=T,colClasses = "character",header=T)
file looks like this-
Chr Pos CaseA CaseC CaseG CaseT
10 135344110 0.000000 24.000000 0.000000 0.000000
10 135344110 0.000000 0.000000 24.000000 0.000000
10 135344110 0.000000 0.000000 24.000000 0.000000
10 135344113 0.000000 0.000000 24.000000 0.000000
10 135344114 24.000000 0.000000 0.000000 0.000000
10 135344114 24.000000 0.000000 0.000000 0.000000
10 135344116 0.000000 0.000000 0.000000 24.000000
10 135344118 0.000000 24.000000 0.000000 0.000000
10 135344118 0.000000 0.000000 0.000000 24.000000
10 135344122 24.000000 0.000000 0.000000 0.000000
10 135344122 0.000000 24.000000 0.000000 0.000000
10 135344123 0.000000 24.000000 0.000000 0.000000
10 135344123 0.000000 24.000000 0.000000 0.000000
10 135344123 0.000000 0.000000 0.000000 24.000000
10 135344126 0.000000 0.000000 24.000000 0.000000
Now some of the values in column Pos are same.For these same positions i want
to add the values of columns 3:6
I will explain with an example-
The output of first row should be-
Chr Pos CaseA CaseC CaseG CaseT
10 135344110 0.000000 24.000000 48.000000 0.000000
because first three rows have same value in Pos column.
so the whole output for above input should be-
Chr Pos CaseA CaseC CaseG CaseT
10 135344110 0.000000 24.000000 48.000000 0.000000
10 135344113 0.000000 0.000000 24.000000 0.000000
10 135344114 48.000000 0.000000 0.000000 0.000000
10 135344116 0.000000 0.000000 0.000000 24.000000
10 135344118 0.000000 24.000000 0.000000 24.000000
10 135344122 24.000000 24.000000 0.000000 0.000000
10 135344123 0.000000 48.000000 0.000000 24.000000
10 135344126 0.000000 0.000000 24.000000 0.000000
Can you please help me.
Chr Pos CaseA CaseC CaseG CaseT
10 135344110 0.000000 24.000000 0.000000 0.000000
10 135344110 0.000000 0.000000 24.000000 0.000000
10 135344110 0.000000 0.000000 24.000000 0.000000
10 135344113 0.000000 0.000000 24.000000 0.000000
10 135344114 24.000000 0.000000 0.000000 0.000000
10 135344114 24.000000 0.000000 0.000000 0.000000
10 135344116 0.000000 0.000000 0.000000 24.000000
10 135344118 0.000000 24.000000 0.000000 0.000000
10 135344118 0.000000 0.000000 0.000000 24.000000
10 135344122 24.000000 0.000000 0.000000 0.000000
10 135344122 0.000000 24.000000 0.000000 0.000000
10 135344123 0.000000 24.000000 0.000000 0.000000
10 135344123 0.000000 24.000000 0.000000 0.000000
10 135344123 0.000000 0.000000 0.000000 24.000000
10 135344126 0.000000 0.000000 24.000000 0.000000
______________________________________________
R-help@r-project.org mailing list
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.