user2056257
user2056257

Reputation: 141

Error reading table into R

I am trying to read this file into an R dataframe but keep getting errors.

This is the command I am using

data <- read.csv("TrainExer 3-1-corrected.txt", sep='\t', colClasses = "numeric")

I get the following error

Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : scan() expected 'a real', got '1229.2316.200'

If I don't specify colClasses, I don't get any error, but the table merges some entries from different columns. For example, 1229.23 is one entry in one column and 16.200 is another entry in the adjacent column. Somehow R is trying to read them as one.

Upvotes: 0

Views: 309

Answers (1)

user14353
user14353

Reputation: 135

You probably should be using read.table instead, since you're not loading in a csv. This might work: data <- read.table("TrainExer 3-1-corrected.txt", header = TRUE)

Upvotes: 2

Related Questions