Rscript后台运行
- nohup Rscript scRNA.R > my_log.out 2>&1 &
scRNA.R 如下:
######## Load necessary library
library(dplyr)
######## Read the data from a CSV file
data <- read.csv("input.csv")
######## Calculate the mean and standard deviation of each numeric column
stats <- data %>%
summarise_all(list(mean = mean, sd = sd), na.rm = TRUE)
######## Write the results to a new CSV file
write.csv(stats, "output.csv")
- 增加命令行参数
nohup Rscript scRNA2.R input.csv output.csv > my_log.out 2>&1 &
scRNA2.R 如下:
######## Load necessary library
library(dplyr)
######## Get the command line arguments
args <- commandArgs(trailingOnly = TRUE)
######## Read the data from the input CSV file
data <- read.csv(args[1])
######## Calculate the mean and standard deviation of each numeric column
stats <- data %>%
summarise_all(list(mean = mean, sd = sd), na.rm = TRUE)
######## Write the results to the output CSV file
write.csv(stats, args[2])
#######--args[1]是输入文件的名称,args[2]是输出文件的名称