- Hands-On Data Science with Anaconda
- Dr. Yuxing Yan James Yan
- 170字
- 2021-06-25 21:08:51
Introduction to the haven and foreign R packages
The R package called haven is for import and export from SPSS, Stata and SAS files. The package is for Labelled Data Utility Functions, which is a collection of many small functions dealing with labelled data, such as reading and writing data between R and other statistical software packages such as SAS, SPSS, or Stata, and working with labelled data.
This includes easy ways to get, set, and change value and variable label attributes, convert labelled vectors into factors or numeric values (and vice versa), and deal with multiple declared missing values. The following example is about writing several specific outputs:
library(haven)
x<-1:100
y<-matrix(x,50,2)
z<-data.frame(y)
colnames(z)<-c("a","b")
write_sas(z,"c:/temp/tt.sas7bdat")
write_spss(z,"c:/temp/tt.sav")
write_stata(z,"c:/temp/tt.dta")
Another R package called foreign can be used to read SPSS, and SAS data. Here is one example. First, let's download a SPSS dataset called airline_passanges.sav at http://calcnet.mth.cmich.edu/org/spss/Prj_airlinePassengers.htm. Assume that the related SPCC data is saved under c:/temp:
library(foreign) x<-read.spss("c:/temp/airline_passengers.sav", to.data.frame=TRUE) dim(x) [1] 144 1
- Splunk 7 Essentials(Third Edition)
- 輕松學(xué)C#
- 基于LabWindows/CVI的虛擬儀器設(shè)計(jì)與應(yīng)用
- Dreamweaver 8中文版商業(yè)案例精粹
- 視覺(jué)檢測(cè)技術(shù)及智能計(jì)算
- 氣動(dòng)系統(tǒng)裝調(diào)與PLC控制
- 單片機(jī)C語(yǔ)言程序設(shè)計(jì)完全自學(xué)手冊(cè)
- 零起點(diǎn)學(xué)西門子S7-200 PLC
- 基于神經(jīng)網(wǎng)絡(luò)的監(jiān)督和半監(jiān)督學(xué)習(xí)方法與遙感圖像智能解譯
- 啊哈C!思考快你一步
- 簡(jiǎn)明學(xué)中文版Photoshop
- 數(shù)字多媒體技術(shù)基礎(chǔ)
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)實(shí)訓(xùn)(職業(yè)模塊)
- Learn Microsoft Azure
- 電氣控制及Micro800 PLC程序設(shè)計(jì)