我有一个名为"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"))
Run Code Online (Sandbox Code Playgroud)
有没有办法可以循环这个,这样我就可以生成21个图形?我真的不想制作"df1","df2",df3"等等,直到"df21"然后将所有名称复制到那几行函数中并且必须做"plotdf1","plotdf2","plotdf3" "等等
如果这个问题令人困惑,请告诉我.
提前致谢!
所以我设置了我的工作目录,一个名为"Ril_1"的文件夹.
setwd("~/Dropbox/Ril_1/")
Run Code Online (Sandbox Code Playgroud)
在此文件夹"Ril_1"中,有两个.R脚本文件,另一个名为"Score"的文件夹和另一个名为"Setup"的文件夹.在"Score"和"Setup"文件夹中,有21个.txt文件,我想输出为21个数据帧的列表,每个.txt文件是一个数据帧.
为了做到这一点,我一直在设置工作目录三次......
setwd("~/Dropbox/Ril_1/")
setwd("~/Dropbox/Ril_1/Score")
#read in .txt files from "Score" file
setwd("~/Dropbox/Ril_1/Setup")
#now read in .txt files from "Setup" file
Run Code Online (Sandbox Code Playgroud)
有没有办法我可以将工作目录设置为"Ril_1"文件夹然后能够读入"Score"和"Setup"文件夹中的数据(输出每个作为21个数据帧的列表)以及两个.R脚本文件?
先感谢您!
我在R中有一个名为A.Data的数据框.
它有8个不同的列:plate,row, col,TOF,EXT,green,red,和yellow.
以下是数据示例.
> head(A.Data)
plate row col TOF EXT green red yellow
1 1 A 12 20 21 2 0 0
2 1 C 12 20 17 0 1 0
3 1 C 11 20 17 0 0 1
4 1 A 10 20 16 1 1 3
5 1 A 10 20 16 0 0 0
6 1 A 10 20 15 0 …Run Code Online (Sandbox Code Playgroud) 我是 R 新手,这是一个非常简单的问题,我似乎无法解决...所以我想制作一个包含 A1~A12、B1~B12、C1~C12、D1~D12、E1 的列表~E12、F1~F12、G1~G12、H1~H12。像下面这样的东西...
[1] "A1" "A2" "A3" "A4" "A5" "A6" "A7" "A8" "A9" "A10" "A11" "A12" "B1" "B2" "B3" "B4" "B5" "B6" "B7" "B8"
[21] "B9" "B10" "B11" "B12" "C1" "C2" "C3" "C4" "C5" "C6" "C7" "C8" "C9" "C10" "C11" "C12" "D1" "D2" "D3" "D4"
[41] "D5" "D6" "D7" "D8" "D9" "D10" "D11" "D12" "E1" "E2" "E3" "E4" "E5" "E6" "E7" "E8" "E9" "E10" "E11" "E12"
[61] "F1" "F2" "F3" "F4" "F5" "F6" "F7" "F8" "F9" "F10" "F11" …Run Code Online (Sandbox Code Playgroud)