Re: [R] From SPSS Syntax to R code

2011-02-13 Thread John
On Saturday, February 12, 2011 05:08:06 am beky wrote: > There is a code from SPSS Syntax > > do if sub(ATVK,2,2)="01". > comp strata=1. > else if sub(ATVK,2,2)>="05" and sub(ATVK,2,2)<="27". > comp strata=3. > else if sub(ATVK,4,2)>"20" or sub(ATVK,6,2)>"20". > comp strata=4. > else if sub(ATVK,4

Re: [R] From SPSS Syntax to R code

2011-02-13 Thread Sascha Vieweg
On 11-02-12 05:08, beky wrote: There is a code from SPSS Syntax do if sub(ATVK,2,2)="01". comp strata=1. else if sub(ATVK,2,2)>="05" and sub(ATVK,2,2)<="27". comp strata=3. else if sub(ATVK,4,2)>"20" or sub(ATVK,6,2)>"20". comp strata=4. Note that your first statement is overwritten by the on

Re: [R] From SPSS Syntax to R code

2011-02-12 Thread Daróczi Gergely
Hi, instead of sub, use substr in R, also look for 'which' and 'factor' in the manual. E.g.: ?substr ?which > ?factor I hope this could help you to rewrite the SPSS syntax in R. Good luck! Best, Gergely On Sat, Feb 12, 2011 at 2:08 PM, beky wrote: > > There is a code from SPSS Syntax > >

Re: [R] From SPSS Syntax to R code

2011-02-12 Thread Pete Brecknock
You might want to take a look at Bob Muenchen's book "R for SAS and SPSS Users" There is an 80 page preview at .. http://rforsasandspssusers.com/ Additionally, there is lots of documentation for getting started with R on the CRAN website http://cran.r-project.org/ HTH Pete -- Vi

[R] From SPSS Syntax to R code

2011-02-12 Thread beky
There is a code from SPSS Syntax do if sub(ATVK,2,2)="01". comp strata=1. else if sub(ATVK,2,2)>="05" and sub(ATVK,2,2)<="27". comp strata=3. else if sub(ATVK,4,2)>"20" or sub(ATVK,6,2)>"20". comp strata=4. else if sub(ATVK,4,2)>"00". comp strata=2. end if. value labels strata 1 "R 2 "Li" 3 "M"