문제

I have a ddply that goes over a list of IPs and applies a fun over each IP. I want the fun to return a value only if the nrow(ip.data) > 1. Otherwise, I want ddply to skip over that IP and continue. How can I do this?

eg:

pd.outs <- ddply(server_ips, .(ip), function(x) get.ip.outs(x$ip, data))

nrow(ip.data) will provide the length of the number of rows in the subset of (data).

도움이 되었습니까?

해결책

One way is to just return NULL where nrow(x)==1:

pd.outs <- ddply(server_ips, .(ip), function(x) {
  if (nrow(x) == 1) {
    return(NULL)
  }
  get.ip.outs(x$ip, data)
})
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top