You defined temp as a vector: > temp <- vector(mode="numeric", length = vl)
but you try to extract from it as if it was a 2d object: colA <- temp[,compareA] Maybe you meant to use temp1 instead? More meaningful variable names might help avoid such mistakes. On Wed, Aug 3, 2011 at 6:14 PM, Matt Curcio <[email protected]>wrote: > Greetings all, > I am getting an error message that is stifling me. > Any ideas? > > > ## Define Directories ## > > load_from <- "/home/mcc/Dropbox/abrodsky/kegg_combine_data/" > > save_to <- "/home/mcc/Dropbox/abrodsky/ttest_results/" > > > > ############################### > > ## Define Columns To Compare ## > > compareA <- "log_b_rich" > > compareB <- "Fc_cdt_rich_tot" > > > > ################################ > > ## Collect Files To Compare ## > > setwd(load_from) > > files_to_test <- list.files(pattern = "combine.kegg") > > > > ########################## > > ## Initialize Variables ## > > vl <- length(files_to_test) > > temp <- vector(mode="numeric", length = vl) > > colA <- vector(mode="numeric", length = vl) > > colB <- vector(mode="numeric", length = vl) > > tt <- vector(mode="numeric", length = vl) > > > > > > ######################## > > ## Calculate P-values ## > > for (i in 1:3){ > + temp1 <- read.table(files_to_test[i], header=TRUE, sep=" ") > + numrows <- nrow(temp1) > + tt_pvalue <- matrix(data=temp, nrow=numrows, ncol=vl) > + colA <- temp[,compareA] > + colB <- temp[,compareB] > + tt <- t.test(colA, colB, var.equal=TRUE) > + tt_pvalue <- tt$p.value > + } > Error in temp[, compareA] : incorrect number of dimensions > > -- > > > Matt Curcio > M: 401-316-5358 > E: [email protected] > > ______________________________________________ > [email protected] 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. > [[alternative HTML version deleted]] ______________________________________________ [email protected] 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.

