Displaying 1 result from an estimated 1 matches for "getminmax2".
Did you mean:
getminmax1
2010 Dec 06
3
[plyr] Question regarding ddply: use of .(as.name(varname)) and varname in ddply function
..., ## I am using
as.name(grp), source of error
function(x){
minmax <- c(mix(x[ , 3]), max(x[ ,3]))
return(minmax)
}
)
return(dfret)
}
## Works fine
# grp -- name of a column of the the data.frame df
# function call is -- getMinMax2( df1 , grp = "var1")
getMinMax2 <-function(df, grp){
dfret <- ddply( df , grp, ## using the quoted variable name
passed to grp when the fun is called
function(x){
minmax <- c(min(x[ , 3]), max(x[ ,3]))
return(minmax)...