今天,我们利用健明老师推荐的批量运行多个R脚本代码,见证一下该代码的优势。首先,下载《Preoperative immune landscape predisposes adverse outcomes in hepatocellular carcinoma patients with liver transplantation》的 GitHub (https://github.com/sangho1130/KOR_HCC) ,我们发现其共包含19个R脚本。然后,我们一个一个打开脚本检查了一下其所用到的R包,下载好所要用到的所有R包。但是在下载R包过程中我们发现RGtk2和rsgcc这两个包一直报错,没有解决掉这个问题。所以,我们把包含这两个包的5个脚本剔除,把剩下的14个R脚本进行批量运行。
#这两个R包下载失败了,如果你们下载成功了,也欢迎分享以下方法!
具体运行过程
#对以下14个包进行批量运行:
代码语言:javascript复制setwd("C:\Users\Lenovo\Desktop\KOR_HCC-main\KOR_HCC-main\code")
fs=list.files('./',pattern = '*.R$')
fs
lapply(fs, function(x){
print(x)
source(x)
})
代码语言:javascript复制
#正常运行结果
[1] "Figure_1A.R"
Coordinate system already present. Adding new coordinate system, which will replace the existing one.
[1] "Figure_1B.R"
[1] "Figure_1C_bottom.R"
[1] "Figure_1C_top.R"
Coordinate system already present. Adding new coordinate system, which will replace the existing one.
[1] "Figure_2A.R"
Using Status as id variables
Saving 6.92 x 6.92 in image
Using Status as id variables
Saving 6.92 x 6.92 in image
[1] "Figure_2B.R"
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
[1] "Figure_2D.R"
[1] "Figure_3.R"
[1] "Figure_3_new.R"
[1] "Figure_4A.R"
i SHA-1 hash of file is "015fc0457e61e3e93a903e69a24d96d2dac7b9fb"
The following `from` values were not present in `x`: Yes
[1] "Figure_4B.R"
[1] "Figure_4D.R"
[1] 0.0002906699
[1] "Figure_6A.R"
Barnard's Unconditional Test
Treatment I Treatment II
Outcome I 10 11
Outcome II 2 11
Null hypothesis: Treatments have no effect on the outcomes
Score statistic = -1.91134
Nuisance parameter = 0.074 (One sided), 0.353 (Two sided)
P-value = 0.0440743 (One sided), 0.0645337 (Two sided)
[1] "Figure_6B.R"
最终,我们就可以得到所有的结果文件: