图表R中的总和或平均值 city\u data

图表R中的总和或平均值 city\u data,r,plotly,R,Plotly,如何将ggplot与Plotly相结合 city_data <- tribble( ~City, ~Value, "Mumbai", "100", "Delhi", "200", "Mumbai", "150", "Delhi", 250 ) plot_ly(x = city_data$City, y = city_data$Value, type = "bar")

如何将
ggplot
Plotly
相结合

city_data <- tribble(
            ~City, ~Value,
            "Mumbai", "100",
            "Delhi", "200",
            "Mumbai", "150",
            "Delhi", 250
)

plot_ly(x = city_data$City, y = city_data$Value, type = "bar")
library('tibble')
库(“plotly”)

样本数据中的city_数据在
值中混合了字符串和数字。谢谢,我会检查它,如果它满足我的要求,我会告诉你。
library('tibble')
library('plotly')

city_data <- tribble(
  ~City, ~Value,
  "Mumbai", 100,
  "Delhi", 200,
  "Mumbai", 150,
  "Delhi", 250
)

g <- ggplot(city_data, aes(City)) + geom_bar(aes(weight = Value))
ggplotly(g)