R 从数据帧列表生成多个绘图
我有一个名为“proc.r1”的21个不同数据帧的列表 我试图制作21个图表,每个图表都使用列表中每个数据框的数据 下面我所做的只适用于列表中的第一个数据帧。我为“plotdf1”编写的ggplot是我需要从每个数据帧生成的图形。所以我需要21个外观相同的“plotdf1”,除了每个都会显示来自不同数据帧的数据R 从数据帧列表生成多个绘图,r,list,ggplot2,R,List,Ggplot2,我有一个名为“proc.r1”的21个不同数据帧的列表 我试图制作21个图表,每个图表都使用列表中每个数据框的数据 下面我所做的只适用于列表中的第一个数据帧。我为“plotdf1”编写的ggplot是我需要从每个数据帧生成的图形。所以我需要21个外观相同的“plotdf1”,除了每个都会显示来自不同数据帧的数据 #making the first data frame in the "proc.r1" list as a separate data frame df1 <-
#making the first data frame in the "proc.r1" list as a separate data frame
df1 <- as.data.frame(proc.r1 [[1]])
#making all the NA values displayed as 0
df1[is.na(df1)] <- 0
#rounding off the "norm.n" column, which I'll use as a label in the plot, to just 1 decimal point
df1 [,42] <- round(df1[,42],1)
plotdf1 <- ggplot(df1)+geom_rect(aes(xmin=0,xmax=5,ymin=0,ymax=5))+facet_grid(row~col)+geom_text(aes(x=2.5,y=2.5,label=norm.n,colour="white"))
#将“proc.r1”列表中的第一个数据帧作为单独的数据帧
df1它相对简单:
for(i in 1:length(proc.r1)
{
df1 = as.data.frame(proc.r1[[i]])
df1[is.na(df1)] <- 0
df1[,42] <- round(df1[,42],1)
plotdf1 <- ggplot(df1)+geom_rect(aes(xmin=0,xmax=5,ymin=0,ymax=5))+
facet_grid(row~col)+geom_text(aes(x=2.5,y=2.5,label=norm.n,colour="white"))
print(plotdf1)
}
for(1中的i:length(过程r1)
{
df1=as.data.frame(进程r1[[i]]
df1[is.na(df1)]