我有一组UNIX时间戳和URI,我试图绘制每个URI的累积请求数.我设法使用虚拟列一次为一个URI执行此操作:
x.df$count <- apply(x.df,1,function(row) 1) # Create a dummy column for cumsum
x.df <- x.df[order(x.df$time, decreasing=FALSE),] # Sort
ggplot(x.df, aes(x=time, y=cumsum(count))) + geom_line()
Run Code Online (Sandbox Code Playgroud)
但是,在我的情况下,这将产生大约30个情节.
ggplot2允许你将多行绘制成一个图(我从这里复制了这段代码):
ggplot(data=test_data_long, aes(x=date, y=value, colour=variable)) +
geom_line()
Run Code Online (Sandbox Code Playgroud)
问题在于,这种方式cumsum()会依赖于此.
有人有想法吗?