R 数据读取与写入

路径

getwd() #获取当前工作路径
setwd() #设置工作路径

获取普通文本数据

x = read.table("data.txt")  #通过路径直接获取
x = read.table("clipboard") #通过剪切板
x = read.csv("data.csv") #获取CSV文件

写入文本数据

write.table()  #写入txt文件
write.csv()  #写入csv文件

获取常用统计格式数据 SPSS STATA SAS

library(haven) #加载 haven 包

R读取、写入STATA软件 DTA文件

x = read_stata() 
x = read_dta() 
write_dta()

R读取SPSS软件 .sav .zsav .por文件,写入.sav .zsav 文件

x = read_spss() 
x = read_sav() 
write_sav()
x = read_por() 

R读取、写入SAS软件 SAS文件

x = read_sas() 
write_sas()
x = read_xpt() 
write_xpt() 
原文地址:https://www.cnblogs.com/drliu/p/12939924.html