Displaying 4 results from an estimated 4 matches for "myaggs".
Did you mean:
myagg
2012 Feb 03
1
incomplete final line found on <name of my sourced function file>
Dear R-ers,
I hope there is a really simple solution to my problem.
I've written a function that I saved in an .r file. I source this file
in my code. For a while it worked fine. But then when I run the line:
source("F mylineplot.r")
I started getting a warning:
In readLines(file) : incomplete final line found on 'F mylineplot.r'
I have no idea why - I tried to check and
2008 Oct 02
1
Help with aggregation
Hi All,
I seem to be having a few troubles with aggregating data back onto the the
dataframe,
I want to take the max value of a user, and then apply this max value back
against all id's that match (i.e a one to many matching)
Can anyone offer any advice? is there a better way of doing this?
Dummy data and code are listed below:-
dataset is called Mcookie
user_id c_we_conversion
1
2011 Oct 05
2
aggregate function with a dataframe for both "x" and "by"
...1=c(1,3,5,7,8,3,5,NA,4,5,7,9),
testvar2=c(11,33,55,77,88,33,55,NA,44,55,77,99)
)
mybys=data.frame(mbn1=c('red','blue',1,2,NA,'big',1,2,'red',1,NA,12),mbn2=c('wet','dry',99,95,NA,'damp',95,99,'red',99,NA,NA)
, stringsAsFactors =F)
myaggs <- data.frame(matrix(data=NA, nrow=nrow(mydata), ncol=ncol(mydata) )
)
for(i in 1: ncol(mydata) ) {
temp <- aggregate(mydata[i], by = as.list(mybys[i]), FUN=sum, na.rm=T)
rownums <- match(mybys[,i],temp[,1])
myaggs[,i] <- temp[rownums,2]
}
myaggs
Finally, how do I convert a...
2004 Aug 16
1
turning off automatic coersion from list to matrix
Hello,
I am having trouble understanding how R is coercing between matrices and
lists in the following example. I have an aggregate behavior I like:
aggregate(a[,"num"],by=list(product=a[,"product"],region=a[,"region"]),
sum)
Now in reality I have more columns than just product and region, and
need to pick different combinations. So I want to abstract this into a