Re: [R] Matching a character in a string

2010-01-25 Thread Fabrice DELENTE
> grep("o", "hello") Thanks, I hadn't noticed R has grep included! -- Fabrice DELENTE __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-projec

[R] Matching a character in a string

2010-01-25 Thread Fabrice DELENTE
charmatch("o", strstplit("hello","")) but it gives NA (why??) Thinking it may be a type problem, I tried > charmatch("o",as.character(strsplit("hello",""))) but it gives NA too (why???) So how can I know if a given string con

Re: [R] R and Limesurvey

2010-01-23 Thread Fabrice DELENTE
> Hmm, does it help if you first set > > names(attributes(data)$variable.labels) <- names(data) Yes, it does, many thanks! I'll take some time later to work out what all these commands mean :^) -- Fabrice DELENTE __ R-help@r-pr

[R] R and Limesurvey

2010-01-23 Thread Fabrice DELENTE
?". How does this work? Thanks for any hint! -- Fabrice DELENTE __ R-help@r-project.org 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, minimal, self-contained, reproducible code.

Re: [R] Counting two factors at the same time

2010-01-22 Thread Fabrice DELENTE
x27;3', '2', '2', '3')) > > lets=="B" > [1] FALSE TRUE FALSE FALSE TRUE FALSE TRUE > > sum(lets=="B" & nums=="2") > [1] 2 Thanks very much, it will save me :^) As I am a beginner

Re: [R] Counting two factors at the same time

2010-01-22 Thread Fabrice DELENTE
> Try this; > > > f <- c( 'A', 'B', 'A', 'C', 'B', 'D', 'B') > > n <- c('1', '2', '2', '3', '2', '2', '3') > > table(paste(f,

[R] Counting two factors at the same time

2010-01-22 Thread Fabrice DELENTE
I tried doing it with loops (looping on one factor for 'B', looking for the corresponding value in the second factor, and incrementing a counter when the corresponding value is '2'), but I didn't succeed, and I know it's not the R-way. Any hint or direction? Thanks. --