0
我剛剛發現了rCharts。是否可以做一個密度圖?例如用ggplot2我做:我如何用rCharts繪製密度?
library(ggplot2)
m <- ggplot(movies, aes(x = rating))
m + geom_density(aes(fill=factor(Drama)), size=2)
謝謝!
我剛剛發現了rCharts。是否可以做一個密度圖?例如用ggplot2我做:我如何用rCharts繪製密度?
library(ggplot2)
m <- ggplot(movies, aes(x = rating))
m + geom_density(aes(fill=factor(Drama)), size=2)
謝謝!
我能做到這一點
library(rCharts)
drama = density(movies$rating[movies$Drama==1])
drama = data.frame(drama$x, drama$y)
drama$Var = "Drama"
names(drama) = c("x", "y", "Var")
Nodrama = density(movies$rating[movies$Drama==0])
Nodrama = data.frame(Nodrama$x, Nodrama$y)
Nodrama$Var = "No Drama"
names(Nodrama) = c("x", "y", "Var")
densen1n2 = rbind(drama, Nodrama)
nPlot(x = "x", y = "y", group = "Var", data = densen1n2, type = "lineChart")
不知道這是最好的方式。我也不知道如何給一個名稱的X軸
是的,你可以...... – agstudy
這只是一個谷歌... ... http://bl.ocks.org/patilv/raw/7360262/ – hrbrmstr
@hrbrmstr謝謝! – Ignacio