You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if people could help with this problem. I am trying to use group_by() and rle() in R to group according to column1 and count the consecutive number of times there is either a one or a zero within each group from column2. I would like to return both the "values" and "lengths" data from using rle().
This is what my data frame (df1) looks like:
I used this code to generate what I thought might work based on some suggestions I found on the web.
Since I was ultimately interested in only the values in column1 which were "1", I used this code that I adapted from another website. Unfortunately, I forget now what that site was.
Hello Everyone,
I was wondering if people could help with this problem. I am trying to use group_by() and rle() in R to group according to column1 and count the consecutive number of times there is either a one or a zero within each group from column2. I would like to return both the "values" and "lengths" data from using rle().
This is what my data frame (df1) looks like:
I used this code to generate what I thought might work based on some suggestions I found on the web.
df2 <- df1 %>% group_by(column1) %>% reframe(data.frame(unclass(rle(df1$column2))))
This is the output I get for df2:
It seems that my code is not grouping the data effectively according to column1. Any suggestions would be appreciated. Thanks.
The text was updated successfully, but these errors were encountered: