我正在遵循此https://stackoverflow.com/a/3542115/3483997方法,以便将 2 个直方图(具有不同的总体)集成在同一数据框中。
ROS_SPITFIRE <- data.frame(length = rnorm(100, 0.76406353, 0.500970292))
ROS_FARSITE <- data.frame(length = rnorm(398, 3.48366834170854,2.19050069588744))
#Now, combine your two dataframes into one. First make a new column in each.
ROS_SPITFIRE$veg <- 'ROS_SPITFIRE'
ROS_FARSITE$veg <- 'ROS_FARSITE'
#and combine into your new data frame vegLengths
vegLengths <- rbind(ROS_SPITFIRE, ROS_FARSITE)
#now make your lovely plot
ggplot(vegLengths, aes(length, fill = veg)) + geom_density(alpha = 0.3)
ggplot(vegLengths, aes(length, fill = veg)) + geom_density(alpha = 0.3)
ggplot(vegLengths, aes(length, fill = veg)) + geom_histogram(alpha = 0.5, aes(y = ..density..), position = 'identity')
ggplot = ggplot + xlim((0,15))
当我在每个数据框中创建新列时,我的问题出现了。它产生负值,因此我的最终分布图在 X 轴上具有负值。有谁知道如何修理它?
谢谢