Re: [R] Retrieving the context

2009-04-02 Thread Uwe Ligges
Example: see_context <- function(word, data, context) { dat <- data$strings temp <- grep(paste("^", word, "$", sep=""), dat) if(length(temp)) index <- lapply(temp, function(x) seq(max(0, x - context), min(x + context, length(dat sapply(index, function(x) paste(dat[x]

[R] Retrieving the context

2009-03-30 Thread Fredrik Karlsson
Dear list, I have a general problem that I really don't know how to solve efficiently in R. Lets say we have a sequence of things, like for instance a string of words, that is stored in a file. We need all the words in a table format, so therefore we create an id for the word, that links the word