所以,我有一个相当大的数据集(Dropbox:csv文件),我正在尝试使用它geom_boxplot.以下产生了似乎合理的情节:
require(reshape2)
require(ggplot2)
require(scales)
require(grid)
require(gridExtra)
df <- read.csv("\\Downloads\\boxplot.csv", na.strings = "*")
df$year <- factor(df$year, levels = c(2010,2011,2012,2013,2014), labels = c(2010,2011,2012,2013,2014))
d <- ggplot(data = df, aes(x = year, y = value)) +
geom_boxplot(aes(fill = station)) +
facet_grid(station~.) +
scale_y_continuous(limits = c(0, 15)) +
theme(legend.position = "none"))
d
Run Code Online (Sandbox Code Playgroud)
然而,当你深入挖掘时,问题就会蔓延开来.当我用它们的值标记boxplot medians时,会产生以下图表.
df.m <- aggregate(value~year+station, data = df, FUN = function(x) median(x))
d <- d + geom_text(data = df.m, aes(x = year, y = value, label = value)) …Run Code Online (Sandbox Code Playgroud) 我有几年的数据,我正在尝试使用动物园对象(Dropbox中的.csv).一旦数据被强制转换为动物园对象,我就会收到错误.我在索引中找不到任何重复的内容.
df <- read.csv(choose.files(default = "", caption = "Select data source", multi = FALSE), na.strings="*")
df <- read.zoo(df, format = "%Y/%m/%d %H:%M", regular = TRUE, row.names = FALSE, col.names = TRUE, index.column = 1)
Warning message:
In zoo(rval3, ix) :
some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
Run Code Online (Sandbox Code Playgroud)
我试过了:
sum(duplicated(df$NST_DATI))
Run Code Online (Sandbox Code Playgroud)
但结果是0.
谢谢你的帮助!