similar to: aggregate function / custom column names?

Displaying 20 results from an estimated 9000 matches similar to: "aggregate function / custom column names?"

2008 Jun 17
1
re sultant column names from reshape::cast, with a fun.aggregate vector
try this: scores.melt = data.frame(grade = floor(runif(100, 1,10)), variable = 'score', value = rnorm(100)); cast(scores.melt, grade ~ variable, fun.aggregate = c(mean, length)) it has the nice column names of: grade score_mean score_length 1 1 0.08788535 8 2 2 0.16720313 15 3 3 0.41046299 7 4 4 0.13928356 13 ... but
2010 Nov 22
2
aggregate a Date column does not work?
Hi, I am trying to aggregate max a Date type column but have weird result, how do I fix this? > a <- rbind( + data.frame(name='Tom', payday=as.Date('1999-01-01')), + data.frame(name='Tom', payday=as.Date('2000-01-01')), + data.frame(name='Pete', payday=as.Date('1998-01-01')), + data.frame(name='Pete',
2013 Jan 11
3
aggregate data.frame based on column class
Hi, When using the aggregate function to aggregate a data.frame by one or more grouping variables I often have the problem, that I want the mean for some numeric variables but the unique value for factor variables. So for example in this data-frame: data <- data.frame(x = rnorm(10,1,2), group = c(rep(1,5), rep(2,5)), gender =c(rep('m',5), rep('f',5))) aggregate(data,
2010 Jan 18
2
column selection for aggregate()
Hi everybody! I'm working on R today so I have a lot of questions (you may have noticed that it's the 3rd email today). I'm new on R, so please excuse the "spam"! I have a dataset "ssfa" with many rows and the column names are: > names(ssfa) [1] "SPECSHOR" "BONE" "TO_POS" "MEASUREM" "FACETTE"
2010 Oct 07
3
aggregate text column by a few rows
Hi, R function aggregate can only take summary stats functions, can I aggregate text columns? For example, for the dataframe below, > a <- rbind(data.frame(id=1, name='Tom', hobby='fishing'),data.frame(id=1, name='Tom', hobby='reading'),data.frame(id=2, name='Mary', hobby='reading'),data.frame(id=3, name='John',
2011 Aug 02
2
Help with aggregate syntax for a multi-column function please.
Dear R-experts: I am using a function called AUC whose arguments are data, time, id, and dv. data is the name of the dataframe, time is the independent variable column name, id is the subject id and dv is the dependent variable. The function computes area under the curve by trapezoidal rule, for each subject id. I would like to embed this in aggregate to further subset by each
2006 Feb 15
2
aggregate data.frame using column-specific functions
Dear Colleagues, does anybody know how to aggregate a data.frame using different functions for different columns? Sincerely ___________________ Markus Preisetanz Consultant Client Vela GmbH Albert-Roßhaupter-Str. 32 81369 München fon: +49 (0) 89 742 17-113 fax: +49 (0) 89 742 17-150 mailto:markus.preisetanz@clientvela.com
2006 Jun 30
2
aggregate data.frame by one column
Hi, everyone, I have a data.frame named "eva" like this: IND PARTNO VC1 EO1 EO2 EO3 EO4 EO5 114 114001 2 5 4 4 5 4 114 114001 2 4 4 4 4 4 114 114001 2 4 NA NA NA NA 112 112002 2 3 3 6 2 6 112 112002 2 1 1 3 4 4 112 112003 2 6 6 6 5 6 112 112003 2 5 7 6 6 6 112 112003 2 6 6 6 4 5 114 114004 2
2011 Nov 29
2
aggregate syntax for grouped column means
I am calculating the mean of each column grouped by the variable 'id'. I do this using aggregate, data.table, and plyr. My aggregate results do not match the other two, and I am trying to figure out what is incorrect with my syntax. Any suggestions? Thanks. Here is the data. myData <- structure(list(var1 = c(31.59, 32.21, 31.78, 31.34, 31.61, 31.61, 30.59, 30.84, 30.98, 30.79, 30.79,
2018 Feb 27
0
Aggregate over multiple and unequal column length data frames
Then you need to rethink your data structure. Use a list instead of a data frame. The components of a list can have different lengths, and the "apply" family of functions (lapply(), etc.) can operate on them. Consult any good R tutorial for details. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it."
2010 Jan 29
1
SemiPar/spm question
Hello -- I posted this question yesterday and for some reason the post seems to be attached to the wrong thread. Also, I extended my test a little and it seems to indicate the problem is with spm. I would appreciate any help. Thanks. ========================================================== library(plyr) library(SemiPar) data <-
2010 Jan 25
2
(no subject)
Hello -- I would like to know of a more efficient way of writing the following piece of code. Thanks. options(stringsAsFactors=FALSE) orig <- c(rep('11111111',100000),rep('22222222',200000),rep('33333333',300000),rep('44444444',400000)) orig.unique <- unique(orig) system.time(df <- as.data.frame(sapply(orig.unique, function(x) ifelse(orig==x, 1, 0))))
2018 Feb 23
0
Aggregate over multiple and unequal column length data frames
Hi Your example is rather confusing - partly because HTML formating, partly because weird coding. You probably could concatenate your data frames e.g. by rbind or merge and after that you could try to aggregate them somehow. I could construct example data.frames myself but most probably they would be different from yours and also the result would not be necessary the same as you expect. You
2010 Feb 02
1
ggplot/time series with indicators question
Hello, I am trying to plot time-series data with certain weeks highlighted using symbols. require(ggplot2) #plotting time series data timescale <- seq(as.Date("01/01/09","%m/%d/%y"), length.out=12, by=7) data.all <- data.frame( id = c(rep('111',12),rep('222',12),rep('333',12)), week=c(timescale,timescale,timescale),
2004 May 26
0
aggregate.formula
This relates to a message from Christophe Pallier to r-help some time ago. Like myself, he finds aggregate very useful, but the interface a little cumbersome. I've implemented a more compact formula interface, found at the bottom of this message: data(ToothGrowth) # I used to aggregate like this: aggregate(list(len=ToothGrowth$len),
2011 Jan 11
2
aggregate.formula implicitly removes rows containing NA
The documentation for `aggregate` makes it sound like aggregate.formula should behave identically to aggregate.data.frame (apart from the way the parameters are passed). But it looks like aggregate.formula is quietly removing rows where any of the "output" variables (those on the LHS of the formula) are NA. This differs from how aggregate.data.frame works. Is this expected behavior?
2002 May 17
0
aggregate() classing var. def.
Dear all, I want to aggregate() my data based of the classes of a factors, just as in the help file, but how do I define the "Region varable" in the ?aggregate example? Now, the column is just like any other in my data matrix. As I understand it from ?(state), state contains a matrix with the columns Pop, Income etc., but Region is somehow separated. I noted below that as.list() is
2011 Sep 15
1
Problems with aggregate() function in stats package
Hi, I'm having some problems with the aggregate() function in the {stats} package, and the documentation doesn't address them. 1) Why would the first line work, but the second not? According to the help file, it accepts a "data=" argument. > with(tsrc, aggregate(x=DistRatio, by=list(Condition), FUN=mean)) Group.1 x 1 Congruent 1.741789 2 Mismatch 1.771425
2003 Jan 02
1
aggregate: "sum" not meaningful for factors
Dear all, I try to summarise my data per category using aggregate, but for some reason I get the error message "sum" not meaningful for factors even though my vector is numeric. The data set is shown below. Could someone please give a hint. Thanks in advance! Sincerely, Tord > names(test) [1] "ObjektID" "tallstubbyta" > is.factor(test$ObjektID);
2009 May 09
1
Improve aggregate.default ...?
Hi, I find it a bit annoying that aggregate.default forces the returned object to loose the 'name' of the variable aggregated, replacing it with 'x'. A brief example: > dat <- data.frame(A = runif(100), B = rnorm(100), + Group = gl(4, 25)) > with(dat, aggregate(A, by = list(Group = Group), FUN = mean)) Group x 1 1 0.6523228 2 2