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
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
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
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
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
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
?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
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,
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
.
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
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
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
: [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
=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
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
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
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
-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
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
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:
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
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,]
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
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.
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
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]
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
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
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
401 - 429 of 429 matches
Mail list logo