-1
此代码将在一个窗口中显示几个图。由于每个图是根据每列X1到X13生成的。所以我想给as a main
添加一个数字,用来绘制这个图的列的名字请看下面区分哪个是。如何为R中的每个图添加标题?
ref= read.table("D:\\AS_asc.txt", sep="",header=TRUE)
sour1 = read.table("D:\\re.txt", sep="",header=TRUE)
sour2= read.table("D:\\_asc.txt", sep="",header=TRUE)
columns <- paste0("X", 1:13)
par(mfrow=c(4,4))
lapply(
columns,
function(column)
{
result1 <- (
mean(ref[[column]]) -
((sd(ref[[column]])/sd(sour1[[column]])) * mean(sour1[[column]])) +
((sd(ref[[column]])/sd(sour1[[column]]) * sour1[[column]]))
) # calculate using ref and sour1
result2 <- ((
mean(ref[[column]]) -
((sd(ref[[column]])/sd(sour2[[column]], na.rm=TRUE)) * mean(sour2[[column]], na.rm=TRUE)) +
((sd(ref[[column]])/sd(sour2[[column]], na.rm=TRUE) * sour2[[column]]))
)) # calculate using ref and sour2
plot(
ref[[column]],
result1,
ylab = "[[column]]",
xlab = "[[column]]",
col = 2
)
points(ref[[column]], ref[[column]], col = 'green')
points(ref[[column]], result2, col = 'blue')
}
)
你就不能添加'主贴=(列)''你的情节()'命令里面? – 2013-03-13 18:54:57
因为好奇心,你可能想要发布一些虚拟数据,并且你会暴露于处理这些任务的ggplot2/lattice方式。警告:没有回头路。 – baptiste 2013-03-13 19:11:54
除了@baptiste所说的之外,你还真想看看'ggplot2',特别是'facet_wrap'和'facet_grid'。刻面是用于创建绘图网格的“ggplot2”专业术语,每个用于一个因子级别(分类变量)。 – 2013-03-13 21:13:52