Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 将数据帧列转换为向量_R - Fatal编程技术网

R 将数据帧列转换为向量

R 将数据帧列转换为向量,r,R,我有一个名为“Continumes_tmap”的数据帧,我想在其中返回3个向量,如下例所示。注意:“值”需要根据dataframe中的名称区分大小写 labels = c("France","Germany","India", etc) Parent = c("Europe","Europe","Asia",etc) Values = c(100,345,456,etc)

我有一个名为“Continumes_tmap”的数据帧,我想在其中返回3个向量,如下例所示。注意:“值”需要根据dataframe中的名称区分大小写

labels = c("France","Germany","India", etc)
Parent = c("Europe","Europe","Asia",etc)
Values = c(100,345,456,etc)

我目前的代码如下

covid_1 <-
  read.csv("C:/Users/Owner/Downloads/COVID-19 Activity.csv", stringsAsFactors = FALSE)
df1 <-
  select(
    covid_1,
    REPORT_DATE,
    COUNTRY_SHORT_NAME,
    COUNTRY_ALPHA_3_CODE,
    PEOPLE_DEATH_NEW_COUNT,
    PEOPLE_POSITIVE_NEW_CASES_COUNT,
    PEOPLE_DEATH_COUNT,
    PEOPLE_POSITIVE_CASES_COUNT,
    CONTINENT_NAME
  )

Continents_tmap <- df1 %>%
  group_by(Continent,Country.x) %>%
  summarise(Deaths = sum(Deaths), Cases = sum(Positive_Cases))
Continents_tmap<- data.frame(Continents_tmap)

covid_1了解大陆tmap data.frame的外观会很有帮助。我假设它是一个data.frame,包含“大陆”、“国家”和“值”列?如果我答对了你的问题,你可以简单地得到一个data.frame列作为向量,如下所示:
labels谢谢。。。。标签