R.如何对名称中带有 () 括号的行进行子集化?

R . How to subsetting a row which have () parentheses in the name?

我对R很菜鸟,正在尝试剧情。

该文件包含一堆具有 4 个不同名称的行,我可以对某些行进行子集化,但我对文本中带有括号的其他行有问题。我如何对论文进行子集化?

我也想重新订购,但是我做不到

提前致谢!

文件是这样的:link to .csv

library(tidyverse)

dfagro<- read.csv("C:/Users/../data.csv", encoding = "ASCII", header = TRUE, sep = ",")
colnames(dfagro) <- c("time","GEO", "crop", "stuc", "Value", "flag")

# dfagro$Value = as.numeric(gsub(",","\.",dfagro$Value))

# dfagro %>%
# mutate(GEO = fct_reorder(GEO, Value)) %>%

ggplot(subset(dfagro, crop %in% c("Permanent crops for human consumption")), aes(x=GEO, y=Value)) +
     geom_bar(stat="identity", width=0.6) + coord_flip()      # +
  #geom_text(data=dfagro, aes(y=Value,label=Value),vjust=1)

当我尝试用 () 绘制此类行时出现问题:

# ggplot(subset(dfagro, crop %in% c("Fresh vegetables (including melons)")), aes(x = GEO, y = Value))+

我们可以使用 filter

library(dplyr)
dfagro %>%
        mutate(GEO = fct_reorder(GEO, Value)) %>%
        filter(crop %in% "Permanent crops for human consumption")