在
R中,如何将多行文本文件(包含sql)的内容导入单个字符串?
SELECT TOP 100 setpoint,tph FROM rates
我需要将该文本文件导入到R字符串中,如下所示:
> sqlString [1] "SELECT TOP 100 setpoint,tph FROM rates"
就这样,我可以把它喂给RODBC
> library(RODBC) > myconn<-odbcConnect("RPM") > results<-sqlQuery(myconn,sqlString)
我已经尝试了readLines命令如下,但没有给出RODBC需要的字符串格式.
> filecon<-file("sql.txt","r") > sqlString<-readLines(filecon,warn=FALSE) > sqlString [1] "SELECT TOP 100 " "\t[Reclaim Setpoint Mean (tph)] as setpoint," [3] "\t[Reclaim Rate Mean (tph)] as tphmean " "FROM [Dampier_RC1P].[dbo].[Rates]" >