[R] alternative to ifelse

2013-06-19 Thread Brian Perron
Greetings: I am looking for a way to avoid using the ifelse function for constructing a new variable. More specifically, assume I have a set of variables with scores ranging from 1 to 30. set.seed(12345) x <- c(1:30) x1 <- sample(x, 15, replace = TRUE) x2 <- sample(x, 15, replace = TRUE) x3 <- s

[R] Selecting values

2007-09-28 Thread Brian Perron
Hello all, An elementary question that I am sure can be easily cracked by an R enthusiast. Let's say I have multiple scores (y) on subjects (x.sample). Some subjects have a few more scores than others. Can somebody suggest some code that will select the first score for each subject? For example