Hi,
I am a learner in R. So, I was trying to use/learn Ddply function of Plyr package and do some simple finding Minimum value based on Group steps but I found the below error. Though I know there are other ways to get the desired result.
ec_max <- ddply(AEC, .(Subject Identifier for the Study
), summarise, min_vis = min(Visit Number
, na.rm = TRUE))
when I use the above statement I get "Inf" for the Min_vis column as there are missing value present.
So I use the below steps to try out the ignore missing value and replace with 0
ec_max <- ddply(AEC, .(Subject Identifier for the Study
), summarise, min_vis = function(x) {ifelse(!is.na(x$Visit Number
), min(x$Visit Number
), 0 )})
but this statement gives the below error
Error in vector(type, length) :
vector: cannot make a vector of mode 'closure'.
I would like to know what is this error and how to get rid of this error?
My data looks like this
|Subject Identifier for the Study|Visit Number|Visit Name|
|123|5|Week 5|
|123|6|Week 6|
|123|7|Week 7|
|123|8|Week 8|
|123|9|Week 9|
|124|NA|NA|
|124|5|Week 5|
|124|8|Week 8|
|124|9|Week 9|
|124|NA|NA|
|124|18|Week 18|
|125|4|Week 4|
|125|5|Week 5|
|125|9|Week 9|
|125|NA|NA|
|125|15|Week 15|
|125|16|Week 16|