-2

When I try to import a text file, Ratings.timed.txt, R says that the input file is ypu and that the data frame is just a long column of undefined, even though I can open and read it just fine. Do you know how I can fix it?

This is what I'm talking about, for clarity.

Edit: I was able to read the file using Ratings.timed <- read.delim("Ratings.timed.txt", fileEncoding="UTF-16LE")

Prradep
  • 5,506
  • 5
  • 43
  • 84
J. Dionisio
  • 159
  • 1
  • 13

1 Answers1

1

Looking at your file it is not really CSV (comma separated) but probably TSV (tab-separated). Because of that, you should rather use read_tsv() function.

Moreover, the file has probably BOM so the first column will get 3 extra symbols at the beginning of the name of the first column. I don't know any better with tidyverse than using rename():

library(tidyverse)

read_tsv('filename.csv') %>%
  rename(userid.ID = colnames(.)[1])
Piotr K
  • 943
  • 9
  • 20
  • Oh, thank you! I'm going to edit the post, but I was also able to read the file using `Ratings.timed <- read.delim("Ratings.timed.txt", fileEncoding="UTF-16LE")` – J. Dionisio Apr 26 '20 at 19:47