Hi R-users,
I have a data.frame like this (modificated from
https://stat.ethz.ch/pipermail/r-help/2007-August/138124.html).
y1 - rnorm(20) + 6.8
y2 - rnorm(20) + (1:20*1.7 + 1)
y3 - rnorm(20) + (1:20*6.7 + 3.7)
y - c(y1,y2,y3)
x - rep(1:5,12)
f - gl(3,20, labels=paste(lev, 1:3, sep=))
d -
Lauri Nikkinen wrote:
Hi R-users,
I have a data.frame like this (modificated from
https://stat.ethz.ch/pipermail/r-help/2007-August/138124.html).
y1 - rnorm(20) + 6.8
y2 - rnorm(20) + (1:20*1.7 + 1)
y3 - rnorm(20) + (1:20*6.7 + 3.7)
y - c(y1,y2,y3)
x - rep(1:5,12)
f - gl(3,20,
Thanks Chuck but I would fancy the output made by tapply because the idea is
to make a barplot based on those values.
-Lauri
2007/8/8, Chuck Cleland [EMAIL PROTECTED]:
Lauri Nikkinen wrote:
Hi R-users,
I have a data.frame like this (modificated from
Lauri Nikkinen wrote:
Thanks Chuck but I would fancy the output made by tapply because the
idea is to make a barplot based on those values.
-Lauri
sum1 - summary(y ~ x + f, data = d, fun=mean,
method=cross, overall=TRUE)
df - data.frame(x = sum1$x, f = sum1$f, y = sum1$S)
hello,
i want to compute the mean of a variable (aps) for every class
(1,2, and 3).
every id have a few obs., aps and class are constant over id.
like this:
id aps class
1 11 2
1 11 2
1 11 2
1 11 2
1 11 2
2 83
2 8
I do not understand what you want. If aps is constant
over each class then the mean for each class is equal
to any value of aps.
Using your example you can do
tapply(icu1$aps, icu1$d, mean)
but it does not give you anything new. Can you
explain the problem a bit more?
--- sigalit
I also don't understand, but perhaps:
with(df, tapply(aps, list(class, id), mean))
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O
On 19/07/07, sigalit mangut-leiba [EMAIL PROTECTED] wrote:
hello,
i want to compute the mean of a variable (aps) for every class
I'm sorry for the unfocused questions, i'm new here...
the output should be:
classaps_mean
1 na
2 11.5
3 8
the mean aps of every class, when every id count *once*, for example: class
2, mean= (11+12)/2=11.5
hope it's clearer.
sigalit.
sigalit mangut-leiba wrote:
I'm sorry for the unfocused questions, i'm new here...
the output should be:
classaps_mean
1 na
2 11.5
3 8
the mean aps of every class, when every id count *once*, for example: class
2, mean= (11+12)/2=11.5
hope it's
Hello, I want to conduct normality test to a series of data and get the
p-value for each subset. I am using the following codes, but it does not
work.
tapply(re, list(reg, ast), pvalue(shapiro.test))
Could anyone give me some advice? Many thanks.
--
View this message in context:
I'm not sure what is the 'pvalue' function (it's not found in base nor
stats packages) but
this should give you what you want:
# some example
re - rnorm(100)
reg - rep(1:3, length=100)
ast - rep(1:2, length=100)
tapply( re, list(reg, ast), function(v) shapiro.test(v)$p.value )
# or neater by
: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
- Original Message -
From: livia [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Friday, June 01, 2007 1:00 PM
Subject: [R] tapply
Hello, I want to conduct normality
Dear members,
I would like to pass the histogram settings to each subset of the dataframe,
and generate a multiple figures graph.
First, can anyone tell me how to generate a multiple figures environment? I
am trying
mfrow=c(2,4) and nothing appears.
Secondly, I want to pass the following
use lattice graph
At 08:00 AM 6/1/2007, livia wrote:
Dear members,
I would like to pass the histogram settings to each subset of the dataframe,
and generate a multiple figures graph.
First, can anyone tell me how to generate a multiple figures environment? I
am trying
mfrow=c(2,4) and
On Fri, 2007-06-01 at 06:00 -0700, livia wrote:
Dear members,
I would like to pass the histogram settings to each subset of the dataframe,
and generate a multiple figures graph.
First, can anyone tell me how to generate a multiple figures environment? I
am trying
mfrow=c(2,4) and
Hallo
Seems to me that you can make a summary table using
aggregate(RESPONSE, list(TREATMENT, MEASUREMENT, BLOCK, STUDY), mean)
and then if you want you can use reshape function or melt/cast function
from reshape package to get wide form of your table.
Regards
Petr Pikal
[EMAIL PROTECTED]
Dear R-Users,
I have the following problem of which I have provided a simple example.
Using the tapply command I can efficiently run the function genflo for
all months and years. I am new to R and I do not understand how I can
store the results of f such that as the function loops through the
Hi,
I have a summary table for an experiment that looks like this
STUDY BLOCK TREATMENT MEASURMENT RESPONSE
A 1 T-0 1 12
A 1 T-1 1 52
A 1 T-0 2 12
A 1 T-1 2 65
and so on...
there are 10
Hi Jim,
jim holtman schrieb:
Here is one way:
t - split(mat, classes)
for (i in names(t)) plotdensity(t[[i]], main=i)
But then I don't use the advantages of the tapply anymore...
What is the problem you are trying to solve?
I have a set of data (multiple files), which belong to
Hi Jim,
jim holtman schrieb:
Here is one way:
t - split(mat, classes)
for (i in names(t)) plotdensity(t[[i]], main=i)
But then I don't use the advantages of the tapply anymore...
What is the problem you are trying to solve?
I have a set of data (multiple files), which belong to
But it does the same thing. What 'advantage' of tapply do you think that
you are missing? Performance is probably not impacted since most of the
time is in the plot.
On 2/16/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Hi Jim,
jim holtman schrieb:
Here is one way:
t - split(mat,
Hello,
I have another question. I would like to plot something within a self
written function (plotdensity) called by tapply
t - tapply(mat, classes, plotdensity)
Now I would like to add each plot the class/level as title.
How can I do this?
Antje
I want to transform the data by tapply to one dataframe. But I can not get
it.
For example:
tst=tapply(point,pp,length)
tst[1:10]
p1 p10 p100 p1000 p1001 p1002 p1003 p1004 p1005 p1006
1 5 1 8 6 5 8 7 4 4
res=as.data.frame(tst) # I try to transform it
res[1:10,]
p1
Is this what you want:
tst
p1 p10 p100 p1000 p1001 p1002 p1003 p1004 p1005 p1006
1 5 1 8 6 5 8 7 4 4
data.frame(point=names(tst), ind=tst)
point ind
p1 p1 1
p10 p10 5
p100 p100 1
p1000 p1000 8
p1001 p1001 6
p1002 p1002
Hi R-users,
I'm quite new to R and trying to learn the basics. I have a following
problem concerning the convertion of array object into data frame. I have
made following data sets
tmp1 - rnorm(100)
tmp2 - gl(10,2,length=100)
tmp3 - as.data.frame(cbind(tmp1,tmp2))
tmp3.sum -
Lauri Nikkinen wrote:
Hi R-users,
I'm quite new to R and trying to learn the basics. I have a following
problem concerning the convertion of array object into data frame. I have
made following data sets
tmp1 - rnorm(100)
tmp2 - gl(10,2,length=100)
tmp3 - as.data.frame(cbind(tmp1,tmp2))
Hello,
I'm applying a self-written function to a matrix on basis of different
levels.
Is there any way, to get the level information within the self-written
function???
t - tapply(mat, levels, plotDensity)
plotDensity - function(x) {
??? print(level(x)) ???
}
Antje
I think I understand tapply but i still
can't figure out how to do the following.
I have a dataframe where some of the column names are the same
and i want to make a new dataframe where columns
that have the same name are averaged by row.
so, if the data frame, DF, was
AAABBB CCC
i think you can't have column with the same names.
data.frame(AAA=1:3, AAA=4:6)
AAA AAA.1
1 1 4
2 2 5
3 3 6
but you could subset the data frame by names using substring():
sapply(unique(substring(names(data1), 1, 3)), function(x)
rowMeans(data1[,
I think this does what you want:
In - AAABBB CCC AAA DDD
+ 1 07 11 13
+ 20 8 12 14
+ 30 6 0 15
DF - read.table(textConnection(In), header=TRUE, check.names=FALSE)
DF[DF == 0]-NA
rowaverage-function(x)
Hi everyone,
Is it possible to use tapply(x,y,mean) if not all groups of x by y are
of the same length (for example if you have one missing observation)?
I tried tapply(x,y,mean,na.omit=T) but it doesn't work!
Steffi
--
-
Stefanie von Felten
Doktorandin
ETH
2006/3/12, Stefanie von Felten, IPWIfU [EMAIL PROTECTED]:
Hi everyone,
Is it possible to use tapply(x,y,mean) if not all groups of x by y are
of the same length (for example if you have one missing observation)?
Yes,It works.
I tried tapply(x,y,mean,na.omit=T) but it doesn't work!
What does
Stefanie von Felten, IPWIfU wrote:
Hi everyone,
Is it possible to use tapply(x,y,mean) if not all groups of x by y are
of the same length (for example if you have one missing observation)?
I tried tapply(x,y,mean,na.omit=T) but it doesn't work!
See ?tapply which tells you that the
I' m trying to compute weighted mean on different
groups but it only returns NA. If I use the following
data.frame truc:
x y w
1 1 1
1 2 2
1 3 1
1 4 2
0 2 1
0 3 2
0 4 1
0 5 1
where x is a factor, and then use the command :
tapply(truc$y,list(truc$x),wtd.mean, weights=truc$w)
: Thursday, January 12, 2006 3:44 PM
Subject: [R] tapply and weighted means
I' m trying to compute weighted mean on different
groups but it only returns NA. If I use the following
data.frame truc:
x y w
1 1 1
1 2 2
1 3 1
1 4 2
0 2 1
0 3 2
0 4 1
0 5 1
where x
/~m0390867/dimitris.htm
- Original Message -
From: Florent Bresson [EMAIL PROTECTED]
To: R-help r-help@stat.math.ethz.ch
Sent: Thursday, January 12, 2006 3:44 PM
Subject: [R] tapply and weighted means
I' m trying to compute weighted mean on different
groups but it only returns
On Thu, 2006-01-12 at 15:44 +0100, Florent Bresson wrote:
I' m trying to compute weighted mean on different
groups but it only returns NA. If I use the following
data.frame truc:
x y w
1 1 1
1 2 2
1 3 1
1 4 2
0 2 1
0 3 2
0 4 1
0 5 1
where x is a factor, and then
HI,
Suppose I have the following data structure.
LRT tp
1 1.50654010 522
2 0.51793929 522
3 0.90340299 522
4 1.20293325 522
5 1.05578774 523
6 0.01617942 523
7 0.68183543 523
8 0.43820244 523
9 1.14123995 524
10 0.05809550 524
11 0.93061597 524
12 1.39739700 524
13
Frank Johannes wrote:
HI,
Suppose I have the following data structure.
LRT tp
1 1.50654010 522
2 0.51793929 522
3 0.90340299 522
4 1.20293325 522
5 1.05578774 523
6 0.01617942 523
7 0.68183543 523
8 0.43820244 523
9 1.14123995 524
10 0.05809550 524
11
Hi all,
Apologies if this has been raised before ... R's tapply is very fast, but if
X has names in this example, there seems to be a huge slow down: under 1
second compared to 151 seconds. The following timings are repeatable and
are timed properly on a single user machine :
X = 1:10
Please use a current version of R!
This was fixed long ago, and you will find it in the NEWS file:
split() now handles vectors with names internally and so is
almost as fast as on vectors without names (and maybe 100x
faster than before).
On Mon, 8 Aug 2005, Matthew
I cannot find in the literature a way to conduct the following t.test
on 2 objects, A and B
A B
col1 col2 col3 col1 col2 col3
Where col(i)'s name is identical in both A and B (they are names of tissues).
How do I test (t.test) if each
AndyL == Liaw, Andy [EMAIL PROTECTED]
on Tue, 21 Jun 2005 13:30:54 -0400 writes:
AndyL Try:
(x - factor(1:2, levels=1:5))
AndyL [1] 1 2
AndyL Levels: 1 2 3 4 5
(x - x[, drop=TRUE])
AndyL [1] 1 2
AndyL Levels: 1 2
or
(x - factor(1:2, levels=1:5))
(x2
hi
i tried all the methods suggested above:
ave and rowsum with with function works for my situation. I think
the problem might not be due to tapply.
My data z comes from
z-y[y[[1]] %in% x[[2]], c(1,9)]
while z is supposed to have no entries for those non-matched between x and y.
however, when I
What does str(z) say? I suspect the second column is a factor, which, after
the subsetting, has some empty levels. If so, just drop those levels.
Andy
From: Weiwei Shi
hi
i tried all the methods suggested above:
ave and rowsum with with function works for my situation. I think
the
Even before I tried, I already realize it must be true when I read
this reply! Great job! thanks, Andy.
str(z)
`data.frame': 235 obs. of 2 variables:
$ CLAIMNUM : Factor w/ 1907 levels 0,1001849,..: 1083 1083
1083 1582 1582 1084 1681 1681 1391 1391 ...
$ SIU.SAVED: int 475 3000 3000 0
Try:
(x - factor(1:2, levels=1:5))
[1] 1 2
Levels: 1 2 3 4 5
(x - x[, drop=TRUE])
[1] 1 2
Levels: 1 2
Andy
From: Weiwei Shi [mailto:[EMAIL PROTECTED]
Even before I tried, I already realize it must be true when I read
this reply! Great job! thanks, Andy.
str(z)
`data.frame': 235
hi,
i have another question on tapply:
i have a dataset z like this:
5540 389100307391 2600
5541 389100307391 2600
5542 389100307391 2600
5543 389100307391 2600
5544 389100307391 2600
5546 381300302513NA
5547 387000307470NA
5548 387000307470NA
5549
To: R-help@stat.math.ethz.ch
Subject: [R] tapply
hi,
i have another question on tapply:
i have a dataset z like this:
5540 389100307391 2600
5541 389100307391 2600
5542 389100307391 2600
5543 389100307391 2600
5544 389100307391 2600
5546 381300302513NA
5547
On Mon, 2005-06-20 at 18:15 -0500, Weiwei Shi wrote:
hi,
i have another question on tapply:
i have a dataset z like this:
5540 389100307391 2600
5541 389100307391 2600
5542 389100307391 2600
5543 389100307391 2600
5544 389100307391 2600
5546 381300302513NA
On 6/20/05, Weiwei Shi [EMAIL PROTECTED] wrote:
hi,
i have another question on tapply:
i have a dataset z like this:
5540 389100307391 2600
5541 389100307391 2600
5542 389100307391 2600
5543 389100307391 2600
5544 389100307391 2600
5546 381300302513NA
On 6/20/05, Weiwei Shi [EMAIL PROTECTED] wrote:
hi,
i have another question on tapply:
i have a dataset z like this:
5540 389100307391 2600
5541 389100307391 2600
5542 389100307391 2600
5543 389100307391 2600
5544 389100307391 2600
5546 381300302513NA
Hi,
I'm writing for a little help.
I have a dataframe with same NA value and I'd like to obtain the means of the
value of a coloumn grouped by the levels of a factor coloumn of the datframe.
I'm using the function tapply but I see that if only a NA value is present
the result is NA.
There is an
PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Friday, March 25, 2005 10:35 AM
Subject: [R] tapply and NA value
Hi,
I'm writing for a little help.
I have a dataframe with same NA value and I'd like to obtain the
means of the
value of a coloumn grouped by the levels of a factor coloumn
25, 2005 10:35 AM
Subject: [R] tapply and NA value
Hi,
I'm writing for a little help.
I have a dataframe with same NA value and I'd like to obtain the means of
the
value of a coloumn grouped by the levels of a factor coloumn of the
datframe.
I'm using the function tapply but I see that if only
://www.med.kuleuven.ac.be/biostat/
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
- Original Message -
From: Leonardo Lami [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Friday, March 25, 2005 10:35 AM
Subject: [R] tapply and NA value
Hi,
I'm writing for a little help.
I
I have a data frame containing children, with variables 'year' = birth
year, and 'm.id' = mother's id number. Let's assume that all the births of
each mother is represented in the data frame.
Now I want to create a subset of this data frame containing all children,
whose mother's first birth was
From: Göran Broström
I have a data frame containing children, with variables 'year' = birth
year, and 'm.id' = mother's id number. Let's assume that all
the births of
each mother is represented in the data frame.
Now I want to create a subset of this data frame containing
all
://www.med.kuleuven.ac.be/biostat
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
- Original Message -
From: Göran Broström [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Tuesday, January 25, 2005 3:55 PM
Subject: [R] tapply and names
I have a data frame containing children
On Tue, Jan 25, 2005 at 10:43:24AM -0500, Liaw, Andy wrote:
From: Göran Broström
I have a data frame containing children, with variables 'year' = birth
year, and 'm.id' = mother's id number. Let's assume that all
the births of
each mother is represented in the data frame.
Now I
I'm learning how to use tapply.
Now I'm having a go at the following code in which dati contains almost 600
lines, Pot - numeric - are the capacities of power plants and SGruppo - text
- the corresponding six technologies (CCC, CIC,TGC, CSC,CPC, TE).
...
# Histograms by technology
par(mfrow=c(2,3))
tapply(Pot,SGruppo,hist)
detach(dati)
It all works great but tapply(Pot,SGruppo,hist) produces 6 histograms
with
the titles and the xlab labels in a generic form, something like
integer[1],
integer[2],
As another respondent already mentioned, Lattice is probably the way to
go on this one but if you do want to use tapply try this:
names(Pot) - SGruppo
dummy - tapply(Pot,SGruppo,function(x)hist(x,main=names(x)[1],xlab=NULL))
Vittorio v.demartino2 at virgilio.it writes:
:
: I'm learning how
Martin Maechler [EMAIL PROTECTED] writes:
and I like to help you.
As I keep installed `(almost) all released versions of R ever
installed on our machines'
I can easily run 1.8.1 (or 1.4.x or 1.0.x ...) for you.
The only difference
between the help page help(tapply)
is an extra
Hi,
I've just upgraded to 1.9.0 and one of my Sweave files that produces a
number of barplots in a standard manner now produces them in a
different way. I have made a couple of small changes to my code to
get the back the output I was getting before upgrading and now (mostly
out of curiosity)
David == David Whiting [EMAIL PROTECTED]
on 15 Apr 2004 11:42:18 + writes:
David Hi,
David I've just upgraded to 1.9.0 and one of my Sweave
David files that produces a number of barplots in a
David standard manner now produces them in a different way.
David I have
On Thu, 15 Apr 2004 18:10:27 +0200, Martin Maechler
[EMAIL PROTECTED] wrote :
David == David Whiting [EMAIL PROTECTED]
on 15 Apr 2004 11:42:18 + writes:
David Hi,
David I've just upgraded to 1.9.0 and one of my Sweave
David files that produces a number of barplots in a
Dear all
I have a dataframe containing hourly data of 3 parameters.
I would like to create a dataframe containg daily mean values of these
parameters. Additionally I want to keep information about time of
measurement (year,month,day).
With the function tapply I can average over a column of
Try this (untested):
aggregate( data[,6:8], list(date = as.matrix(data[,1:3]) %*% c(1,100,1)), mean )
---
Date: Thu, 18 Mar 2004 09:39:02 +0100
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [R] tapply
Dear all
I have a dataframe containing hourly data of 3
[EMAIL PROTECTED] wrote:
Question: is there a function that average in a single step over the 3
columns?
You may look for ?aggregate
Thomas P.
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the
70 matches
Mail list logo