Re: [R] access assigned objects

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Fri 12 Aug 2005 - 16:49:21 EST

Beth Wilmot wrote:
> Dear list,
> I am trying to write a function that will make a matrix of each row of a data frame (4 columns), calculate a fisher.test on each resulting matrix and assign a vector of the p-values. I have gotten through making the matrices, but cannot calculate the fisher.test.
>
> fm<-function(x)
> {dfrow<-nrow(x)
>
> mm <- vector("list", dfrow)
> for(i in 1:dfrow)
> mm[[i]] <- matrix(x[i,],nr=2)

If x is a data.frame, x[1,] is also a data.frame.

Try unlist() at first:

     mm[[i]] <- matrix(unlist(x[i,]),nr=2)

Uwe Ligges

>
> }
>
> I don't know how to access each mm[[i]] as everything I've tried gives me the error that
> "Error in fisher.test(mm[[i]]) : all entries of x must be nonnegative and finite"
>
> All the numbers in the matrices are between 1 and 600.
>
>
> Thanks,
> Beth
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Aug 12 16:56:00 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:15:45 EST