The file you are accessing comes in a rather messy format - there is a lenghty introductory text on lines 1 to 69, then two lines of column headers and only then the actual data; columns seem to be separated by white spaces.
I suggest the following steps:
- download the file via cURL (it is always easier to troubleshoot import of a local file)
- read in the file via readr, skipping the header, as a single column data frame
- separate the actual columns via
tidyr::separate()
library(tidyverse)
local_file <- tempfile(fileext = ".txt")
curl::curl_download(url = "ftp://aftp.cmdl.noaa.gov/products/trends/co2/co2_mm_mlo.txt",
destfile = local_file)
local_dataframe <- readr::read_tsv(local_file, skip = 72, col_names = F) %>%
tidyr::separate(col = X1,
into = c("year", "month", "decimal_date", "average", "interpolated", "trend", "no_days"),
sep = "[^[\\d+\\.?\\d*$]]+")