i novice r programmer. below dataframe using. running filtering problem full_join()
tidyverse
.
library(tidyverse) set.seed(1234) df <- data.frame( trial = rep(0:1, each = 8), sex = rep(c('m','f'), 4), participant = rep(1:4, 4), x = runif(16, 1, 10), y = runif(16, 1, 10)) df
i doing following operation full_join()
df <- df %>% mutate(k = 1) df <- df %>% full_join(df, = "k")
i restricting results obtain combination of points same participant between trials
df2 <- filter(df, sex.x == sex.y, participant.x == participant.y, trial.x != trial.y) df3 <- filter(df2, participant.x == 1) df3
here, @ step, running trouble. not care order of points. how condense duplicates 1 row?
thank you
depending on columns considering, use duplicate function. first 1 weed out duplicates based on first 5 columns. last 1 weed out duplicates based on
df3[!duplicated(df3[,1:5]),] df3[!duplicated(df3[,7:11]),]
Comments
Post a Comment