On 08/30/2011 04:19 PM, Debs Majumdar wrote:
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_st...@yahoo.com>
To: "r-help@r-project.org"<r-help@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))

I see the error if I run the command

  Rplink(PHENO, GENO, CLUSTER, COVAR)

after sourcing the code you provided. I think clm is not implemented correctly; it is looking for 's' in the wrong environment. Help it along by providing an explicit 'data' argument. Also, PHENO is apparently supposed to be a 'factor'. So maybe replace the previous line with...

        df <- data.frame(PHENO=factor(PHENO), s)
        m <- summary(clm(PHENO ~ s, data=df))

Perhaps contact the maintainer of the 'ordinal' package (use packageDescription('ordinal') to report the issue.

Martin

         r<- c(m$coef)
         c( length(r) , r )
       }
      apply( GENO , 2 , f1 )
      }


Thanks,

  Debs

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to