本文介绍了R中同一图上的频率和累积频率曲线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 有没有一种方法(用ggplot或其他方法)在单列(两行)中绘制频率和累积频率曲线,即一个顶部或另一个顶点,以便可以使用直线在两条曲线上显示给定的四分位数行呢?我希望我明白这一点。 您可以使用这些数据。 mydata< -structure(list(speed = c(10,15,20,25,30,35,40,45,50),频率= c(0,1,5,10,20,10,6,3,0)),NAME = c( 速度,频率),row.names = c(NA,-9L),class =data.frame) library(ggplot2) qplot(data = mydata,x = speed,y = frequency, geom = c(point,line))+ geom_line(aes(y = cumsum(frequency))) 或 频率栏 mydata $ sum.freq< -wit h(mydata,cumsum(频率)) library(reshape) qplot(data = melt(mydata,id.vars =speed),x = speed,y = value, geom = c(point,line),facets = variable〜。) Is there a way (in R with ggplot or otherwise) to draw frequency and cumulative frequency curves in a single column (two rows) i.e. one top of the other such that a given quartile can be shown on both the curves using straight lines? I hope I am clear on this..You may use this data..mydata<-structure(list(speed = c(10, 15, 20, 25, 30, 35, 40, 45, 50),frequency = c(0, 1, 5, 10, 20, 10, 6, 3, 0)), .Names = c("speed","frequency"), row.names = c(NA, -9L), class = "data.frame") 解决方案 mydata<-structure(list(speed = c(10, 15, 20, 25, 30, 35, 40, 45, 50),frequency = c(0, 1, 5, 10, 20, 10, 6, 3, 0)), .Names = c("speed","frequency"), row.names = c(NA, -9L), class = "data.frame")library(ggplot2)qplot(data=mydata, x=speed, y=frequency, geom=c("point", "line"))+ geom_line(aes(y=cumsum(frequency)))orAdd a cumulative frequency columnmydata$sum.freq<-with(mydata, cumsum(frequency))library(reshape)qplot(data=melt(mydata, id.vars="speed"), x=speed, y=value, geom=c("point", "line"), facets=variable~.) 这篇关于R中同一图上的频率和累积频率曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-27 07:27