2.4.x

London Investment Mortgage Loan Information

No votes yet

London Investment Mortgage Loan Information

Read more

Explode character vector into a list

No votes yet

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.

Read more

Means for each level of a factor

Average: 5 (1 vote)

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.

Read more

Remove all objects in the working environment

No votes yet

This is in the help files for rm, but for non-unix-ians, it seems to be hard to remember. Normally, if I am testing code that should stand on it's own, perhaps that I'll send off to the R-help list or put on here, I'll run this before I send it off:

rm(list=ls())

Read more

Row-by-row dissimilarity measure

No votes yet

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."

Read more

Non-conformable matrix multiplication

No votes yet

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..."

Read more

Syndicate content