Errors, driving me nuts
Hi Matt,
On Mon, Aug 1, 2011 at 4:47 PM, Matt Curcio <matt.curcio.ri at gmail.com> wrote:
Greetings all, I am getting this error that is driving me nuts... (not a long trip, haha) I have a set of files and in these files I want to calculate ttests on rows 'compareA' and 'compareB' (these will change over time there I want a variable here). Also these files are in many different directories so I want a way filter out the junk... ?Anyway I don't believe that this is related to my errors but I mention it none the less.
files_to_test <- list.files (pattern = "kegg.combine")
for (i in 1:length (files_to_test)) {
+ ? ?raw_data <- read.table (files_to_test[i], header=TRUE, sep=" ") + ? ?tmpA <- raw_data[,compareA] + ? ?tmpB <- raw_data[,compareB] + ? ?tt <- t.test (tmpA, tmpB, var.equal=TRUE) + ? ?tt_pvalue[i] <- tt$p.value + } Error in tt_pvalue[i] <- tt$p.value : object 'tt_pvalue' not found # I tried setting up a vector... # as.vector(tt_pvalue, mode="any") ### but NO GO
file.name = paste("ttest.results.", compareA, compareB, "")
setwd(save_to)
write.table(tt_pvalue, file=file.name, sep="\t" )
Error in inherits(x, "data.frame") : object 'tt_pvalue' not found # No idea??
you need to create tt_pvalue before you can assign values to it (i.e., before you start your for-loop). Consider this simpler example: tst[1] <- 1 Error in tst[1] <- 1 : object 'tst' not found tst <- vector() tst[1] <- 1 Best, Ista
What is going wrong?? M Matt Curcio M: 401-316-5358 E: matt.curcio.ri at gmail.com
______________________________________________ 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.
Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org