I am trying to read a txt file into R environment. I do not understand what is the problem with it and why I cannot read the txt into columns. Can someone explain to me what is the actual problem here? Because that will enable me to search properly on internet. But first I have to understand the issue of it.
This is the type of data I have.
structure(list(dateRep.day.month.year.cases.deaths.countriesAndTerritories.geoId.countryterritoryCode.popData2018.continentExp = c("01/06/2020,1,6,2020,680,8,Afghanistan,AF,AFG,37172386,Asia",
"31/05/2020,31,5,2020,866,3,Afghanistan,AF,AFG,37172386,Asia",
"30/05/2020,30,5,2020,623,11,Afghanistan,AF,AFG,37172386,Asia",
"29/05/2020,29,5,2020,580,8,Afghanistan,AF,AFG,37172386,Asia",
"28/05/2020,28,5,2020,625,7,Afghanistan,AF,AFG,37172386,Asia",
"27/05/2020,27,5,2020,658,1,Afghanistan,AF,AFG,37172386,Asia"
)), row.names = c(NA, 6L), class = "data.frame")
I have tried to read this table into R with this code:
test <- read.delim("download.txt", header = TRUE, sep = "\t")
And this code:
read.table(download.txt, header = TRUE, sep = ",")
Is there a tidyverse way of reading the txt file with separated columns?
I suspect the issue was that download.txt
should have been "download.txt"
in the last line you wrote. Your data is comma-separated, so you can use read.table("download.txt", header = TRUE, sep = ",")
, or, simply read.csv("download.txt")
with default arguments.