在 Linux 集群上运行 R 脚本

在 Linux 集群上运行 R 脚本

我可以使用 CentOS v.6.2 访问 IBM IDataplex Cluster。如果我想在 R 上运行以下 R 脚本:

library(data.table) library(mgcv) library(reshape2) library(dplyr) 
library(tidyr) library(lubridate) library(DataCombine)

temp_hist <- as.data.table(temp_hist)
humid_hist <- as.data.table(humid_hist)

# Merge
mykey<- c("FIPS", "year","month", "week")
setkeyv(temp_hist, mykey)
setkeyv(humid_hist, mykey)

hist<- merge(temp_hist, humid_hist, by=mykey)

# Min
hist_min <- hist

hist_min$FIPS <- hist_min$year <- hist_min$month <- hist_min$tmax <- hist_min$tmean <- hist_min$hmax <- hist_min$hmean <- NULL

# Adding Factors
hist_min$citycode <- rep(101,nrow(hist_min)) 
hist_min$year <- rep(2010,nrow(hist_min))
hist_min$week <- rep(1,nrow(hist_min)) 
hist_min$lnincome <- rep(10.262,nrow(hist_min))

# Predictions
pred_hist_min <- predict.gam(gam_mean_count_wk, hist_min)

pred_hist_min <- as.data.table(pred_hist_min)
pred_hist_min <- cbind(hist, pred_hist_min)
pred_hist_min$tmax <- pred_hist_min$tmean <- pred_hist_min$tmin <- pred_hist_min$hmax <- pred_hist_min$hmean <- pred_hist_min$hmin <- NULL

# Aggregate by FIPS
min_hist <- pred_hist_min %>%
  group_by(FIPS) %>%
  summarise(pred_hist = mean(pred_hist_min))

如何使用 qsub/bsub 来利用集群的性能(指定核心)来运行此脚本?

相关内容