SPSS, R notes at CPCDR
- R-project home
- R-projects documents
- R-project modules
- R functions
- use R to read spss *.sav file
>library(foreign) ---- to load spss package.
> p<-read.spss("c:/temp/test.sav", to.data.frame=TRUE) --- sent to object p with frame
> attach(p) ---- attach dataframe
- Clear console
- edit/view object p data content
> edit(p)
- Or, export p data content to screen, use "," to separate
> write.table(p,sep=",")
- Then, and select all to copy and paste into excel
- export datafile and codefile
> datafile<-tempfile()
> codefile<-tempfile()
> write.foreign(p,datafile,codefile,package="SPSS")
> file.show(datafile)
> file.show(codefile)
> unlink(datafile)
> unlink(codefile)