I have a dataframe called data
where I would like to rescale the values in the 4th field to a range of 0-1000 and round the scaled value to the nearest integer. I'm trying to use ddply
, round
and rescale
:
scaled_data <- ddply(data, round(rescale(data[,4], to=c(0,1000), from=range(data[,4], na.rm=TRUE)), 0)
The above code throws this error:
Error in `[.data.frame`(envir, exprs) : undefined columns selected
Can anyone point out the problem or a better way to accomplish what I am trying to do?