Hello list,
I read in a txt file using
B-read.table(file=data.snp,header=TRUE,row.names=NULL)
by specifying the row.names=NULL so that the rows are numbered.
Below is an example after how the table looks like using
B[1:10,1:3]
SNPChromosome PhysicalPosition
1
Here is a way of doing it using 'rle':
x - read.table(textConnection( SNPChromosome
PhysicalPosition
+ 1 SNP_A-1909444 1 7924293
+ 2 SNP_A-2237149 1 8173763
+ 3 SNP_A-4303947 1 8191853
+ 4 SNP_A-2236359 1
Am I missing something? ...
Why not: range(seq(nrow(B))[B[,2]==1] ) ?? ## note: == not =
Alternatively, and easily generalized (to start with a frame which is a
subset of the original and any subset of rows, contiguous or not)
range(as.numeric(row.names(B)[B[,2]==1]))
Again, am I missing
That works for the specific value of '1', but you would have to repeat
it for other values in the column. If you had 100 different ranges in
that column, what would you do? Here is another solution using
'range' on the same data:
tapply(seq_len(nrow(x)), x$Chromosome, range)
$`1`
[1] 1 6
$`2`
Thanks a lot, Jim and Bert. It worked pretty well.
Best,
Allen
On Nov 14, 2007 12:11 PM, jim holtman [EMAIL PROTECTED] wrote:
That works for the specific value of '1', but you would have to repeat
it for other values in the column. If you had 100 different ranges in
that column, what
One way to do this is
range(which(B[,2]==1))
Julian
affy snp wrote:
Hello list,
I read in a txt file using
B-read.table(file=data.snp,header=TRUE,row.names=NULL)
by specifying the row.names=NULL so that the rows are numbered.
Below is an example after how the table looks like using
Thank you very much, Julian. I got it.
Best,
Allen
On Nov 14, 2007 2:38 PM, Julian Burgos [EMAIL PROTECTED] wrote:
One way to do this is
range(which(B[,2]==1))
Julian
affy snp wrote:
Hello list,
I read in a txt file using
7 matches
Mail list logo