简体   繁体   中英

Loading R packages in job script

this is a simple question I am sure, but I have not been able to figure it out. I want to submit a job to a statistical computing center, and I am using a script as follows:

#!/bin/sh 
#PBS -l nodes=1
#PBS -l walltime=1:00:00
module add R/2.14.0
R
packages.install("np")
61
library(np)
packages.install("foreign")
library(foreign)
data<-read.dta("smallsample.dta")

...

Then there are more commands using the np package in R. Note: The 61 line is for the country specific mirror that is requested when installing a package. When I submit the script I immediately get an error for the line containing packages.install("np") . How do I install a package in R? I have tried to replicate exactly what works in an interactive session but I have not been successful.

You have to use install.packages not packages.install . To set the repository you have to use the repos argument. I doubt just entering it like this will work, but not sure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM