Probelm with a restrame in R

5lwkijsr  于 2023-11-14  发布在  其他
关注(0)|答案(1)|浏览(83)

我有一个10列和7.000行的嵌套框架,我想创建一个新的嵌套框架,有一个列的特定值,我尝试与subset.data.frame,但我有这个错误:

Error in subset.default(peak.anno_4$ENTREZID == c("171832", "172856",  : 
      argument "subset" is missing, with no default
    In addition: Warning message:
    In peak.anno_4$ENTREZID == c("171832", "172856", "177870", "173051",  :
      longer object length is not a multiple of shorter object length

字符串
有人能提出一个解决方案吗?

1qczuiv0

1qczuiv01#

我假设你试图检索具有某些ID值的行。如果是这种情况,你应该使用库dplyr。如果你的数据集很大(你的csv文件超过10GB),我推荐库data.table
下面是示例代码。

library(dplyr)

sample <- data.frame("ID" = c("1", "2", "3", "4"),
                     "NAME" = c("A", "B", "C", "D"))

#retrieving only 3 & 4
search_value <- c("3", "4")
#creating a new dataframe sample2
sample2 <- sample %>% 
  filter(ID %in% search_value)

字符串
您可以在dplyr网站(https://github.com/tidyverse/dplyr)中查找其他材料

相关问题