similar to: Remark on tapply().

Displaying 20 results from an estimated 10000 matches similar to: "Remark on tapply()."

2002 May 14
2
tapply and empty subsets
I am using tapply to compute means by group, as in > tapply(y, z, mean) 1 2 3 21.00757 20.50031 NA where y is a vector and z a factor with levels 1:3. I would like to get a zero instead of the NA I get when a subset is empty. The problem is that FUN is not applied to empty cells of the ragged array. (Of course I am willing to define a function my.mean that returns
2011 Oct 16
2
question: ragged array
Hello, I have a big problem which I’m just not able to solve. I created the following mean value from the following dataset structure: Id |value 1 | 2 1 | 3 1 | 4 2 | 2 2 | 1 3 | 5 4 | 3 etc.|etc. with the command: mean_rating <- tapply(ratok$value, ratok$project_id , mean,simplify = FALSE) this gives me a ragged array: > mean_rating [1] $`14`
2004 Sep 13
1
Adding ranks to a repeatedly ragged array
How can I add an extra column containing the rank to a ragged array indexed by more than one grouping factors? E.g. with the barley dataset: How can I to add an additional column ``rank'' containing the rank of the ``yield'' of the different varieties in relation to the indices ``year'' and ``site'' to the barley dataframe? I achieved to calculate the ranks with:
2003 Apr 17
3
accessing current factor in tapply
G'Day, I want to access in a function called from tapply the current factor. In my example below, all I want to do is to write the current factor on each histogram. Needless to say my example does not work. I would be grateful for pointers in the right direction. Many thanks Bernie McConnell Sea Mammal Reserach Unit cc <- 1:10 ff <- rep(c("a","b"),5) pp<-
2016 Sep 09
2
R-intro: function 'stderr' and 'sd'
In "An Introduction to R" Version 3.3.1, in "4.2 The function tapply() and ragged arrays", after stderr <- function(x) sqrt(var(x)/length(x)) , there is a note in brackets: Writing functions will be considered later in [Writing your own functions], and in this case was unnecessary as R also has a builtin function sd(). The part "in this case was unnecessary as R also
2012 Oct 23
10
How to pick colums from a ragged array?
I have a large dataset (~1 million rows) of three variables: ID (patient's name), DATE (of appointment) and DIAGNOSIS (given on that date). Patients may have been assigned more than one diagnosis at any one appointment - leading to two rows, same ID and DATE but different DIAGNOSIS. The diagnoses may change between appointments. I want to subset the data in two ways: - define groups
2000 Mar 03
1
tapply, sorting and the heap
howdy gurus, I'm new and green and I was hoping for a tiny bit of your expertise. I'm running out of virtual memory (heap?) when summing using tapply. I've already used --vsize=90M on my hpux machine. (details below) Can I pre-sort or something to prevent my error? thanks, John Strumila john.strumila at corpmail.telstra.com.au > gc()["Vcells","total"] [1]
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 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 definition." I'd like to raise a discussion of the possibility of an
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:
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"
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,
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)
2008 Sep 01
1
how to pass additional parameters to a function called in tapply?
Hi all, the following problem is still beyond my R-knowledge: I have one data vector containing the signal from 4 channels that are measured subsequently and in repeating cycles (with one factor vector for cycle and one for channel identification). To extract the mean of each channel during each cycle tapply is the method of choice. However, I cannot use the whole measuring period for each
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){
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 NULL 2 NULL NULL 3 6
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
2011 Mar 15
1
Questions on dividing lists and tapply
Hello R community, I have two questions about using R. The first is about dividing each element of a list with another similar sized list. So, if the first list has two elements and so does the second, then the result should also be a list with two elements. For example, the inputs are: list(matrix(1:6,ncol=2),matrix(1:6,ncol=2))->l1 l2<-list(1:3,2) I want to get a list, l3 with the
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) { ret = c(unname(quantile(x,probs=seq(.25,.75,.25),na.rm=T)),mean(x,na.rm=T)) } a =
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