Displaying 20 results from an estimated 5000 matches similar to: "plot data from tapply"
2008 Dec 10
4
tapply within a data.frame: a simpler alternative?
Dear list,
I have a data.frame with x, y values and a 3-level factor "group",
say. I want to create a new column in this data.frame with the values
of y scaled to 1 by group. Perhaps the example below describes it best:
> x <- seq(0, 10, len=100)
> my.df <- data.frame(x = rep(x, 3), y=c(3*sin(x), 2*cos(x),
> cos(2*x)), # note how the y values have a different
2008 Aug 07
6
multiple tapply
Hi folk,
I tried this and it works just perfectly
tapply(iris[,1],iris[5],mean)
but, how to obtain a single table from multiple variables?
In tapply x is an atomic object so this code doesn't work
tapply(iris[,1:4],iris[5],mean)
Thanx and great summer holidays
Gianandrea
--
View this message in context: http://www.nabble.com/multiple-tapply-tp18868063p18868063.html
Sent from the R help
2010 May 07
4
Any way to apply TWO functions with tapply()?
I need to compute the mean and the standard deviation of a data set and would
like to have the results in one table/data frame. I call tapply() two times
and do then merge the resulting tables to have them all in one table. Is
there any way to tell tapply() to use the functions mean and sd within one
function call? Something like tapply(data$response, list(data$targets,
data$conditions), c(mean,
2010 Aug 30
4
different interface to by (tapply)?
dear R experts:
has someone written a function that returns the results of by() as a
data frame? ??of course, this can work only if the output of the
function that is an argument to by() is a numerical vector.
presumably, what is now names(byobject) would become a column in the
data frame, and the by object's list elements would become columns.
it's a little bit like flattening the by()
2004 Mar 12
1
another do.call() problem.
Hi everyone
suppose I have
a <- array(1:256,rep(4,4))
and want to access a[1,2,3,1] by the vector c(1,2,3,1). As per
yesterday, I can use do.call():
a[1,2,3,1] == do.call("[",c(list(a),c(1,2,3,1)))
Now how do I apply the above technique (or indeed any other technique!) to get
a[1,2,3,]
[1] 37 101 165 229
from a vector like c(1,2,3,0) or c(1,2,3,NULL) or c(1,2,3,NA)?
2012 Aug 23
1
Extracting data from dataframe with tied rows
Hi R help,
I'm a fairly experienced R user but this manipulation has me stumped, please
help:
DATA
id<-rep(LETTERS[1:5],20)
distance<-rnorm(1:100, mean = 100)
bearing<-sample(1:360,100,replace=T)
month<-sample(1:12,100,replace=T)
I have a dataset with records of individuals (id) , each with a distance
(distance) & direction (bearing) recorded for each month (month).
I want
2009 Feb 13
2
tapply bug? - levels of a factor in a data frame after tapply are intermixed
Hello! I have encountered a really weird problem. Maybe you've
encountered it before?
I have a large data frame "importances". It has one factor ($A) with 3
levels: 3, 9, and 15. $B is a regular numeric variable.
Below I am picking a really small sub-frame (just 3 rows) based on
"indices". "indices" were chosen so that all 3 levels of A are
present:
2010 Feb 02
3
tapply for function taking of >1 argument?
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 )
Thanks for your help.
--
View this message in context:
2008 Sep 28
2
using tapply on a data frame in a function
Hello,
I'm trying to use tapply to find group means in a function. It works
outside of a function, but I get the error message from the following code:
"Error in tapply(index, cluster, mean) : arguments must have same length."
Any suggestions? Thanks.
eric
d <- data.frame(cbind(cluster=1:2, value1=1:10, value2=11:20))
d
FindClusterTraits <- function(framename, index){
2008 Nov 14
1
# values used in a function in tapply
Hello,
I am using tapply to pull out data by the day of week and then perform
functions (e.g. mean). I would like to have the number of values used for
the calcuation for the functions, sorted by each day of week. A number of
entries in any given column are NAs.
I have tried the following code and simple variants with no luck.
for (i in 1:length(a[1,])){
x<-tapply(a[,i],a[,1],mean,
2004 May 13
2
tapply & hist
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").
.....................................................
2007 Jun 18
1
getting tapply() to work across multiple columns
I have the following data.frame:
index <- c("a","a","b","b","b")
alpha <- c(1,2,3,4,5)
beta <- c(2,3,4,5,6)
table <-data.frame(index,alpha,beta)
I'm now interested in getting means of alpha and beta for each of the
index values and do a tapply() for each of the columns, e.g.
means.alpha <- tapply(table$alpha, index,mean)
2007 Jun 01
2
tapply
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: http://www.nabble.com/tapply-tf3851631.html#a10910748
Sent from the R help mailing list archive at Nabble.com.
2008 Sep 29
2
adding labels to tapply results
Hi,
How do I get labels onto the output from tapply? I need the labels to merge
the output with another data frame. Thanks.
eric
d <- data.frame(cbind(x=1:3, y=1:10))
a <- with(d, tapply(y, x, sum))
[[alternative HTML version deleted]]
1999 Feb 19
1
Potential problem with tapply
Is the following behaviour of tapply not disappointing?
Problem with tapply occurs when dealing with na.rm when an
argument additional to na.rm is sent to the applied function (here
quantile).
Any comment?
Thank you,
Philippe Lambert
> x <- c(12,10,12,2,4,11,3,7,2,1,18,7,NA,NA,7,5)
> fac <- gl(4,4,16)
> # Works fine
> tapply(x,fac,quantile,na.rm=T)
$"1"
0% 25%
2009 Oct 15
1
tapply() and using factor() on a factor
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 output, I get the following:
summary(result1)
Min. 1st Qu. Median Mean 3rd Qu.
2006 Mar 12
2
tapply with unequal length of arguments
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 Z?rich
Institut f?r Pflanzenwissenschaften
ETH Zentrum, LFW A 2
Telefon: 044 632 85 97
Telefax: 044
2007 Nov 28
1
interaction of shingles and tapply()
I'm interested in a version of tapply() that operates with shingles
instead of factors. For instance:
x <- c(1,1,2,2,3,3)
y <- c(1,1,1,0,0,0)
s <- shingle(x,intervals=cbind(c(0.5,1.5),c(2.5,3.5)))
# the following function should exist!
tapply.shingle(x,s,mean) # returns the vector c(0.75,0.25)
I've written such a function as follows:
tapply.shingle <-
2008 Jul 08
0
Fwd: Re: extracting index list when using tapply()
The following message is provided by Erik
Please provide the reproducible code to do this. Generate a sample data
set using the random data generating functions and show us what you'd
like, we can then more easily help.
ctu at bigred.unl.edu wrote:
> Hi,
> How about using "subset"?
> x1<-tapply(subset(years, length(area)>20), function(x) length(unique(x)))
>
2009 Jun 16
2
tapply with cbinded x
Dear List,
why does this not work?
df <- data.frame(var1 = c(3,2,1), var2 = c(6,5,4), var3 = c(9,8,7),
fac = c('A', 'A', 'B'))
tapply(cbind(df$var1, df$var2, df$var3), df$fac, mean)
Thank you,
Stefan