2

I have to get the final data frame using ddply of the package plyr. Here is the code:

POI_instances = ddply(.data = POI_proximity, .variables = c("owner","deviceid","date"), .fun = function(df){data.frame(min_time = min(df$loc_ts),max_time = max(df$loc_ts))})

Basically, I am trying to subset the given data frame "POI_proximity" into the final data set "POI_instances" by applying function given in the third argument.

But I am getting the error:

R Error in unique.default(x) : unique() applies only to vectors

I did tried already asked but didn't get the solution. Any Help Possible?

Community
  • 1
  • 1
user2850251
  • 31
  • 1
  • 5
  • 2
    Have you tried with `ddply` with `summarize`. May be `ddply(POI_proximity, .(owner, deviceid, date), summarize, min_time=min(loc_ts), max_time=max(loc_ts))` not tested without an example – akrun Feb 18 '15 at 16:34
  • Here is the complication, I am able to run the code in my local windows machine with Rstudio except when I am trying to run it on the Hetzner server using Linux Centos. – user2850251 Feb 18 '15 at 16:47
  • Did you meant that your code works on some operating system but not others? I am using `linux mint 17` with `R 3.1.2` It does work fine with `summarize` though. – akrun Feb 18 '15 at 16:49
  • Both the codes worked for me. But, your code is probably not correct as it is giving you the `min` values of the whole `loc_ts` column instead of giving min for each group. – akrun Feb 18 '15 at 16:54
  • Yes, one is windows platform in which my code is running, but in the Linux environment it's not. – user2850251 Feb 18 '15 at 16:59
  • Moreover the code inside the function is correct as I am getting the desired result in one environment. – user2850251 Feb 18 '15 at 17:00
  • except platform everything is same in the "version" command. – user2850251 Feb 18 '15 at 17:03
  • Anyway, both codes worked for me. – akrun Feb 18 '15 at 17:05

0 Answers0