我试图使用ggplot在一个时间序列中绘制多个趋势线(每十年).
这是数据:
dat <- structure(list(YY = 1961:2010, a = c(98L, 76L, 83L, 89L, 120L,
107L, 83L, 83L, 92L, 104L, 98L, 91L, 81L, 69L, 86L, 76L, 85L,
86L, 70L, 81L, 77L, 89L, 60L, 80L, 94L, 66L, 77L, 85L, 77L, 80L,
79L, 79L, 65L, 70L, 80L, 87L, 84L, 67L, 106L, 129L, 95L, 79L,
67L, 105L, 118L, 85L, 86L, 103L, 97L, 106L)), .Names = c("YY",
"a"), row.names = c(NA, -50L), class = "data.frame")
Run Code Online (Sandbox Code Playgroud)
这是脚本:
p <- ggplot(dat, aes(x = YY))
p <- p …Run Code Online (Sandbox Code Playgroud) 我试图使用ggplot绘制自举样本(1000列),但结果图不正确.
这是数据:
dat<- structure(list(YY = c(1961L, 1961L, 1961L, 1961L, 1961L, 1961L,
1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L,
1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L,
1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L,
1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L,
1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L,
1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L,
1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L, 1961L,
1961L, 1961L, 1961L, 1961L, 1961L, 1961L, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用下面的代码在 R 中绘制月度玫瑰图,但遇到错误:“错误:分面变量必须至少有一个值”
这是我使用的 数据链接到数据
此代码来自上一篇文章:使用 ggplot 的玫瑰图
require(ggplot2)
require(RColorBrewer)
require(scales)
plot.windrose <- function(data,
spd,
dir,
spdres = 2,
dirres = 22.5,
spdmin = 2,
spdmax = 20,
spdseq = NULL,
palette = "YlGnBu",
countmax = NA,
debug = 0){
# Look to see what data was passed in to the function
if (is.numeric(spd) & is.numeric(dir)){
# assume that we've been given vectors of the speed and direction vectors
data <- data.frame(spd = spd,
dir = dir)
spd = …Run Code Online (Sandbox Code Playgroud)