search for: agg1

Displaying 6 results from an estimated 6 matches for "agg1".

Did you mean: agg
2011 Jul 14
2
cbind in aggregate formula - based on an existing object (vector)
...1,3.1,30.1,300.1,4.1,40.1,400.1) example<-data.frame(mydate=mydate,value1=value1,value2=value2) example$group<-c(rep("group1",3),rep("group2",3),rep("group1",3),rep("group2",3)) example$group<-as.factor(example$group) (example);str(example) example.agg1<-aggregate(cbind(value1,value2)~group+mydate,sum,data=example) # this works (example.agg1) ### Building my object (vector of 2 names - in reality, many more): myvars<-c("value1","value2") example.agg1<-aggregate(cbind(myvars)~group+mydate,sum,data=example) ### does not...
2012 Jun 05
4
need descriptive help
Hi all, I'm new to using R, and apologize for simplicity of this question. I'm using a data set with over 60,000 observations, Two variables are patient ID, and cost incurred by the patient. I'd like to generate frequency/table by patient and cost IF the total cost is over 2000. Right now I'm using: by(x$cost, x$patient, sum) but this generates a huge list for each patient.
2011 Jan 26
1
aggregate(as.formula("some formula"), data, function) error when called from in a function
...0,replace=TRUE) # make a column of 1s and zeros # 1 when that row has that level of y # 0 otherwise lvls <- levels(dat$y) dat$ya <- 1*(dat[,1] == lvls[1]) dat$yb <- 1*(dat[,1] == lvls[2]) dat$yc <- 1*(dat[,1] == lvls[3]) # this works fine if you give the exact function agg1 <- aggregate(cbind(ya,yb,yc)~x,data=dat,sum) # and fine if you accept fo <- as.formula("cbind(ya,yb,yc)~x") if(test) { return(list(fo=fo,data=dat)) } cat("do agg 2\n") agg2 <- aggregate(fo,data=dat,sum) list(agg1,agg2) } agg2(FALSE) ag <- agg2(TRUE)...
2008 Mar 29
3
Generating maps in R
Greetings! I am trying plot some data on a map in R. Here's the scenario. I have a variable called probworkinghealthy which contains a predicted probability of employment for every individual in my sample (about 100,000 observations). I have another variable, called a001ter, which contains the subject of residency in the Russian Federation (akin to a US state) for every individual in the
2011 Apr 18
1
using "aggregate" when variable names contain spaces
...$group) ### Generating variable names with spaces: names(example)<-c("mydate", "my value 1","my value 2","group") ### Trying to aggregate - but it's not working. Clearly, my reference to variable names is incorrect: mynames<-names(example) example.agg1<-aggregate(cbind(mynames)~group+mydate,sum,data=example) Thank you very much! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com
2012 Sep 07
7
Producing a table with mean values
Hi All, I have a data set wit three size classes (pico, nano and micro) and 12 different sites (Seamounts). I want to produce a table with the mean and standard deviation values for each site. Seamount Pico Nano Micro Total_Ch 1 Off_Mount 1 0.0691 0.24200 0.00100 0.31210 2 Off_Mount 1 0.0938 0.00521 0.02060 0.11961 3 Off_Mount 1 0.1130 0.20000 0.06620 0.37920 4 Off_Mount 1