I've completed an experiment and want to summarize the results.
There are two things I like to create.
1) A simple count of things from the data.frame with predictions
1a) Number of predictions with probability greater than x
1b) Number of predictions with probability greater than x that
hi,
I have some session data in a dataframe, where each session is recorded with a
start and a stop date. Like this:
session_start session_stop
===
2009-01-03 2009-01-04
2009-01-01 2009-01-05
2009-01-02 2009-01-09
A session is at least one day long. Now I want
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
Hello,
I have the following problem.
I am running simulations on possible states of a set of agents
(1=employed, 0=unemployed).
I store these simulated time series in a matrix like the following,
where rows indicates time periods, columns the number of agents (4
agents and 8 periods in this
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 p
Try this using built in data frame iris:
> length(subset(iris, Sepal.Length >= 7, Sepal.Width)[[1]])
[1] 13
> length(subset(iris, Sepal.Length >= 7 & Species == 'virginica',
> Sepal.Width)[[1]])
[1] 12
> # or the following (note that dot in Sepal.Length is automatically
> # converted to _ becaus
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Noah Silverman
> Sent: Tuesday, August 04, 2009 8:40 PM
> To: r help
> Subject: [R] Counting things
>
> I've completed an experiment and
Hi all,
I've a vector with entries, which are all of the same type, e.g. string:
k <- c("bb", "bb", "bb", "aa", "cc", "cc")
and want to create a second vector containing the number of each entry
in k in the same order as in k, i.e.
c(3, 1, 2)
or:
k <- c(5,5,5,5,2,2,4)
=> c(4,2,1)
thanks
Try this:
> dateseq <- function(i) seq(DF[i, 1], DF[i, 2], 1)
> table(as.Date(unlist(lapply(1:nrow(DF), dateseq)), origin = "1970-01-01"))
2009-01-01 2009-01-02 2009-01-03 2009-01-04 2009-01-05 2009-01-06 2009-01-07
1 2 3 3 2 1 1
2009
On Mon, Feb 9, 2009 at 4:57 PM, wrote:
>
> hi,
>
> I have some session data in a dataframe, where each session is recorded with
> a start and a stop date. Like this:
>
> session_start session_stop
> ===
> 2009-01-03 2009-01-04
> 2009-01-01 2009-01-05
> 2009-01-02
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 developm
it is pretty enough for me. Thanks
- Original Message
From: Martin Morgan <[EMAIL PROTECTED]>
To: joseph <[EMAIL PROTECTED]>
Cc: r-help@r-project.org
Sent: Friday, February 22, 2008 6:41:41 PM
Subject: Re: [R] counting sequence mismatches
One
kind
of
ugly
soluti
it's not totally clear to me what exactly do you need in this case, but
have a look at the following:
Atr <- cbind(rep(1:0, each = 4), 1, c(1, rep(0, 7)), 1)
unSpells <- colSums(Atr == 0)
unSpells[unSpells == 0] <- 1
unSpells
I hope it helps.
Best,
Dimitris
Mario Lavezzi wrote:
Hello,
I ha
Try this:
unSpells[tail(Atr,1)==0] <-
apply(Atr,2,function(x)sum(x==0))[tail(Atr,1)==0]
Or (if you don't have to preserve the value in the unSpells vector):
unSpells <- apply(Atr,2,function(x)sum(x==0))
But in this case you have 0 instead of 1 in the second and fourth position.
Ciao,
domenico
Hi Dimitris, thank you very much.
Actually, I have not specified the following: i want to consider only
the "most recent" sequence of zeros, that is the last part of the time
series.
That is, If I have:
[,1] [,2] [,3] [,4]
[1,]0101
[2,]1111
[3,]11
then try the following:
Atr <- cbind(rep(1:0, each = 4), 1, c(1, rep(0, 7)), 1)
Atr <- rbind(c(0, 1, 0, 1), Atr)
apply(Atr, 2, function (x) {
rr <- rle(x)
if (tail(rr$values, 1) == 0) tail(rr$length, 1) else 0
})
I hope this what you're looking for.
Best,
Dimitris
Mario Lavezzi wrote
> >> It works, but the for (i in ...) loop slows down the simulation a
lot.
> >>
> >> Any suggestion on how to avoid this loop? (or in general, to speed up
> >> this part of the simulation)
> Actually, I have not specified the following: i want to consider only
> the "most recent" sequence of
Hi Mario --
This function
f <- function(m) {
## next 2 lines due to Bill Dunlap
## http://tolstoy.newcastle.edu.au/R/e4/devel/08/04/1206.html
csum <- cumsum(!m)
crun <- csum - cummax(m * csum)
matrix(ifelse(crun > 0, (crun-1) %% nrow(m) + 1, 0),
nrow=nrow(m))
}
ret
Dear Richard, Martin, Dimitris and Domenico
thank you very much for your help.
I must say that the fastest procedure appears to be the one suggested by
Richard
This runs pretty quickly:
unSpells <- nrow(Atr) - apply(Atr,2,function(x) max(which(x==1)))
#c(4,0,7,0)
If I may abuse of your kin
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
try this:
k <- c("bb", "bb", "bb", "aa", "cc", "cc")
f <- factor(k, levels = unique(k))
as.vector(table(f))
you can put it in one line but it's less readable. I hope it helps.
Best,
Dimitris
axionator wrote:
Hi all,
I've a vector with entries, which are all of the same type, e.g. string:
k
Its not clear whether c("bb", "bb", "aa", "aa", "bb") can occur
or if it can how it should be handled but this gives the lengths
of each run and so would give c(2, 2, 1) in that case (as opposed
to c(3, 2)):
rle(k)$lengths
On Wed, Feb 4, 2009 at 10:19 AM, axionator wrote:
> Hi all,
> I've a vect
axionator gmail.com> writes:
> I've a vector with entries, which are all of the same type, e.g. string:
> k <- c("bb", "bb", "bb", "aa", "cc", "cc")
> and want to create a second vector containing the number of each entry
> in k in the same order as in k, i.e.
> c(3, 1, 2)
table(k)
Ben Bolk
Take a look at the run-length encoding function rle. I believe
rle(k)$lengths gives you exactly what you want.
-s
On Wed, Feb 4, 2009 at 10:19 AM, axionator wrote:
> Hi all,
> I've a vector with entries, which are all of the same type, e.g. string:
> k <- c("bb", "bb", "bb", "aa", "
Try:
table(k)[rank(unique(k))]
-ian
Armin Meier wrote:
>
> Hi all,
> I've a vector with entries, which are all of the same type, e.g. string:
> k <- c("bb", "bb", "bb", "aa", "cc", "cc")
> and want to create a second vector containing the number of each entry
> in k in the same order as in k,
Try:
table(k)
On Wed, Feb 4, 2009 at 1:19 PM, axionator wrote:
> Hi all,
> I've a vector with entries, which are all of the same type, e.g. string:
> k <- c("bb", "bb", "bb", "aa", "cc", "cc")
> and want to create a second vector containing the number of each entry
> in k in the same order as i
rle(k)$lengths is perfectly suitable for my purposes.
__
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-cont
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
Dear List,
I have a data set stored in the following format:
> head(dat, n = 10)
id sppcode abundance
1 10307 1000 1
2 10307 16220602 2
3 10307 2000 5
4 10307 2011 2
5 10307 2400 1
6 10307 402183
7 10307 40210102
Dear All,
I have a query : what is the command to count number of repeated words in a
column.
for ex:
a =
oranges
oranges
apples
apples
grape
oranges
apple
pine
the result should be
oranges 3
apples 3
grape 1
pine 1
is there an easy way for this.
Thanks,
Nataraju
GM R & D
Bangalore
--
"
Any better solution than this ?
sum(strsplit("TCGACAATCGGTAACCCGTCT", "")[[1]] == "G")
_
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://s
Hi R-Users,
I have a data frame containing year, month, day, and code columns. The
code column is a unique character of set ('E','A','B') - I am trying to
determine an efficient way of summarizing the count of each of these
codes by month and year without having to use for...loops and subsets.
Do
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 3
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 li
id)
> Sent: Wednesday, February 06, 2008 9:08 AM
> To: r-help@r-project.org
> Subject: [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
gt; matrix(c(dat$x, dat$y), ncol=2) mat[gg] <- dat$Freq
>
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Waterman, DG
> > (David)
> > Sent: Wednesday, February 06, 2008 9:08 AM
> > To: r-help@r-projec
On Feb 6, 2008 8:08 AM, Waterman, DG (David)
<[EMAIL PROTECTED]> 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
115 81
7 103 125
8 76 54
9 114 117
10 96 18
...and so on for many rows.
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 repetit
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
Hi,
Is there a function which counts the frequencies of the occurence of a
number within an interval?
for example I have this vector:
x <- c(1, 3, 1.2, 5, 5.9)
and I want a vector that gives me the frequencies within an interval
of 2, beginning at 0
(so the intervals are 0-2, 2-4, 4-6 a
Apologies, Jim Holtman has pointed out a couple of problems/queries with
my original email that I would like to make clear.
Firstly, I introduced a typo when trying to be helpful. In my email
below, I had incorrectly typed out one of the species codes I would
count:
1000
16220602
2011
240
To answer my own post, and for the archives (hopefully not that anyone
has to repeat what I had to do ;-), after much hair-pulling , frowning
at the screen and general dumb headedness the following slab of R code
achieves the results I wanted. It isn't elegant but does a job.
msr <- function(x) {
?table
On Thu, Feb 19, 2009 at 11:48 AM, Nattu wrote:
> Dear All,
>
> I have a query : what is the command to count number of repeated words in a
> column.
>
> for ex:
>
> a =
>
> oranges
> oranges
> apples
> apples
> grape
> oranges
> apple
> pine
>
>
> the result should be
> oranges 3
> apples
Try:
a<-c("o","o","a","a","g","o","a","p")
table(a)
a
a g o p
3 1 3 1
Clint BowmanINTERNET: cl...@ecy.wa.gov
Air Dispersion Modeler INTERNET: cl...@math.utah.edu
Air Quality Program VOICE: (360) 407-6815
Department of Ecology
#I have a dataset with two factor. I want to combine those factors into
a single factor and count the number of data values for each new factor.
The following gives a comparable dataframe:
a <- rep(c("a", "b"), c(6,6))
b <- rep(c("c", "d"), c(6,6))
df <- data.frame(f1=a, f2=b, d=rnorm(12))
df
Daren Tan hotmail.com> writes:
> Any better solution than this ?
> sum(strsplit("TCGACAATCGGTAACCCGTCT", "")[[1]] == "G")
Try
table(strsplit("TCGACAATCGGTAACCCGTCT", ""))
A C G T
5 7 8 5
and get all 4 at once.
HTH
--
Ken Knoblauch
Inserm U846
Institut Cellule Souche et Cerveau
D
Seems like you can do:
library("matchprobes") # on Bioconductor
countbases("TCGACAATCGGTAACCCGTCT")[,"G"]
The catch is that it only counts A, C, G, and T:s and no other symbols.
/Henrik
On Tue, Jul 15, 2008 at 8:27 AM, Daren Tan <[EMAIL PROTECTED]> wrote:
>
> Any better solution than this
Hi,
And the Bioconductor package "Biostrings" is the place to go for any
serious work with sequences.
--
Best wishes
Wolfgang
--
Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber
15/07/2008 16:43 Henrik Bengtsson
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 - +
: Tuesday, July 15, 2008 11:28 AM
To: [EMAIL PROTECTED]
Subject: [R] counting number of "G" in "TCGACAATCGGTAACCCGTCT"
Any better solution than this ?
sum(strsplit("TCGACAATCGGTAACCCGTCT", "")[[1]] == "G")
___
Try this:
with(DF, tapply(code, list(year, month, code), length))
On Tue, Sep 23, 2008 at 8:10 PM, Hutchinson,David [PYR]
<[EMAIL PROTECTED]> wrote:
> Hi R-Users,
>
> I have a data frame containing year, month, day, and code columns. The
> code column is a unique character of set ('E','A','B') -
See
?ftable
?as.data.frame
?xtabs
e.g.
ftable( xtabs( ~code+year+month, your.df ), col.vars=1 )
as.data.frame( xtabs(~code+year+month, your.df ) )
HTH,
Chuck
On Tue, 23 Sep 2008, Hutchinson,David [PYR] wrote:
Hi R-Users,
I have a data frame contai
Thanks Charles, ftable() works perfectly.
-Original Message-
From: Charles C. Berry [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 23, 2008 5:06 PM
To: Hutchinson,David [PYR]
Cc: r-help@r-project.org
Subject: Re: [R] Counting character occurrences in data frame
See
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
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
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 Sat,
>--- [EMAIL PROTECTED] wrote:
> >
> >> >From: Felipe Carrillo <[EMAIL PROTECTED]>
> >> >Date: 2008/03/22 Sat PM 06:16:59 CDT
> >> >To: [EMAIL PROTECTED]
> >> >Subject: [R] counting values on one colum only
> >>
> >&
2008/10/16 Jörg Groß <[EMAIL PROTECTED]>:
> Hi,
>
>
> Is there a function which counts the frequencies of the occurence of a
> number within an interval?
>
> for example I have this vector:
>
> x <- c(1, 3, 1.2, 5, 5.9)
>
> and I want a vector that gives me the frequencies within an interval of 2,
, October 16, 2008 10:47 AM
> To: r-help@r-project.org
> Subject: [R] counting the frequencies of a vector
>
> Hi,
>
>
> Is there a function which counts the frequencies of the occurence of a
> number within an interval?
>
> for example I have this vector:
>
> x <
Dear Jörg,
See ?cut and ?table. Is this what you want?
x <- c(1, 3, 1.2, 5, 5.9)
table(cut(x,breaks=c(0,2,4,6)))
(0,2] (2,4] (4,6]
2 1 2
HTH,
Jorge
On Thu, Oct 16, 2008 at 12:46 PM, Jörg Groß <[EMAIL PROTECTED]> wrote:
> Hi,
>
>
> Is there a function which counts the frequencies o
On Oct 16, 2008, at 12:55 PM, Jorge Ivan Velez wrote:
Dear Jörg,
See ?cut and ?table. Is this what you want?
x <- c(1, 3, 1.2, 5, 5.9)
table(cut(x,breaks=c(0,2,4,6)))
(0,2] (2,4] (4,6]
2 1 2
Perhaps even greater future efficiency could be had by also adding
?seq
table(cut(x, bre
Hello list.
I am hoping for some help with a relatively simple problem. I have a data frame
arranged as below. I want to be able to count the occurrence of each gene (eg
let-7e) by Experiment. In other words how many times does a given gene crop up
in the dataframe. I tried table but couldn't
Dear List,
I'm an [R] novice starting analysis of an ecological dataset containing the
basal areas of different tree species in a number of research plots.
Example data follow:
> Trees<-data.frame(SppID=as.factor(c(rep('QUEELL',2), rep('QUEALB',3),
'CORAME', 'ACENEG', 'TILAME')), BA=c(907.9, 1104
Hi,
I'm sure there's an easy approach to this issue, I'm just not seeing it.
I have a data frame of the following form:
Date classsubclass count
8/1/2009AX 1
8/1/2009BX 2
8/1/2009AY 9
8/1/2009BY 3
8/2
Sam,
Depending on what your ultimate aim is, perhaps you just want to add
the 'drop=TRUE' argument to your interaction call.
Peter
Sam Player wrote:
#I have a dataset with two factor. I want to combine those factors into
a single factor and count the number of data values for each new factor.
On Sep 19, 2009, at 5:39 AM, Sam Player wrote:
#I have a dataset with two factor. I want to combine those factors
into a single factor and count the number of data values for each
new factor. The following gives a comparable dataframe:
a <- rep(c("a", "b"), c(6,6))
b <- rep(c("c", "d"), c(
> -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 wee
Hi All,
I have a column that contains values between 0 and 1. I would like to make
a table that consists of the number of elements in each category.
For example , how many elements have values between 0 and 0.1, 0.1 to 0.2,
0.2 to 0.3,etc……..0.9 to 1.
Is there an easy way to do this?
Thanks
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
Try this:
Lines <- "Tanaka Mitchell Wang Hunter Chen Chim
miR-191* let-7e let-7b miR-126let-7a let-7g
miR-198let-7f let-7c miR-146a let-7b let-7i
miR-22 let-7g miR-1224 miR-16 let-7d miR-130b
miR-223let-7i miR-124
On Sat, 23 May 2009 12:44:19 + (GMT) Iain Gallagher
wrote:
IG> I am hoping for some help with a relatively simple problem. I have
IG> a data frame arranged as below. I want to be able to count the
IG> occurrence of each gene (eg let-7e) by Experiment. In other words
IG> how many times does a
This is probably what you want; you need to count the number of unique
instances:
> tapply(Trees$SppID, Trees$PlotID, function(x) length(unique(x)))
BU3F10 BU3F11 BU3F12
1 2 4
>
On Wed, Jul 29, 2009 at 12:57 PM, Ian Chidister wrote:
> Dear List,
>
> I'm an [R] novice starting anal
oun...@r-project.org] Im
Auftrag von Ian Chidister
Gesendet: Wednesday, July 29, 2009 12:57 PM
An: r-help@r-project.org
Betreff: [R] - counting factor occurrences within a group: tapply()
Dear List,
I'm an [R] novice starting analysis of an ecological dataset containing the
basal areas of di
Hi All-
Thanks for your quick responses. I was looking for unique instances, so
Jim's and Daniel's suggestions got the job done. Using "length" alone
didn't discriminate between multiple occurrences of the same species and
multiple species.
I do have one followup question- my full data set (not
One way is to exclude the NAs from consideration by creating a new
object without NAs in that column:
newTrees <- Trees[!is.na(Trees$SppID),]
tapply(newTrees$SppID, newTrees$PlotID, function(x) length(unique(x)))
On Wed, Jul 29, 2009 at 2:13 PM, Ian Chidister wrote:
> Hi All-
>
> Thanks for your
Or even easier:
tapply(Trees$SppID, Trees$PlotID, function(x) length(unique(na.omit(x
On Wed, Jul 29, 2009 at 2:13 PM, Ian Chidister wrote:
> Hi All-
>
> Thanks for your quick responses. I was looking for unique instances, so
> Jim's and Daniel's suggestions got the job done. Using "length
Jim-
That did the trick- thanks so much for taking the time to help me out.
Sincerely,
Ian Chidister
On Wed, Jul 29, 2009 at 11:57 AM, Ian Chidister wrote:
> Dear List,
>
> I'm an [R] novice starting analysis of an ecological dataset containing the
> basal areas of different tree species in a
Try this:
with(d, tapply(count, list(Date, class), sum))
On Wed, Aug 26, 2009 at 10:07 AM, Shaun Grannis wrote:
> Hi,
>
> I'm sure there's an easy approach to this issue, I'm just not seeing it.
>
> I have a data frame of the following form:
>
> Date classsubclass count
> 8/1/2009
Wow.
That was fast -- and spot on!
Thanks so much.
Best Regards,
Shaun
On Aug 26, 2009, at 9:11 AM, Henrique Dallazuanna wrote:
> Try this:
>
> with(d, tapply(count, list(Date, class), sum))
>
> On Wed, Aug 26, 2009 at 10:07 AM, Shaun Grannis > wrote:
> Hi,
>
> I'm sure there's an easy appr
e combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey
-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Shaun Grannis
Verzonden: w
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
Moshe,
Gabor posted that same solution shortly after my reply on Thursday.
I had one of those "head banging" episodes shortly thereafter... :-)
Regards,
Marc
On Mon, 2007-11-19 at 17:46 -0800, Moshe Olshansky wrote:
> How about adding an artificial last row containing no
> 1's (say a row of z
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 wa
On Nov 18, 2008, at 12:50 AM, kayj wrote:
Hi All,
I have a column that contains values between 0 and 1. I would like
to make
a table that consists of the number of elements in each category.
For example , how many elements have values between 0 and 0.1, 0.1
to 0.2,
0.2 to 0.3,etc……..0
Dear kayj,
Here is one way:
# Data
set.seed(123)
x=runif(100)
# Cuts
as.data.frame.table(table(cut(x,seq(0,1,by=0.1
#Var1 Freq
#1(0,0.1]7
#2 (0.1,0.2] 12
#3 (0.2,0.3] 11
#4 (0.3,0.4]9
#5 (0.4,0.5] 14
#6 (0.5,0.6]7
#7 (0.6,0.7] 11
#8 (0.7,0.8] 11
#9 (0.8,0.9]
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,]311
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
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 agent
across states of a stochastic process,
so I would like t
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:
>
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
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 i
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 dear R-users,
today I have a question that I completely do not know how to solve (R-newbie!).
In a temperature chamber I have measured temperature over time. The result is
shown in the attached eps-file (if attachments are shown): There are two
temperature levels, 150°C and -40°C. A comple
I have a long dataframe ("pollution") that contains a column of hourly
date information ("date") and a column of pollution measurements ("pol")
I have been happily calculating daily means and daily maximums using the
aggregate function
DMEANpollution = aggregate(pollution["pol"],
format(
?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
You can count the number of times the values make a transition through
some threshold and average over some short time period because you
probably get multiple transitions in a short time as it is approaching
the threshold. Once you have that, you can count then number of times
it happens.
On Mon
?
Can a cycle be 30 minutes of lower temperature followed by 30 minutes of upper
temperature?
--- On Mon, 6/7/09, Steller, Antje (GQL-LM) wrote:
> From: Steller, Antje (GQL-LM)
> Subject: [R] Counting the number of cycles in a temperature test
> To: r-help@r-project.org
> Received: Mo
cycle?
Can a cycle be 30 minutes of lower temperature followed by 30 minutes of upper
temperature?
--- On Mon, 6/7/09, Steller, Antje (GQL-LM) wrote:
From: Steller, Antje (GQL-LM)
Subject: [R] Counting the number of cycles in a temperature test
To: r-help@r-project.org
Received: Monday, 6 July, 20
Try
tempFun <- function(x) sum(!is.na(x))
nonZeros <- aggregate(pollution["pol"],format(pollution["date"],"%Y-%j"), FUN
= tempFun)
--- On Wed, 12/8/09, Tim Chatterton wrote:
> From: Tim Chatterton
> Subject: [R] Counting the number of non-NA
100 matches
Mail list logo