r - Memory error despite having ample RAM -


i have 64-bit windows 7 machine 8gb ram. memory.limit() shows 8135. ran memory issue though i'm trying not seem humongous @ (compared other memory-related questions on so).

basically i'm matching firm's id industry. ref.table data frame store id , industry reference.

matchid <- function(id) {   firm.industry <- ref.table$industry[ref.table$id==id]   firm.industry <- as.character(firm.industry[1]) # same id has multiple industries. pick one.   resid <<- c(resid, firm.industry) } resid <- c() invisible( lapply(unmatched.id, matchid) ) # unmatched.id vector of firms' id matched 

the unmatched.id vector 60,000-element long. still got error "cannot allocate vector of 41.8kb size" (only 41.8kb!) windows task manager shows full ram usage @ time.

is because function unwieldy somehow? can't imagine it's vector size causing problems.

(ps: gc() , rm() frequently)

i think you're looking vector of unmatched id's in ref.table$id, , finding corresponding index

## first match, 1 each unmatched.id, na if no match idx <- match(unmatched.id, ref.table$id) ## matching industries resid <- ref.table$industry[idx] 

this 'vectorized' more efficient lapply.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -