similar to: Using paste on results from tapply?

Displaying 20 results from an estimated 20000 matches similar to: "Using paste on results from tapply?"

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]]
2012 Oct 22
6
How to use tapply with more than one variables grouped
I'm studying alone the R language for data preparation. I found a course at MIT for data preparation that uses python but I'm using R to learning. The first exercise is the preparation of data from a database that shows the contributions made to candidates for U.S. president. The database is described in FORMART
2006 Dec 07
2
Splitting a dataframe at the results of tapply
I have got a dataframe containing measurement of aircraft noise like this: > Id <- c(1,4,5,2,3,6,4,1,2,5,6,3) > Noise <- c(88,94,97,98,92,56,103,102,87,95,92,97) > Height <- c(190, 150, 120, 115, 188, 104, 101, 189, 146, 111, 124, 126) > > df <- data.frame(Id, Noise, Height) Now I would like to split this in two new dataframes. The first one containing the rows
2012 Sep 14
1
parallel version of tapply() or table()?
Hello R-helpers. I've tried to recreate a parallel version of tapply() and table() using a combination of the parallel functions mclapply() and pvec() and papply(), but haven't been successful. In the end, I'm trying to get a cross tab of two vectors. I currently (can) use tapply(..., sum) and table(), and even xtabs() and ftable(), but with tens of millions of words and tens of
2007 Jan 26
1
plotting results from tapply
Hi, there I'm trying to plot what is returned from a call to tapply, and can't figure out how to do it. My guess is that it has something to do with the inclusion of row names when you ask for the values you're interested in, but if anyone has any ideas on how to get it to work, that would be stellar. Here's some example code: y1<-rnorm(40, 2) x1<-rep(1:2, each=20)
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<-
2006 Mar 14
2
Multi-line paste function
Here's my contribution to R. When R interacts with external programs (MySQL, cURL, etc.), it often requires a pasted string that is sent to these programs. For readability reasons, it is often preferable to have complex commands (SQL for example) spread on several lines. However, the normal paste function requires to add additional ' ", ' at the end of each line and another '
2001 Feb 21
1
Specification of factors in tapply
After some fiddling around with the tapply command, I discovered that the factors (the INDEX argument) given to tapply must be specified in fastest-cycling first order. The following code shows how I discovered my error: (R version 1.2.1) -o-o-o-o-o- x <- as.data.frame(list(data=c(-9,0,3,1,-9,1,0,-9,0,3,1,-9,1,0), subj=c(rep(1,7),rep(2,7)),
2008 May 02
2
Coercing by/tapply to data.frame for more than two indices?
Dear Colleagues, Apologies for a long email to ask what I feel may be a very simple question; I figure it's better to overspecify my situation. I was asked a question, recently, by a colleague in my department about pre-aggregating variables, i.e., computing the mean of defined subsets of a data frame. Naturally, I thought of the 'by' and 'tapply' functions, as
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){
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"). .....................................................
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 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
2008 Nov 07
2
Re gular Expression help
hi there I have a vector with a set of data.I just wanna seperate them based on the first p and q values metioned within the data. [1] chr10p15.3 /// chr3q29 /// chr4q35 /// chr9q34.3 [2] chr1q22-q24 [3] chr1q22-q24 [4] chr1pter-q24 [5] chr1pter-q24
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,
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 =
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.
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.
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
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