Sample Question #190 (programming – Matlab or R)
You have a very large dataset. For one of the variables in the dataset — for example, the dataset is from a population of people and the variable of interest is age — you need to create a grouping variable that takes on a discrete value for each range of values of the original variable. For example, ages 0-18 might be group 1, ages 19-25 group 2, etc.
How would you do this in Matlab or R?
(Hint: there’s a slow way and there’s a fast way)
(Comment: what about doing this in other packages or languages such as C++, Gauss, SAS or Stata?)
[Question courtesy of Dr. Charles Qin of ITG]