How to read in a text file to R using textConnection and library(sqldf)

后端 未结 3 729
独厮守ぢ
独厮守ぢ 2021-01-06 17:12

I\'m trying to read a text file into R so I can use the sqldf functions. I\'m following this example, https://stat.ethz.ch/pipermail/r-help/2008-January/152040.html, but I

3条回答
  •  别那么骄傲
    2021-01-06 17:48

    Aniko's comment has almost all you need (along with header=TRUE):

    R> data <- read.table("test.table.1.0", header=TRUE)
    R> data
      id Source
    1  1    A10
    2  2    A32
    3  3    A10
    4  4    A25
    R> 
    

    In other words, if you have the data in a file, read from a file. A textConnection is useful if and when you have the data 'right there' along with the command as in the email you referenced.

提交回复
热议问题