search for: words_mh

Displaying 1 result from an estimated 1 matches for "words_mh".

2011 Aug 29
3
Basic question about re-writing for loop as a function
Hello- Sorry to ask a basic question, but I've spent many hours on this now and seem to be missing something. I have a loop that looks like this: mainmat=data.frame(matrix(data=0, ncol=92, nrow=length(predata$Words_MH))) for(i in 1:length(predata$Words_MH)){ for(j in 1:92){ mainmat[i,j]=ifelse(j %in% as.numeric(unlist(strsplit(predata$Words_MH[i], split=","))), 1, 0) } } What it's doing is creating a matrix with 92 columns, that's the number of different codes, and then...