Re: [R] counting number of G in TCGGGGGACAATCGGTAACCCGTCT

2008-07-15 Thread Patrick Aboyoun
Henrik, As Wolfgang mentioned, the Biostrings package in Bioconductor has a number of sequence manipulation functions. The alphabetFrequency function would get you what you need. library(Biostrings) alphabetFrequency(DNAString(TCGACAATCGGTAACCCGTCT)) A C G T M R W S Y K V H D B N - + 5

Re: [R] counting number of G in TCGGGGGACAATCGGTAACCCGTCT

2008-07-15 Thread Riley, Steve
To: [EMAIL PROTECTED] Subject: [R] counting number of G in TCGACAATCGGTAACCCGTCT Any better solution than this ? sum(strsplit(TCGACAATCGGTAACCCGTCT, )[[1]] == G) _ [[alternative HTML version deleted

Re: [R] counting values on one colum only

2008-03-23 Thread Felipe Carrillo
CDT To: [EMAIL PROTECTED] Subject: [R] counting values on one colum only i'm not sure i understand what you want because, by definition, a dataframe can't have a different number of rows in each column ? maybe i-nrow(!is.na(weekly$a)) if the blanks are actually NAs

[R] counting values on one colum only

2008-03-22 Thread Felipe Carrillo
Hi all: Can someone help me count the number of rows with values in colum a only. assume the name of my dataframe is weekly I was trying i- nrows(weekly$a) i but returns 7 when it should be 4. Thanks a b c d 27.000 27.000 1.569 0.013

Re: [R] counting values on one colum only

2008-03-22 Thread jim holtman
There are 7 rows since this is probably a data frame and each column in a dataframe (or a matrix in this case) all have the same number of rows. I think what you want is to 'sum' the number of times a condition is met; this might come closer to what you were expecting: sum(weekly$a != 0) On

[R] counting specific elements in a column of a matrix

2008-03-08 Thread Donna Tucker
Hello, I would like to know how to count the number (cardinality) of a specific element in a single row of a matrix. At this time I have 30X3 matrix. The first column is the treatment number for each data point. I would like to know how many of each treatments are in this matrix. i.e. I

Re: [R] counting specific elements in a column of a matrix

2008-03-08 Thread jim holtman
?table e.g., table(your.matrix[,1]) On Sat, Mar 8, 2008 at 3:15 PM, Donna Tucker [EMAIL PROTECTED] wrote: Hello, I would like to know how to count the number (cardinality) of a specific element in a single row of a matrix. At this time I have 30X3 matrix. The first column is the

[R] counting sequence mismatches

2008-02-22 Thread joseph
Hello I have 2 columns of short sequences that I would like to compare and count the number of mismatches and record the number of mismatches in a new column. The sequences are part of a data frame that looks like this: seq1=c(CGGTGTAGAGGAAAGGAAACAGGAGTTC,CGGTGGTCAGTCTGGGACCTGGGCAGCAGGCT,

Re: [R] counting sequence mismatches

2008-02-22 Thread Martin Morgan
One kind of ugly solution d.f=data.frame(seq1, seq2, stringsAsFactors=FALSE) d.f[[nMismatch]] - with(d.f, { + m - mapply(!=, strsplit(seq1, ), strsplit(seq2, )) + colSums(m) + }) Check out the Bioconductor Biostrings package, especially the version available with the development version

Re: [R] counting row repetitions without loop

2008-02-07 Thread Waterman, DG (David)
. Cheers David. -Original Message- From: Doran, Harold [mailto:[EMAIL PROTECTED] Sent: 06 February 2008 15:03 To: Doran, Harold; Waterman, DG (David); r-help@r-project.org Subject: RE: [R] counting row repetitions without loop Sorry, word wrap made that incomprehensible, I think x y 4 5 6 7

[R] counting row repetitions without loop

2008-02-06 Thread Waterman, DG (David)
Hi, I have a data frame consisting of coordinates on a 10*10 grid, i.e. example x y 1 4 5 2 6 7 3 6 6 4 7 5 5 5 7 6 6 7 7 4 5 8 6 7 9 7 6 10 5 6 What I would like to do is return an 10*10 matrix consisting of counts at each position, so in the above example

Re: [R] counting row repetitions without loop

2008-02-06 Thread James Foadi
On Wednesday 06 February 2008 14:08, Waterman, DG (David) wrote: Hi, I have a data frame consisting of coordinates on a 10*10 grid, i.e. example x y 1 4 5 2 6 7 3 6 6 4 7 5 5 5 7 6 6 7 7 4 5 8 6 7 9 7 6 10 5 6 What I would like to do is return

Re: [R] counting row repetitions without loop

2008-02-06 Thread Doran, Harold
: [R] counting row repetitions without loop Hi, I have a data frame consisting of coordinates on a 10*10 grid, i.e. example x y 1 4 5 2 6 7 3 6 6 4 7 5 5 5 7 6 6 7 7 4 5 8 6 7 9 7 6 10 5 6 What I would like to do is return an 10*10 matrix

Re: [R] counting row repetitions without loop

2008-02-06 Thread Doran, Harold
=10) gg - matrix(c(dat$x, dat$y), ncol=2) mat[gg] - dat$Freq -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Doran, Harold Sent: Wednesday, February 06, 2008 9:56 AM To: Waterman, DG (David); r-help@r-project.org Subject: Re: [R] counting row

[R] counting identical data in a column

2008-02-04 Thread joseph
Hi Peter I have the following data frame with chromosome name, start and end positions: chrN start end 1 chr1 11122333 11122633 2 chr1 11122333 11122633 3 chr3 11122333 11122633 8 chr3 111273334 111273634 7 chr2 12122334 12122634 4 chr1 21122377 21122677 5 chr2 33122355

Re: [R] counting identical data in a column

2008-02-04 Thread jim holtman
Is this what you want? x - read.table(textConnection( chrN start end + 1 chr1 11122333 11122633 + 2 chr1 11122333 11122633 + 3 chr3 11122333 11122633 + 8 chr3 111273334 111273634 + 7 chr2 12122334 12122634 + 4 chr1 21122377 21122677 + 5 chr2 33122355 33122655 + 6 chr2

[R] counting weekday in a month in R

2007-12-13 Thread tom soyer
Hi, I am trying to count weekday of the month using R. For example, 1/4/2001 is the 4th weekday of Jan, and 1/5/2001 is the 5th weekday of the month, and 1/8/2001 is the 6th weekday of the month, etc. I get as far as extracting the weekdays from a sequence of dates (see below). But I have not yet

Re: [R] counting weekday in a month in R

2007-12-13 Thread Nordlund, Dan (DSHS/RDA)
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of tom soyer Sent: Thursday, December 13, 2007 1:27 PM To: r-help@r-project.org Subject: [R] counting weekday in a month in R Hi, I am trying to count weekday of the month using R. For example, 1

Re: [R] counting strings of identical values in a matrix

2007-11-19 Thread Moshe Olshansky
How about adding an artificial last row containing no 1's (say a row of zeros)? --- Marc Schwartz [EMAIL PROTECTED] wrote: On Thu, 2007-11-15 at 17:53 +0100, A M Lavezzi wrote: thank you. I did not think about the case of overlapping of 1's from the end of one column to the start of

Re: [R] counting strings of identical values in a matrix

2007-11-16 Thread A M Lavezzi
Marc and Gabor thank you so much. Also for making me realize how litte I know about R's potential best, Mario ps I actually thought about appending that row of zeros while waking up this morning.. At 18.35 15/11/2007, Gabor Grothendieck wrote: We can append a row of 0's to handle that case:

[R] counting strings of identical values in a matrix

2007-11-15 Thread A M Lavezzi
Hello I have this problem. I have a large matrix of this sort: prova [,1] [,2] [,3] [,4] [1,]3333 [2,]3331 [3,]1333 [4,]1113 [5,]3113 [6,]3113 [7,]1313 [8,]1333

Re: [R] counting strings of identical values in a matrix

2007-11-15 Thread Marc Schwartz
On Thu, 2007-11-15 at 15:51 +0100, A M Lavezzi wrote: Hello I have this problem. I have a large matrix of this sort: prova [,1] [,2] [,3] [,4] [1,]3333 [2,]3331 [3,]1333 [4,]1113 [5,]3113 [6,]

Re: [R] counting strings of identical values in a matrix

2007-11-15 Thread A M Lavezzi
Dear Marc thank you so much! One thing: writing xx=[1,2,1,1] is not a typo: I read it as the count of runs of different length starting from 1. In prova I have 1 run of length one, 2 runs of length two, 1 run of length three and 1 run of length four. Can I abuse of your time and ask how to

Re: [R] counting strings of identical values in a matrix

2007-11-15 Thread Marc Schwartz
Thanks Gabor. Nice solution. Marc On Thu, 2007-11-15 at 12:35 -0500, Gabor Grothendieck wrote: We can append a row of 0's to handle that case: with(rle(as.vector(rbind(prova, 0))), table(lengths[values == 1])) On Nov 15, 2007 11:36 AM, Marc Schwartz [EMAIL PROTECTED] wrote: Ah...OK.

Re: [R] counting strings of identical values in a matrix

2007-11-15 Thread Marc Schwartz
On Thu, 2007-11-15 at 17:53 +0100, A M Lavezzi wrote: thank you. I did not think about the case of overlapping of 1's from the end of one column to the start of the next, this would actually be a problem In the simulations I am running each column corresponds to the path followed by an

Re: [R] counting strings of identical values in a matrix

2007-11-15 Thread Marc Schwartz
Ah...OK. I misunderstood then. I thought that you wanted the number of runs of 1's in each column. This is actually easier, _if_ there is not an overlap of 1's from the end of one column to the start of the next column: res - rle(as.vector(prova)) res Run Length Encoding lengths: int [1:11]

Re: [R] counting strings of identical values in a matrix

2007-11-15 Thread Gabor Grothendieck
We can append a row of 0's to handle that case: with(rle(as.vector(rbind(prova, 0))), table(lengths[values == 1])) On Nov 15, 2007 11:36 AM, Marc Schwartz [EMAIL PROTECTED] wrote: Ah...OK. I misunderstood then. I thought that you wanted the number of runs of 1's in each column. This is

[R] counting with factors

2007-11-02 Thread Bernd Jagla
Hi there, I have something that appears to be a factor called drug: Typeof(drug) = Integer As.numeric(drug) gives a long list Levels(drug) gives a long list, too. Now I want something like the summary function does: I want to count how often each level occurs in the given vector. My

Re: [R] counting with factors

2007-11-02 Thread Marc Schwartz
On Fri, 2007-11-02 at 12:01 -0400, Bernd Jagla wrote: Hi there, I have something that appears to be a factor called drug: Typeof(drug) = Integer This is because the underlying data type of a factor is an integer. As.numeric(drug) gives a long list This gives you the integer storage code

<    1   2   3   4   5