Displaying 20 results from an estimated 1618 matches for "tapply".
Did you mean:
apply
2004 May 05
3
sample
Dear List:
I have the following simple program:
x<- sample(site)
VarGuilda1<- var(tapply(x,site,func1))
VarGuilda2<- var(tapply(x,site,func2))
VarGuilda3<- var(tapply(x,site,func3))
VarGuilda4<- var(tapply(x,site,func4))
VarGuilda5<- var(tapply(x,site,func5))
VarGuilda6<- var(tapply(x,site,func6))
VarGuilda7<- var(tapply(x,site,func7))
VarGuilda8<- var(tapply(x,sit...
2007 Nov 06
1
A suggestion for an amendment to tapply
Dear R-developers,
when tapply() is invoked on factors that have empty levels, it returns
NA. This behaviour is in accord with the tapply documentation, and is
reasonable in many cases. However, when FUN is sum, it would also
seem reasonable to return 0 instead of NA, because "the sum of an
empty set is zero, by definitio...
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-tp18...
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")....
2008 Jul 08
3
extracting index list when using tapply()
Hello,
The quick version of my question is how can I extract a matrix instead of
a vector using tapply()? I would like to be able to access both the results
of tapply() and also the index variables.
In case further explanation would help: I am analyzing a large (3million
rows x 9 columns) spatial/temporal dataset and am attempting to calculate
the number of unique years containing any data within...
2017 Jan 26
3
RFC: tapply(*, ..., init.value = NA)
...ch/pipermail/r-devel/2017-January/073621.html
In the mean time, I've spent several hours on the issue
and also committed changes to R-devel "in two iterations".
In the case there is a *Left* hand side part to xtabs() formula,
see the help page example using 'esoph',
it uses tapply(..., FUN = sum) and
I now think there is a missing feature in tapply() there, which
I am proposing to change.
Look at a small example:
> D2 <- data.frame(n = gl(3,4), L = gl(6,2, labels=LETTERS[1:6]), N=3)[-c(1,5), ]; xtabs(~., D2)
, , N = 3
L
n A B C D E F
1 1 2 0 0 0 0
2 0 0...
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...
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: http://n4.nabble.com/tapply-for-function-taking-of-1-argument-tp1460392p1460392.html
S...
2009 Apr 13
3
tapply output as a dataframe
i use tapply and by often, but i always end up banging my head against
the wall with the output.
is there a simpler way to convert the output of the following tapply to
a dataframe or matrix than what i have here:
# setup data for tapply
dt = data.frame(bucket=rep(1:4,25),val=rnorm(100))
fn = function(x) {...
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, sd)).
Thanks in advance.
--
View this me...
2017 Jan 27
1
RFC: tapply(*, ..., init.value = NA)
The "no factor combination" case is distinguishable by 'tapply' with simplify=FALSE.
> D2 <- data.frame(n = gl(3,4), L = gl(6,2, labels=LETTERS[1:6]), N=3)
> D2 <- D2[-c(1,5), ]
> DN <- D2; DN[1,"N"] <- NA
> with(DN, tapply(N, list(n,L), FUN=sum, simplify=FALSE))
A B C D E F
1 NA 6 NULL NULL NULL NUL...
2002 Jan 24
5
aggregate, by tapply
Dear R users
I searched some sources but i did not find an answer.Please give
me some hint to following problem.
I would like to compute a summary statistic for some vector for
different factor levels. I know I can use tapply or aggregate but I
do not know if there is a way how to use function with several
(two) variable input (like weighted.mean).
I wrote a simple a function for factor weighted mean
fff<-function(x,fact,w)
{
ws<-tapply(w,fact,sum)
newx<-x*w
tapply(newx,fact,sum)/ws
}
which can handle parti...
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...
2012 Sep 03
1
Scatter plot from tapply output, labels of data
Hei,
i am trying to plot the means of two variables (d13C and d15N), by 2
grouping factors (Species and Year) that i obtained by the function tapply.
I would like to plot with different colours according to the Year and show
the "Species" as data labels.
My data looks like this:
Species d13C d13N Year
"Species1" 14,4 11.5 2009
"Species2" ... ... ....
>Nmean<...
2017 Jan 26
2
RFC: tapply(*, ..., init.value = NA)
...lated note, the storage mode should try to match ans[[1]] (or
unlist:ed and) when allocating 'ansmat' to avoid coercion and hence a full
copy.
Henrik
On Jan 26, 2017 07:50, "William Dunlap via R-devel" <r-devel at r-project.org>
wrote:
It would be cool if the default for tapply's init.value could be
FUN(X[0]), so it would be 0 for FUN=sum or FUN=length, TRUE for
FUN=all, -Inf for FUN=max, etc. But that would take time and would
break code for which FUN did not work on length-0 objects.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Jan 26, 2017 at 2:42 AM, Ma...
2004 Mar 15
2
Bug in tapply with factors containing NAs (PR#6672)
Full_Name: George Leigh
Version: 1.8.1
OS: Windows 2000
Submission from: (NULL) (203.25.1.208)
The following example gives the correct answer when the first argument of tapply
is a numeric vector, but an incorrect answer when it is a factor. If the
function used by tapply is "length", the type and contents of the first argument
should make no difference, provided it has the same length as the second
argument.
> x = c(NA, 1)
> y = factor(x)
> tapply(x...
2004 Aug 21
2
more on apply on data frame
Hi R People:
Several of you pointed out that using "tapply" on a data frame will work on
the iris data frame.
I'm still having a problem.
The iris data frame has 150 rows, 5 variables. The first 4 are numeric,
while the last is a factor, which has the Species names.
I can use tapply for 1 variable at a time:
>tapply(iris[,1],iris[,5],mean...
2008 Sep 09
2
exporting tapply objects to csv-files
Dear Everyone,
I try to create a cvs-file with different results form the table function.
Imagine a data-frame with two vectors a and b where b is of the class factor.
I use the tapply function to count a for the different values of b.
tapply(a,b,table)
and I use the table function to have a look of the frequencies as a total
table(a)
I would like to put both results together in one txt or csv file that I can import to e.g. Excel.
The export file should have a layout like
1...
2005 Jun 20
6
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 381300302513 NA
5547 387000307470 NA
5548 387000307470 NA
5549 387000307470 NA
5550 38700030747...
2012 Aug 29
5
tapply confusion
...lo
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 factor analysis.
> tapply(Temp, INDEX = Roof, FUN = median)
This works fine, however if i try to do anything a bit more complex, such
as:
> tapply(Temp, INDEX = Roof, FUN = kruskal.test)
it gives the error - Error in length(g) : 'g' is missing
What could be the proble...