I have a rectangular data file, where one variable is a column of quoted character vectors. This variable will need to be further broken into a list of substrings, split by some delimiter. It is in the data file this way because for each observation (each subject/each row), they may have any amount of these substrings. In PHP, there is a function called explode that splits a string into an array of substrings, based on some delimiter. In R, strsplit accomplishes the same thing.
A person on the R-Help list wanted to find the mean of each group, based on ID. Their data looked like:
data<-data.frame(ID=rep(letters[1:4], 5), size=runif(20))
The person was trying to write a for loop, as most people generally do when first encountering R (I sure did), but as is the case with most procedures in R, what can be done with a for loop in other languages, can be done looplessly in R.
This question was posed on R-Help; for the following data, "I would like to perform a simple matching but only row 1 compared to row 1, row 2 compared to row 2 (paired).......giving back a number as dissimilarity for each comparison."
This question hit the R-help mailing list:
"I'm having trouble using the 'apply' function to multiply some arrays. Let A be a 500x2 array and B a 500x3 array. I need a vector C which has 6 columns being the first three the result of A[,1] * B and the second three the result of A[,2] * B. What is the most efficient way to express that? I'm trying to use 'apply' with no success..."