0

I have a data frame which looks like this:

dput(test.df)
structure(c("a", "a", "b", "c", "d", "1", "2", "3", "3", "4"), .Dim = c(5L, 
2L), .Dimnames = list(NULL, c("session_", "vid_")))

what I need to do in R is to check which sessions have more than 1 vid_ , then will be marked as TRUE in a new column, so the results looks like this:

> dput(results.df)
structure(c("a", "a", "b", "c", "d", "1", "2", "3", "3", "4", 
"TRUE", "TRUE", "FALSE", "FALSE", "FALSE"), .Dim = c(5L, 3L), .Dimnames = list(
    NULL, c("session_", "vid_", "dirty_session")))

I want to do it in a clean way in 1 row of code, and not group by and count vid's into a seperate dataset and join it back to the original set any help appreciated

Nir Regev
  • 135
  • 1
  • 2
  • 7

0 Answers0