Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/77.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
根据dataframe创建饼图 df_R - Fatal编程技术网

根据dataframe创建饼图 df

根据dataframe创建饼图 df,r,R,非常适合tidyverse df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19- timeseries/master/countryReport/raw/rawReport.csv', stringsAsFactors = FALSE) 对于标签,我使用了geom_text_repelfromggrepelpackage的函数geom_text_repel 我正在努力。我请求帮助,因

非常适合
tidyverse

df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19- 
timeseries/master/countryReport/raw/rawReport.csv',
            stringsAsFactors = FALSE)


对于标签,我使用了
geom_text_repel
from
ggrepel
package的函数
geom_text_repel

我正在努力。我请求帮助,因为我无法拆开数据集。没人帮忙,每个人都说试试看。如果我能自己做的话,我无法寻求帮助。在这里,您将帮助解决您在编码方面面临的问题。你的问题很广泛。数据集有许多维度,可以在这些维度上制作饼图。当你请求帮助时,你需要展示你已经尝试了什么,以及你在哪里面临问题。如果您想知道如何从数据集中提取信息以绘制饼图,可以将问题发布在stats.stackexchange.com上。无论如何,我已经在下面添加了我的建议。
library(tidyverse)
df %>% 
  as_tibble() %>% 
  select(region, confirmed, recovered, death) %>% 
  gather(type, value, -region) %>% 
  group_by(region,type) %>%
  summarise(value= sum(value)) %>%
  ggplot(aes(x="", value, fill =region)) +
  geom_col(position = position_fill(), color="white") + 
  ggrepel::geom_text_repel(aes(label = region), direction = "y",
                           position = position_fill(vjust = 0.5)) +
  coord_polar(theta = "y") +
  scale_fill_discrete("") +
  facet_wrap(~type) +
  theme_void() + 
  theme(legend.position = "bottom")