[R] Error in evalauating a function

Debs Majumdar debs_stata at yahoo.com
Wed Aug 31 01:19:42 CEST 2011


Here's the plik code I ran:

plink --bfile olr_try1 --pheno p3.txt --pheno-name dnum --covar p3.txt --covar-name a4 --missing-phenotype -9 --R olr2.R

The below function is contained in the olr2.R script.

The data which I input is contained in the binary file named olr_try1.
The response variable (PHENO) and the covariate (COVAR) is contained in the file p3.txt.

I added the option --R-debug to get the output below.

 Thanks,

 Debs




----- Original Message -----
From: Debs Majumdar <debs_stata at yahoo.com>
To: "r-help at r-project.org" <r-help at r-project.org>
Cc: 
Sent: Tuesday, August 30, 2011 3:49 PM
Subject: Error in evalauating a function

Hi, 


  I am very new to R. So, pardon my dumb question. I was trying to write my own function to run a different model (perform an ordered logistic regression) using the example in website http://pngu.mgh.harvard.edu/~purcell/plink/rfunc.shtml

But R returns a error `R Error in eval(expr, envir, enclos) : object 's' not found' when I run it. What am I doing wrong here? Here's what I got from the debug file.

# Input data

n <- 10
PHENO <- c( 1, 3, 2, 3, 1, 1, 1, 2, 1, 2 ) 
c <- c( 1, 1, 0, 0, 0, 0, 0, 1, 0, 0 ) 
COVAR <- matrix( c , nrow = n , byrow=T)
CLUSTER <- c( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) 
l <- 22
g <- c( 0, 1, 1, 0, 0, 0, 1, 0, 2, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 2, 0, 0, 0, 2, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, -1, -1, 1, 0, 0, 1, 1, -1, 1, 0, 1, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 2, 0, 1, 0, 0, 1, 0, 1, 0, 1, 2, 0, 1, 1, 0, 1, 0, 2, 1, 0, 0, 0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, -1, -1, 0, 1, 0, 0, 0, 2, 0, 1, 0, 0, 0, 2, 0, 1, 1, 2, 0, 0, 1, 0, 1, -1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 2, 0, 0, 0, 1, 1, 1, 0, 0 )
GENO <- matrix( g , nrow = n ,byrow=T)
GENO[GENO == -1 ] <- NA 


# Function

library(ordinal)
     Rplink <- function(PHENO,GENO,CLUSTER,COVAR)
     {
      f1 <- function(s) 
      {
        m <- summary(clm(PHENO ~ s))
        r <- c(m$coef)
        c( length(r) , r )
      }
     apply( GENO , 2 , f1 )
     }


Thanks,

 Debs



More information about the R-help mailing list