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 <beky@inbox.lv> 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,2)>"00".
> comp strata=2.
> end if.
>
> value labels strata 1 "R 2 "Li" 3 "M" 4 "La".
>
> How can i rewrite it in R code?
> --
> View this message in context:
> http://r.789695.n4.nabble.com/From-SPSS-Syntax-to-R-code-tp3302666p3302666.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>

	[[alternative HTML version deleted]]

