[英]Argument is not named in hc_add_series
I use the package highcharter to create the plot below with: 我使用包highcharter通过以下代码创建图:
library(highcharter)
library(dplyr)
hc <- highchart() %>%
hc_chart(type="column") %>%
hc_xAxis(type="category") %>%
hc_add_series(
name = "Things",
data = list(
list(
name = "Animals",
y = 10,
drilldown = "animals"
),
list(
name = "People",
y = 10,
drilldown = "people"
)
)
)
hc
When I try to create the similar plot fot the sum of Nu
m for every US State I get: 当我尝试建立类似的情节FOT的总和
Nu
m代表美国各个州,我得到:
argument is not named in hc_add_series
State <- c("ALABAMA", "ALABAMA", "ALASKA", "ALASKA")
Num <- c(5, 6, 7, 8)
d <- data.frame(State, Num)
library(highcharter)
library(dplyr)
hc <- highchart() %>%
hc_chart(type="column") %>%
hc_xAxis(type="category") %>%
hc_add_series(
name = "States",
output2 <- d %>% group_by(State) %>%
summarise(Num = sum(Num)) %>%
mutate(drilldown = tolower(State)) %>%
transpose
)
Why does this happen since in both cases Im using a list 为什么会发生这种情况,因为在两种情况下我都使用列表
I think you can benefit from using hcaes
which works like aes
in ggplot
: 我想你可以使用受益
hcaes
其工作方式aes
在ggplot
:
highchart() %>%
hc_chart(type="column") %>%
hc_xAxis(type="category") %>%
hc_add_series(
data = d,
name = "States",
type = "column",
hcaes(x = State, y = Num)
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.