将SAS数据文件导入R
问题描述:
我想将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"
有人可以帮助我?提前致谢。
答
尝试使用正斜杠:
x <- read.sas7bdat("C:/Users/petas/Desktop/airline.sas7bdat")
答
使用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 useforward 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.
希望它可以帮助发布例子。
尝试'library(haven); read_sas(“C:....”)' – akrun