HI Jim,
This is great!! It is also tricky!!! The problem lies in the choice of
ylim. And looking at the data and choosing ylim based on the maximum and
minimum values of y is a waste of time. And choosing it by other means was
yet much more difficult.
I had to start plotting part of the data
Hi Ogbos,
The problem is almost certainly with the data. I get the plot I expect
with the sample data that you first posted, so I know that the code
works. If you try thIs what do you get?
oodf<-read.table(text="S/N AB
1-5 64833
2-4 95864
3-3 82322
4-2 95591
5
Hi Jim
Thanks again for returning to this.
please not that the line "oomean<-as.vector(by(oodf$B,oodf$A,mean))" was
omitted (not sure whether deliberate) after you introduced the standard
error function.
When I used it, empty plot window with the correct axes were generated but
no data was
Hi Ogbos,
If I use the example data that you sent, I get the error after this line:
oose<-as.vector(by(oodf$B,oodf$A,std.error))
Error in FUN(X[[i]], ...) : object 'std.error' not found
The reason is that you have not defined std.error as a function, but
as the result of a calculation. When I
Hi Ogbos,
This may help:
# assume your data frame is named "oodf"
oomean<-as.vector(by(oodf$B,oodf$A,mean))
oose<-as.vector(by(oodf$B,oodf$A,std.error))
plot(-5:10,oomean,type="b",ylim=c(5,11),
xlab="days (epoch is the day of Fd)",ylab="strikes/km2/day")
dispersion(-5:10,oomean,oose)
Dear workers,
I have a data of length 1136. Below is the code I use to get the means B.
It worked fine and I had the mean calculated and plotted.
I wish to plot the error bars as well. I already plotted such means with
error bars before. Please see attached for example.
I tried to redo the same
Hi.
I'm trying to calculate the weighted mean score of a quality of life
measure (ovt) in patients with irritable bowel syndrome by their
marital status (d7).
This is a summary of the structure of the dataset:
str(sii.tesis)
'data.frame':1063 obs. of 75 variables:
$ id : int 51
try resetting your levels? if that doesn't work, please dput() an example
data set that we can test with :) thanks!
sii.design - update( sii.design , d6 = factor( d6 ) )
On Wed, Nov 12, 2014 at 7:59 AM, Martin Canon martin.ca...@gmail.com
wrote:
Hi.
I'm trying to calculate the
hi martin, sending the first 25 rows does not help if it does not re-create
the problem.. when i run the data you have provided, i do not encounter
your problem (see below). someone else may be able to guess the issue, but
this would be a lot easier to solve if you can create a minimal
Anthony, thanks for your reply.
Resetting the levels didn't work.
These are the first 25 rows of the dataset:
structure(list(id = c(51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L,
59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L,
73L, 74L, 75L, 76L), stratum = structure(c(1L, 4L, NA, 4L,
Hello,
How i can use a costum function in tapply which has more than one variable?
I mean sum(x) only needs one object but what when i have a function
function(x,y) with more, how i indicate where are the other variables
to use?7
I hope someone can help me. Thank you!!
Best regards,
Dominic
On Jan 22, 2013, at 2:24 PM, Dominic Roye wrote:
Hello,
How i can use a costum function in tapply which has more than one variable?
I mean sum(x) only needs one object but what when i have a function
function(x,y) with more, how i indicate where are the other variables
to use?7
You can
Dear R users,
imagine i have a dataframe and an indexing vector with the length of the
amount of columns of the dataframe. Is there any convenient way to
combine the colums of the dataframe into vectors (or straight away apply
fundtions to these subsets) according to the indexing vector in a
Hello,
Here's a way.
test - as.data.frame(matrix(1:20, ncol = 5, nrow=4))
test.ind - c(1,1,2,2,2)
lapply(split(colnames(test), test.ind), function(x) unlist(test[, x]))
Hope this helps,
Rui Barradas
Em 04-09-2012 15:40, Jannis escreveu:
Dear R users,
imagine i have a dataframe and an
: Re: [R] tapply to data.frame or matrix
Hello,
Here's a way.
test - as.data.frame(matrix(1:20, ncol = 5, nrow=4))
test.ind - c(1,1,2,2,2)
lapply(split(colnames(test), test.ind), function(x) unlist(test[, x]))
Hope this helps,
Rui Barradas
Em 04-09-2012 15:40, Jannis escreveu:
Dear R users
Actually its okay.
I just created 16 subsets of the dataframe using the different months and
then ran kruskal test 16 times.
Im sure there is a nice way to code this to do it automatically and produce
a nice table of the results but i only started learning R two weeks ago!!!
Thanks for all the
Hello
Thankyou for the help.
kruskal.test(Temp, Roof) is simple but just returns one result for the
whole temperature dataset organised by roof.
I want to compare the Temp data for each Roof in each Month. So because i
have temperature data on the three roofs for 16 different months then i
On Aug 30, 2012, at 4:02 AM, andyspeak wrote:
Hello
Thankyou for the help.
kruskal.test(Temp, Roof) is simple but just returns one result for
the
whole temperature dataset organised by roof.
I want to compare the Temp data for each Roof in each Month. So
because i
have temperature
Hello
I have a huge data frame with three columns 'Roof' 'Month' and 'Temp'
i want to run analyses on the numerical Temp data by the factors Roof and
Month, separately and together.
For using more than one factor i understand i should use aggregate, but i am
struggling with the tapply for single
Le mercredi 29 août 2012 à 07:37 -0700, andyspeak a écrit :
Hello
I have a huge data frame with three columns 'Roof' 'Month' and 'Temp'
i want to run analyses on the numerical Temp data by the factors Roof and
Month, separately and together.
For using more than one factor i understand i
On Aug 29, 2012, at 7:37 AM, andyspeak wrote:
Hello
I have a huge data frame with three columns 'Roof' 'Month' and 'Temp'
i want to run analyses on the numerical Temp data by the factors
Roof and
Month, separately and together.
For using more than one factor i understand i should use
On Thu, Feb 23, 2012 at 11:39 AM, Matthew Keller mckellerc...@gmail.com wrote:
Thank you all very much for your help (on both the r-help and the
bioconductor listserves).
Benilton - I couldn't get sqldf to install on the server I'm using
(error is: Error : package 'gsubfn' does not have a
Thank you all very much for your help (on both the r-help and the
bioconductor listserves).
Benilton - I couldn't get sqldf to install on the server I'm using
(error is: Error : package 'gsubfn' does not have a name space). I
think this was a problem for R 2.13, and I'm trying to get the admin's
On Tue, Feb 21, 2012 at 4:04 PM, Matthew Keller mckellerc...@gmail.com wrote:
X - read.big.matrix(file.loc.X,sep= ,type=double)
hap.indices - bigsplit(X,1:2) #this runs for too long to be useful on
these matrices
#I was then going to use foreach loop to sum across the splits
identified by
Hi all,
SETUP:
I have pairwise data on 22 chromosomes. Data matrix X for a given
chromosome looks like this:
1 13 58 1.12
6 142 56 1.11
18 307 64 3.13
22 320 58 0.72
Where column 1 is person ID 1, column 2 is person ID 2, column 3 can
be ignored, and column 4 is how much chromosomal sharing
All -
I have an example data frame
x l.c.1
43.38812035 085
47.55710661 085
47.55710661 085
51.99211429 085
51.99211429 095
54.78449958 095
54.78449958 095
56.70201864 095
56.70201864 105
59.66361903 105
61.69573564 105
61.69573564 105
-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of Steven Ranney
Sent: Friday, 25 March 2011 12:18 p.m.
To: r-help@r-project.org
Subject: [R] tapply with specific quantile value
All -
I have an example data frame
x l.c.1
43.38812035 085
47.55710661 085
47.55710661 085
Just have a look at ?quantile and the probs argument.
tapply(x, l.c.1, quantile,probs=0.75)
Anyway, quantiles and quartiles are not the same. I guess you meant the
3rd quartile.
All -
I have an example data frame
x l.c.1
43.38812035 085
47.55710661 085
47.55710661 085
Hi Steven,
See the prob argument under ?quantile. The following should be what you
want:
tapply(x, l.c.1, quantile, prob = 0.75)
HTH,
Jorge
*
*
On Thu, Mar 24, 2011 at 7:18 PM, Steven Ranney wrote:
All -
I have an example data frame
x l.c.1
43.38812035 085
47.55710661
-help-bounces@r-
project.org] On Behalf Of Steven Ranney
Sent: Friday, 25 March 2011 12:18 p.m.
To: r-help@r-project.org
Subject: [R] tapply with specific quantile value
All -
I have an example data frame
x l.c.1
43.38812035 085
47.55710661 085
47.55710661 085
51.99211429
On Mon, Apr 13, 2009 at 12:41 PM, Dan Dube ddube-at-advisen.com wrote:
i use tapply and by often, but i always end up banging my head against
the wall with the output.
The proposed solution of Dan's problem posted on R-help was:
do.call(rbind,a)
When I use this 'solution' I get 'ERROR:
Try
as.data.frame(as.table(a))
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
On Feb 3, 2011, at 11:29 AM, Graves, Gregory wrote:
On Mon, Apr 13, 2009 at 12:41 PM, Dan Dube ddube-at-advisen.com
wrote:
That is pushing two years ago, so I doubt very many people still have
that posting on their mail-clients. (When I did go to the archives Dan
Dube's problem was
Subject: Re: [R] tapply output as a dataframe
On Feb 3, 2011, at 11:29 AM, Graves, Gregory wrote:
My tapply output is generated as follows:
a=tapply(value,list(sampling.date,station.code),mean)
Why not give us sampling.date (which is probably NOT really a date but
rather a character vector
; Goodman, Patricia; Gorman, Patricia
Subject: Re: [R] tapply output as a dataframe
On Feb 3, 2011, at 11:29 AM, Graves, Gregory wrote:
My tapply output is generated as follows:
a=tapply(value,list(sampling.date,station.code),mean)
Why not give us sampling.date (which is probably NOT really
On Thu, Feb 3, 2011 at 1:11 PM, David Winsemius dwinsem...@comcast.net wrote:
On Feb 3, 2011, at 1:05 PM, Graves, Gregory wrote:
Yes, as far as I can tell, sampling.date is a character vector of the
format 1/15/2008. It resides in the leftmost column of the tapply output.
station.code are
-Original Message-
From: Phil Spector [mailto:spec...@stat.berkeley.edu]
Sent: Thursday, February 03, 2011 12:41 PM
To: Graves, Gregory
Cc: r-help@r-project.org; Goodman, Patricia; Gorman, Patricia
Subject: Re: [R] tapply output as a dataframe
Try
as.data.frame(as.table
On 2010-10-06 13:24, Erik Iverson wrote:
Hello,
You can use ddply from the very useful plyr package to do this.
There must be a way using base R functions, but plyr is
worth looking into in my opinion.
install.packages(plyr)
library(plyr)
ddply(myData, .(class, group, name),
You can also use sqldf:
require(sqldf)
sqldf(select class, `group`, name, avg(height)
+ from myData
+ group by class, 'group', name)
class group name avg(height)
1 0 B Jane58.5
2 0 A Tom62.5
3 1 A Enzo66.5
4 1 B Mary
Hello, I am having trouble getting the output from the tapply function
formatted so that it can be made into a nice table. Below is my question
written in R code. Does anyone have any suggestions? Thank you. Geoff
#Input the data;
name - c('Tom', 'Tom', 'Jane', 'Jane', 'Enzo', 'Enzo', 'Mary',
Try this:
aggregate(height ~ class + group + name, data = myData, FUN = mean)
On Wed, Oct 6, 2010 at 4:13 PM, Geoffrey Smith g...@asu.edu wrote:
Hello, I am having trouble getting the output from the tapply function
formatted so that it can be made into a nice table. Below is my question
Hello,
You can use ddply from the very useful plyr package to do this.
There must be a way using base R functions, but plyr is
worth looking into in my opinion.
install.packages(plyr)
library(plyr)
ddply(myData, .(class, group, name), function(x) mean(x$height))
class group name V1
1
Geoffrey -
The output you want is exactly what the aggregate() function
provides:
aggregate(myData$height, myData[c('class','group','name')],mean)
class group namex
1 1 A Enzo 66.5
2 0 B Jane 58.5
3 1 B Mary 70.5
4 0 A Tom 62.5
It should be mentioned
That was very clever. Worked perfectly, thanks!
And thanks to everyone else who provided feedback.
On Jun 5, 2010, at 5:46 AM, jim holtman wrote:
It this what you are looking for:
set.seed(1)
# create range for each possible class
# 'name' the values so you can use them in the 'sapply'
It this what you are looking for:
set.seed(1)
# create range for each possible class
# 'name' the values so you can use them in the 'sapply' function
lows-c(a=1, b=2, c=3, d=4, e=5)
highs-c(a=5, b=6, c=7, d=8, e=9)
# data values
vals-sample(1:10,100,replace=T)
#classes
Dear R gurus,
I am trying perform what I believe will be a pretty simple task, but I'm
struggling to figure out how to do it. I have two vectors of the same length,
the first is numeric and the second is factor. I understand that tapply is
perfect for applying a function to the numeric vector
See ?colSums
On Mon, May 10, 2010 at 12:44 AM, vincent.deluard
vincent.delu...@trimtabs.com wrote:
Hi R users,
I have a matrix m of the type:
m
X4.20.2010 X4.19.2010 X4.16.2010
[1,] 0.008319468 0. -0.008250825
[2,] 0.005574136 0.01816118 0.073081608
[3,] -0.047830688
Hi R users,
I have a matrix m of the type:
m
X4.20.2010 X4.19.2010 X4.16.2010
[1,] 0.008319468 0. -0.008250825
[2,] 0.005574136 0.01816118 0.073081608
[3,] -0.047830688 0.01612903 -0.030239833
[4,] NA NA NA
[5,] 0.008746356 0.02848576
It is exactly the same
tmp - matrix(1:24,6,4)
tmp[4,] - NA
tmp
apply(tmp, 2, sum, na.rm=TRUE)
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting
Hi
steven mosher mosherste...@gmail.com napsal dne 27.04.2010 17:04:04:
Thanks,
I had been wondering what Drop did. That makes it more clear.
While I have code that loops and does the problem correctly, I wanted to
do things the R way and be fast and terse. hehe.
So:
ID
Thanks dennis.
Is there a book on R u could recommend.
On Mon, Apr 26, 2010 at 7:12 PM, Dennis Murphy djmu...@gmail.com wrote:
Hi:
On Mon, Apr 26, 2010 at 8:01 AM, steven mosher
mosherste...@gmail.comwrote:
Thanks,
I was trying to stick with the base package and figure out
Hi
r-help-boun...@r-project.org napsal dne 26.04.2010 17:05:54:
I guess my problem was seeing a bunch of examples where they pulled a
variable from a dataframe..
tapply(df$data, index=list(..
df$data results in vector so as eg. df[,5] unless you use drop=FALSE
option
and I
assumed
Hi
If you are not satisfied with R intro docs which are distributed with R
installation you can consider Introductory statistics with R by P.Dalgaard
for beginners and mayby Modern applied statistics with S by W.N.Venables
and B.D.Ripley which is a bit outdated and applies maybe a little more
Thanks,
I had been wondering what Drop did. That makes it more clear.
While I have code that loops and does the problem correctly, I wanted to
do things the R way and be fast and terse. hehe.
So:
ID dy jan ...
11264402000 1 1987 NA NA NA NA NA 218
I've tried both mean and colMean.
I did success with one attempt using mean, however if only have 1 year and
its a NA
then I get NaN ( which I can replace). I'll keep trying.
On Mon, Apr 26, 2010 at 12:26 AM, Petr PIKAL petr.pi...@precheza.cz wrote:
Hi
r-help-boun...@r-project.org napsal
That fails:
The manual says:
tapply(X, INDEX, FUN = NULL, ..., simplify = TRUE)
ArgumentsXan atomic object, typically a vector.INDEXlist of factors, each of
same length as X. The elements are coerced to factors by
as.factorhttp://127.0.0.1:31214/library/base/help/as.factor
.
my error says:
Hi:
Use of ddply() in the plyr package appears to work.
library(plyr)
ddply(df[, -1], .(Year), colwise(mean), na.rm = TRUE)
D Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1 1.00 1980 NaN NaN NaN NaN NaN 212 203 209 228 237 NaN NaN
2 0.50 1981 NaN 251 243 246 241 NaN NaN
Hi
steven mosher mosherste...@gmail.com napsal dne 26.04.2010 10:21:37:
That fails:
The manual says:
tapply(X, INDEX, FUN = NULL, ..., simplify = TRUE)
Arguments
X
an atomic object, typically a vector.
INDEX
list of factors, each of same length as X. The elements are
Thanks,
I was trying to stick with the base package and figure out how the base
routines worked. I looked at plyer and it was very appealing. I guess i'll
give in and use it
On Mon, Apr 26, 2010 at 2:33 AM, Dennis Murphy djmu...@gmail.com wrote:
Hi:
Use of ddply() in the plyr package
I guess my problem was seeing a bunch of examples where they pulled a
variable from a dataframe..
tapply(df$data, index=list(..
and I
assumed that the df$data was just generalizable to a collection of vectors
a vector of vector being a vector
Thanks.
On Mon, Apr 26, 2010 at 2:43 AM, Petr
Hi:
On Mon, Apr 26, 2010 at 8:01 AM, steven mosher mosherste...@gmail.comwrote:
Thanks,
I was trying to stick with the base package and figure out how the base
routines worked.
If you want to use base functions, then here's a solution with aggregate:
(the Id column
was removed first):
Having some difficulties with understanding how tapply works and getting
return values I expect
Data: dataframe. DF DF$Id $D $Year...
Id D Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct
Nov Dec
11264402000 1 1980 NA NA NA NA NA 212 203 209 228 237 NA
What is the function set()? Is that a typo? When I type ?set I get
nothing, and when I try to evaluate that code R tells me it can't find the
function.
--
View this message in context:
http://n4.nabble.com/tapply-syntax-tp1692503p1694586.html
Sent from the R help mailing list archive at
On 29/03/2010, at 1:27 PM, Jeff Brown wrote:
What is the function set()? Is that a typo? When I type ?set I get
nothing, and when I try to evaluate that code R tells me it can't find the
function.
Yeah, it's a typo. (S)he meant ``subset''.
cheers,
Rolf Turner
The message tells you everything - there is no function 'set' in the
workspace you are using. Did you forget to load a library? What is the
context in which you are trying to use it?
On Sun, Mar 28, 2010 at 8:27 PM, Jeff Brown dopethatwantsc...@yahoo.comwrote:
What is the function set()? Is
sorry - I use many abbreviations and I try to remove them before I post
questions/answers - 'set' is my abb. for subset
david
On 3/28/2010 8:27 PM, Jeff Brown [via R] wrote:
What is the function set()? Is that a typo? When I type ?set I get
nothing, and when I try to evaluate that code R
Dear R-help members,
Apologies for the trouble.
I have a question :
Essentially, I have a dataset which stores genetic variations for individual
patients. Each individual patient can have more than one variation, and each
new record corresponds to a new variation (thus, both individual patients
Hi,
I figured a workaround to my problem, but if anyone has any advice on how to
express a function in tapply to achieve the same outcome, that would be
awesome and I'd learn something about functions!
The workaround was
tapply ((data$Variation.Type %in% c(2,3)), data$Patient, sum)
Thanks.
how about:
d1=data.frame(pat=c(rep('a',3),'b','c',rep('d',2),rep('e',2),'f'),var=c(1,2,3,1,2,2,3,2,4,4))
ds=set(d1,var %in% c(2,3))
with(ds,tapply(var,pat,FUN=length))
hth,
David Freedman, CDC, Atlanta
--
View this message in context:
http://n4.nabble.com/tapply-syntax-tp1692503p1692553.html
sjaffe wrote:
I'm sure I can put this together from the various 'apply's and split, but I
wonder if anyone has a quick incantation:
E.g. I can do tapply( data, groups, mean)
but how can I do something like: tapply( list(data,weights), groups,
weighted.mean ) ?
(or: mapply is to sapply as ?
On Feb 4, 2010, at 9:56 AM, J. R. M. Hosking wrote:
sjaffe wrote:
I'm sure I can put this together from the various 'apply's and
split, but I
wonder if anyone has a quick incantation:
E.g. I can do tapply( data, groups, mean)
but how can I do something like: tapply( list(data,weights),
Hi
r-help-boun...@r-project.org napsal dne 02.02.2010 22:16:06:
'fraid not :-((
tapply( data, groups, weighted.mean, weights)
tapply(seq(along=lll), rrr, function(i, x, w) weighted.mean(x[i], w[i]),
x=lll, w=ttt)
If you want to subset more than one thing, subset the index
Yes, this is clearly the key to working with subsets. Thanks
-Original Message-
From: Petr PIKAL [mailto:petr.pi...@precheza.cz]
Sent: Wednesday, February 03, 2010 4:16 AM
To: Steve Jaffe
Cc: r-help@r-project.org
Subject: Re: [R] tapply for function taking of 1 argument?
Hi
r-help-boun
also,
library(plyr)
ddply(d,~grp,function(df) weighted.mean(df$x,df$w))
--
View this message in context:
http://n4.nabble.com/tapply-for-function-taking-of-1-argument-tp1460392p1461428.html
Sent from the R help mailing list archive at Nabble.com.
On Wed, Feb 3, 2010 at 11:06 AM, David Freedman 3.14da...@gmail.com wrote:
also,
library(plyr)
ddply(d,~grp,function(df) weighted.mean(df$x,df$w))
Or
ddply(d, grp, summarise, mean = weighted.mean(x, w))
which is convenient if you want more than one output
Hadley
--
http://had.co.nz/
Also try this:
library(sqldf)
DF - data.frame(data = 1:10, groups = rep(1:2, 5), weights = 1)
sqldf(select groups, sum(data * weights)/sum(weights) 'wtd mean' from DF
group by groups)
groups wtd mean
1 15
2 26
On Tue, Feb 2, 2010 at 5:06 PM, sjaffe
Thanks, Iâm actually more comfortable with vector-ish syntax than sql-ish but
this is a good thing to keep in mind⦠I wonder how it compares in performance
versus âbyâ or âtapplyâ
From: Gabor Grothendieck [via R]
[mailto:ml-node+1461531-1948782...@n4.nabble.com]
Sent: Wednesday,
Of sjaffe
Sent: Wednesday, February 03, 2010 10:25 AM
To: r-help@r-project.org
Subject: Re: [R] tapply for function taking of 1 argument?
Thanks, Ibm actually more comfortable with vector-ish syntax than sql-ish
but this is a good thing to keep in mindb I wonder how it compares in
performance versus
It will of necessity be slower (because there's more machinery underlying
the sqldf package); but I doubt whether it would be noticeably slower than
the native R solution in most practical situations. The same would be true
for plyR's implementation (it relies on the proto package, which slows
I'm sure I can put this together from the various 'apply's and split, but I
wonder if anyone has a quick incantation:
E.g. I can do tapply( data, groups, mean)
but how can I do something like: tapply( list(data,weights), groups,
weighted.mean ) ?
(or: mapply is to sapply as ? is to tapply )
Hi sjaffem,
You were almost there:
tapply( yourdata, groups, weighted.mean, weights)
See ?tapply for more information.
HTH,
Jorge
On Tue, Feb 2, 2010 at 3:58 PM, sjaffe wrote:
I'm sure I can put this together from the various 'apply's and split, but I
wonder if anyone has a quick
'fraid not :-((
tapply( data, groups, weighted.mean, weights)
won't work because the *entire* weights vector is passed as the 2nd arg to
weighted.means. But weighted.mean needs 'weights' to be split in the same
way as 'data' -- the first and 2nd args need to correspond.
Jorge Ivan Velez
?by
Bert Gunter
Genentech Nonclinical Statistics
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of sjaffe
Sent: Tuesday, February 02, 2010 1:16 PM
To: r-help@r-project.org
Subject: Re: [R] tapply for function taking of 1 argument
On Tue, 2 Feb 2010, sjaffe wrote:
'fraid not :-((
tapply( data, groups, weighted.mean, weights)
won't work because the *entire* weights vector is passed as the 2nd arg to
weighted.means. But weighted.mean needs 'weights' to be split in the same
way as 'data' -- the first and 2nd args need to
Excellent! I knew there would be a clever answer using 'do.call' :-)
-Original Message-
From: Charles C. Berry [mailto:cbe...@tajo.ucsd.edu]
Sent: Tuesday, February 02, 2010 4:25 PM
To: Steve Jaffe
Cc: r-help@r-project.org
Subject: Re: [R] tapply for function taking of 1 argument
Thanks! :-)
I suppose it's obvious, but one will generally have to use a (anonymous)
function to 'unpack' the data.frame into columns, unless the function
already knows how to do this.
I mention this because when I tested the solution on my example I got an
unexpected result -- apparently
On Jan 28, 2010, at 10:26 AM, GL wrote:
Can you make tapply break down groups similar to bwplot or such?
Example:
Data frame has one measure (Days) and two Dimensions (MM and
Place). All
have the same length.
length(dbs.final$Days)
[1] 3306
length()
[1] 3306
length()
[1]
Thanks. My mistake was that I used c(dbs.final$Days,dbs.final$Place) instead of
list(... when I tried to follow that part of the documentation.
David Winsemius dwinsem...@comcast.net 1/28/2010 11:49 AM
On Jan 28, 2010, at 10:26 AM, GL wrote:
Can you make tapply break down groups similar
Dear R-users,
I am working with R version 2.10.1.
Say I have is a simple function like this:
my.fun - function(x, mult) mult*sum(x)
Now, I want to apply this function along with some other (say 'max') to a
simple data.frame, like:
dat - data.frame(x = 1:4, grp = c(a,a,b,b))
Ideally, the
Try replacing 'max' with 'mean' and see what you get.
Then have a look at ?max and see what max() does with
extra arguments.
I'm not sure it's relevant, but it might be useful
to check what Hmisc::summarize does.
-Peter Ehlers
RINNER Heinrich wrote:
Dear R-users,
I am working with R version
Hi:
Using the plyr package, we can get the result as follows:
library(plyr)
my.fun - function(x, mult) mult*sum(x)
dat - data.frame(x = 1:4, grp = c(a,a,b,b))
ddply(dat, .(grp), summarize, max = max(x), myfun = my.fun(x, 10))
grp max myfun
1 a 230
2 b 470
HTH,
Dennis
On
Hi Dennis,
now that's a very nice function, and this seems to be just what I need!
Thanks a lot!
-Heinrich.
Von: Dennis Murphy [djmu...@gmail.com]
Gesendet: Dienstag, 26. Januar 2010 19:44
An: RINNER Heinrich
Cc: r-help
Betreff: Re: [R] tapply and more than
Hi,
I tried to use tapply function to find the mean of the data in each group as
the following command, but the result are NA, as there are several missing
values in each group.
tapply(data,group,mean)
Could someone please advice me the way to ignore the missing data in order for
the
you must have missing values in data. Try
tapply(data, group, mean, na.rm = TRUE)
If that's not the case, read the bottom of this email about the posting guide.
HTH,
--sundar
On Tue, Nov 3, 2009 at 5:28 AM, FMH kagba2...@yahoo.com wrote:
Hi,
I tried to use tapply function to find the mean
Hi all,
I would like to invoke a function that takes multiple arguments (some of
which are specified columns in the data frame, and others that are
independent of the data frame) on split parts of a data frame, how do I do
this?
For example, let's say I have a data frame
fitness_data
name
I just realized my earlier post of my question below was not in
Plain Text mode, hence the repeat post...apologies!
Kavitha
On Thu, Oct 22, 2009 at 4:19 PM, Kavitha Venkatesan
kavitha.venkate...@gmail.com wrote:
Hi all,
I would like to invoke a function that takes multiple arguments (some of
for log2?
Alex
-Original Message-
From: William Dunlap [mailto:wdun...@tibco.com]
Sent: Thursday, October 15, 2009 11:59 PM
To: Alexander Peterhansl; r-help@r-project.org
Subject: RE: [R] tapply() and using factor() on a factor
-Original Message-
From: r-help-boun...@r-project.org
...@tibco.com]
Sent: Thursday, October 15, 2009 11:59 PM
To: Alexander Peterhansl; r-help@r-project.org
Subject: RE: [R] tapply() and using factor() on a factor
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Alexander
Peterhansl
Dear List,
Shouldn't result1 and result2 be equal in the following case?
Note that log$RequestID is a factor. That is, is.factor(log$RequestID)
yields TRUE.
result1 - tapply(log$Flag,factor(log$RequestID),sum)
result2 - tapply(log$Flag,log$RequestID,sum)
Yet, when I summarize the
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Alexander
Peterhansl
Sent: Thursday, October 15, 2009 2:50 PM
To: r-help@r-project.org
Subject: [R] tapply() and using factor() on a factor
Dear List,
Shouldn't
1 - 100 of 147 matches
Mail list logo