[R] subset question

2007-08-27 Thread Kirsten Beyer
I would like to code records in a dataset with a 1 if any of the columns 9-67 contain a particular code, and zero if they don't. I've been working with subset and it seems that something like subset(data, data[9:67]--12345) would work, but I have been unsuccessful so far. It seems like a simple

Re: [R] subset question

2007-08-27 Thread jim holtman
Here is one way of checking to see if a row contains a particular value and setting the contents of a new column: n - 20 # create test data x - data.frame(sample(letters,n),sample(letters,n),sample(letters,n),sample(letters,n)) # add a column indicating if the row contains 'a', 'b' or 'c' x$a -

[R] subset question

2006-12-13 Thread Aimin Yan
I have a data set p1982, its structure is the following Then I take 20 observations from this dataset, and assign to pr. in p1982, p has 1982 levels, in dataset pr, p should have 1 levels. But I do str(pr), it shows that p still has 1982 levels. also for these pr$aa [1] ARG THR ASP CYS

Re: [R] subset question

2006-12-13 Thread Richard M. Heiberger
help([.factor) a - factor(letters[1:5]) a a[1:3] a[1:3, drop=T] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented,