An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20050811/a72f2f50/attachment.pl
access assigned objects
2 messages · Beth Wilmot, Uwe Ligges
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 at 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