c()和|之间的区别在使用R的子集中

时间:2018-08-06 14:16:33

标签: r

我尝试从原始数据库中提取一个子集,但是我不明白为什么我在看起来相同的行中得到了一些不同的结果。让我们举个例子:

     a <- data.frame(c("1091Z","4773Z","4725Z","4781Z","4789Z","4725Z","4779Z","4789Z",
            "1071D","4789Z"))
     colnames(a) <- "name"
     b<- subset(a, name == c("1071D","4789Z")) #3 obs. of 1 variables
     d<- subset(a, name == c("4789Z","1071D")) #1 obs. of 1 variables
     c<- subset(a, name == "4789Z" |name =="1071D") #4 obs. of 1 variables

如果我使用filter代替subset,结果是相同的。

0 个答案:

没有答案