Re: [R] how to count occurrences of string?

2009-09-21 Thread Stefan Th. Gries
This should do what you want: set.seed(1) # cerating a vector with comments, in which d's will be counted comments<-character(25) for (i in 1:25) { comments[i] <- paste(sample(letters[1:10], 10, replace=T), collapse="") } # creating a vector to cross -tabulate age <-sample(c("old", "young"), 2

Re: [R] how to count occurrences of string?

2009-09-20 Thread Daniel Malter
ng),gender) Hope that helps, Daniel - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von w_poet Gesendet: Sunday, September 20, 2009 11:58 AM An: r-help@r-project.org Betreff: [R] how to co

[R] how to count occurrences of string?

2009-09-20 Thread w_poet
Hi everyone, I have an array with a variable called comments. I wish to count the number of subjects whose post-experiment comments contain a string x and then cross tab this with other variables of interest, ex. age. Does anyone have any suggestions on how to count unique occurrences of a string