search for: keeprows

Displaying 4 results from an estimated 4 matches for "keeprows".

2011 Apr 24
2
How to erase (replace) certain elements in the data.frame?
Hello R-world, Please, help me to get round my little mess I have a data.frame in which I'd rather like some values to be NA for the future imputation process. I've come up with the following piece of code: random.del <- function (x, n.keeprows, del.percent){ n.items <- ncol(x) k <- n.items*(del.percent/100) x.del <- x for (i in (n.keeprows+1):nrow(x)){ j <- sample(1:n.items, k) x.del[i,j] <- NA } return (x.del) } The problems is that random.del turns out to be slow on huge samples. Is there any other...
2005 Mar 07
1
Faster way of binding multiple rows of data than rbind?
Hi all, I have a vector that contains the row numbers of data taken from several filtering operations performed on a large data frame (20,000rows x 500cols). In order to output this subset of data, I've been looping through the vector containing the row numbers (keepRows). output <- data.frame(row.names = rownames(bigMatrix)) for(i in keepRows) { output <- rbind(output, bigMatrix[i, ]) } As you may guess, doing all of these rbinds takes a LOT of time, so I'm wondering if there's a workaround where I can maybe use an intermediate matrix-like obj...
2010 Jan 14
2
Fixed size permutations
I'm using functions to return a matrix of all permutations of a specified size from a larger list for predictor selection. For each predictor size I use a seperate function like this: bag2 <- function(n) { rl <- c() for (i1 in seq(n)) { for (i2 in seq(n)) { if (length(unique(c(i1,i2)))==1) {next} rl <- cbind(rl,matrix(c(i1,i2))) } }
2009 Jun 16
3
How to subset my dataframe? (a bit tricky)
Hi R-helpers, I would like to subset my dataframe, keeping only those rows which satisfy the following conditions: 1) the string "dnv" is found in at least one column; 2) the value in the column previous to the one "dnv" is found in is not "0" Here's what my data look like: ??? POND_ID 2009-05-07 2009-05-15 2009-05-21 2009-05-28 2009-06-04 4 ? ? ? 101 ? ? ?