ddply skip if nrow = 1

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).

Answers


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)
})

Need Your Help

Using setInterval with PageMethods

setinterval scriptmanager pagemethods

I am trying to call a LoadFile() function every X seconds using setInterval, and I want to call this in my document ready function , and a scriptmanager on my aspx page sets EnablePageMethods as tr...

Write text file to Blob in Azure using PHP

php azure azure-storage azure-storage-blobs

I'm trying to write a text file to the blob. I know i have to create a container and a blob. I need to write something like this: