说我有以下的通用数据
A <- c(1,1,1,1,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5)
B <- c(1,1,2,1,2,1,2,3,2,3,3,4,4,3,2,3,3,4,4,5,4,4,5,5,5)
C <- c(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0)
Data <- data.frame(A,B,C)
然后,我创建了以下情节向日葵
库(动物园)
Data$F = ifelse(Data$C==1,Data$A,NA)
Data$F = na.locf(Data$F)
Data$G = ifelse(Data$C==1,NA,Data$B)
sunflowerplot(Data$G ~ Data$F,
main = "Flower_plot",
xlab = "B value where C==1",
ylab = "B value where C==0",
size = 0.25, cex.lab = 1.3, mgp = c(2.3,1,0))
而当我们在看剧情,我们要删除一些数据。
我们要删除其中对于C = 1和B = 3,数据,其中C = 0和B = 4
我已经试过这样的事情
library(dplyr)
Data_cleaned <- Data %>%
group_by(C) %>%
filter(rm(B==4[A==3 & C==0]))