F. Lumley
F. Lumley

Reputation: 765

Alternative to dlply in R or dplyr

I'm trying to remove dependency on plyr and have a line which uses the dlply function.

translation <- dlply(data ,.(key), function(s) key = as.list(s))

I've tried to use lapply and split based on a previous answer but cannot work out how to translate the key and as.list parts.

Upvotes: 1

Views: 114

Answers (1)

akrun
akrun

Reputation: 887251

If we want to get similar structure, use split and then unclass

lapply(split(data, data$key), unclass)

-testing

lapply(split(head(mtcars), head(mtcars)$cyl), unclass)

Upvotes: 2

Related Questions