R version 3.3.3 (2017-03-06) -- "Another Canoe"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R es un software libre y viene sin GARANTIA ALGUNA.
Usted puede redistribuirlo bajo ciertas circunstancias.
Escriba 'license()' o 'licence()' para detalles de distribucion.

R es un proyecto colaborativo con muchos contribuyentes.
Escriba 'contributors()' para obtener más información y
'citation()' para saber cómo citar R o paquetes de R en publicaciones.

Escriba 'demo()' para demostraciones, 'help()' para el sistema on-line de ayuda,
o 'help.start()' para abrir el sistema de ayuda HTML con su navegador.
Escriba 'q()' para salir de R.

> if(identical(getOption('pager'), file.path(R.home('bin'), 'pager'))) # rather take the ESS one
+       options(pager='cat')
> options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', show.error.locations=TRUE)
> library(foreign); qqq <- read.spss("espania-qqq.sav",to.data.frame=TRUE)
re-encoding from CP1252
Warning messages:
1: In read.spss("espania-qqq.sav", to.data.frame = TRUE) :
  espania-qqq.sav: Unrecognized record type 7, subtype 18 encountered in system file
2: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels,  :
  duplicated levels in factors are deprecated
3: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels,  :
  duplicated levels in factors are deprecated
4: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels,  :
  duplicated levels in factors are deprecated
5: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels,  :
  duplicated levels in factors are deprecated
6: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels,  :
  duplicated levels in factors are deprecated
7: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels,  :
  duplicated levels in factors are deprecated
> cog <- read.spss("espania-cog.sav",to.data.frame=TRUE)
re-encoding from CP1252
Warning messages:
1: In read.spss("espania-cog.sav", to.data.frame = TRUE) :
  espania-cog.sav: Unrecognized record type 7, subtype 18 encountered in system file
2: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels,  :
  duplicated levels in factors are deprecated
3: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels,  :
  duplicated levels in factors are deprecated
4: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels,  :
  duplicated levels in factors are deprecated
> all(qqq$CNTSTUID==cog$CNTSTUID)
[1] TRUE
> qmath <- grep ("^PV.+MATH$", names(qqq))
> qread <- grep ("^PV.+READ$", names(qqq))
> qscie <- grep ("^PV.+SCIE$", names(qqq))
> cmath <- grep ("^.?M[0-9]{3}Q", names(cog))
> cread <- grep ("^.?R[0-9]{3}Q", names(cog))
> cscie <- grep ("^.?S[0-9]{3}Q", names(cog))
> sdmath <- apply (qqq[qmath], 1, sd)
> sdread <- apply (qqq[qread], 1, sd)
> sdscie <- apply (qqq[qscie], 1, sd)
> stem (sdmath)

  The decimal point is 1 digit(s) to the right of the |

  0 | 7999
  1 | 00000111122222222222222333333333333333333333333444444444444444444444
  1 | 55555555555555555555555555555555555555555555555555555555555666666666+386
  2 | 00000000000000000000000000000000000000000000000000000000000000000000+1012
  2 | 55555555555555555555555555555555555555555555555555555555555555555555+1401
  3 | 00000000000000000000000000000000000000000000000000000000000000000000+1319
  3 | 55555555555555555555555555555555555555555555555555555555555555555555+1049
  4 | 00000000000000000000000000000000000000000000000000000000000000000000+541
  4 | 55555555555555555555555555555555555555555555555555555555555555555555+208
  5 | 00000000000000000000000000000000001111111111111111111111111111111111+43
  5 | 5555555555566666777777777777777788888899999
  6 | 0011111122344
  6 | 5557

> nmath <- apply (cog[cmath], 1, function(fila) sum (!is.na (fila)))
> nread <- apply (cog[cread], 1, function(fila) sum (!is.na (fila)))
> nscie <- apply (cog[cscie], 1, function(fila) sum (!is.na (fila)))
> stem (nmath)

  The decimal point is 1 digit(s) to the right of the |

  0 | 00000000000000000000000000000000000000000000000000000000000000000000+3908
  0 | 8
  1 | 
  1 | 8
  2 | 12223444
  2 | 567799
  3 | 0112222233334444444444
  3 | 55555555555566666666666666666666677777777777777777777777777777777777+98
  4 | 00000000000000000000000000111111111111111111111111111111111111112222+80
  4 | 55555555555555555556666666666666666666666677777777777777777777777777+73
  5 | 0144
  5 | 6666677799
  6 | 000011111222222334444
  6 | 55555555666677777777777777888888888888889999999
  7 | 00000000000001111111111111222222222222222222223333333333333333333334+21
  7 | 55555555555555555555555555555555555555555555555566666666666666666666+352
  8 | 00000000000000000000000000000000000000000000000000000000000000000000+561
  8 | 55555555555555555555555555555555555555555555555555555555555555555555+482
  9 | 00000000000000000000000000000000000000000000000000000000000000000000+250
  9 | 55555555555555555555555555555555555555555555555555555555555555555555

> q()
Save workspace image? [y/n/c]: y

Process R finished at Fri Oct 20 00:15:05 2017