所以,我有一个相当大的数据集(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) 我对R非常陌生,正在寻找重建Excel VBA宏和Excel工作表函数(如SUMIFS)的方法.如果行的条目与其他列上的多个条件匹配,则SUMIFS会对列求和.
我有以下数据框,我想计算一个新列.新列是Sample与Start Date和EndDate范围重叠的所有行的总和.例如,在线1它将是697(第一个的总和3 lines).具体的标准是:包括SampleifEndDate >= StartDate[i] & StartDate <=EndDate[i]
StartDate EndDate Sample *SUMIFS example*
10/01/14 24/01/14 139 *697*
12/01/14 26/01/14 136
19/01/14 02/02/14 422
25/01/14 08/02/14 762
29/01/14 12/02/14 899
05/02/14 19/02/14 850
07/02/14 21/02/14 602
09/02/14 23/02/14 180
18/02/14 04/03/14 866
Run Code Online (Sandbox Code Playgroud)
任何评论或指示将不胜感激.
如果存在于使用python 2.7的目录中,如何删除文件os / app?
我试过了
os.remove('directory/file.png')
Run Code Online (Sandbox Code Playgroud)
但如果该项目不存在,我有一个错误.
我有以下简单的线图,其中的丝带表示沿 y 轴的感兴趣阈值。
library(ggplot2)
main.df <- data.frame(time = c(1:20, 1:20),
level = runif(40),
type = c(rep('A', 20), rep('B', 20)))
gg <- ggplot(main.df, aes(x = time, y = level, colour = type))
gg + geom_ribbon(ymin = 0.1, ymax = 0.25, fill = 'green') +
geom_ribbon(ymin = 0.25, ymax = 0.5, fill = 'yellow') +
geom_ribbon(ymin = 0.5, ymax = 0.95, fill = 'red') +
geom_line()
Run Code Online (Sandbox Code Playgroud)
我做了很多尝试来设置 的data属性,geom_ribbon以给我更大的灵活性并清理我的代码。这是一个这样的例子。
rib.df <- data.frame(low = c(0.1, 0.25, 0.5), high = c(0.25, …Run Code Online (Sandbox Code Playgroud)