Thomas MORISSEAU
2010-May-17 15:19 UTC
[R] Unable to execute lm function within a Rscript launch in the Linux Terminal
Hello to the list I'm using a Rscript launched via the linux terminal as the title of this mail explains. The following is the code of the Rscript : myRscript.r -------------------------------- 1 #!/usr/bin/Rscript 2 3 #Read data 4 data=read.table("/home/morisseau/stage/recherche/gwas/data/CFHLC5/CFHLC_format_files_rm_07052010/output/windowstemp.txt") 5 6 data=t(data) 7 phen=read.table("/home/morisseau/stage/recherche/gwas/data/CFHLC/CFHLC_format_files_rm_07052010/input/Admixmap_simphen_simu1_causalsnp61.txt") 8 phen=phen[-1] 9 phen=t(phen) 10 val=c(1,2) 11 for (i in 1:dim(data)[2]){ 12 val[1]=data[,i][3] 13 test=chisq.test(phen,data[,i][-(1:4)]) 14 val[2]=test$p.value 15 test=lm(phen~data[,i][-(1:4)]) 16 print (summary(test)) 17 print(val) 18 } ---------------------------------- which call an error : Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : unable to find "is" function Calls: lm ... model.matrix -> model.matrix.default -> contrasts<- Execution stopped But when I execute the same code in a R console with source("myRscript.r") command, all works fine. I'm sure that this is the lm function which entails the error because when I code off the line 15, the R script works fine in the Linux Terminal. Can you help me please? Thank you in advance. Best regards Thomas MORISSEAU