[R] Error in evalauating a function

David Winsemius dwinsemius at comcast.net
Wed Aug 31 01:03:28 CEST 2011


On Aug 30, 2011, at 6:49 PM, Debs Majumdar wrote:

> 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?

How can we tell? You have not offered the code that you used to run  
it. The code you offered runs without difficulty (once I change the  
T's to TRUE's, that is).


> 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
>
>
> ______________________________________________
> R-help at 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list