Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 从数据帧列表生成多个绘图_R_List_Ggplot2 - Fatal编程技术网

R 从数据帧列表生成多个绘图

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 <-

我有一个名为“proc.r1”的21个不同数据帧的列表

我试图制作21个图表,每个图表都使用列表中每个数据框的数据

下面我所做的只适用于列表中的第一个数据帧。我为“plotdf1”编写的ggplot是我需要从每个数据帧生成的图形。所以我需要21个外观相同的“plotdf1”,除了每个都会显示来自不同数据帧的数据

    #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)]