2016-09-14 130 views
0

我想将SAS数据文件(sas7bdat格式)读入R.我尝试过使用sas7bdat软件包,但最终出现错误。将SAS数据文件导入R

CODE:

x <- read.sas7bdat("C:\Users\petas\Desktop\airline.sas7bdat") 

错误:

'\U' used without hex digits in character string starting ""C:\U"

有人可以帮助我?提前致谢。

+0

尝试'library(haven); read_sas(“C:....”)' – akrun

回答

1

尝试使用正斜杠:

x <- read.sas7bdat("C:/Users/petas/Desktop/airline.sas7bdat") 
1

使用haven

install.packages("haven") 
library(haven) 

url <- "C:\\Users\\petas\\Desktop\\airline.sas7bdat" 

x <- read_sas(url) 

If you use windows than you need to use instead "\" use "\\" or Unix/linux style "/" . Easiest will be to use forward slashes so will be compatible in the future with the path of any OS, in your case Error:'\U' used without hex digits in character string starting ""C:\U" is due the use of single backslashes instead double backslashes.

希望它可以帮助发布例子。