examdata <- RCurl::getURL("https://raw.githubusercontent.com/jrwolf/IT497/master/spendingdata.txt")
examdata2 <- read.table(textConnection(examdata), sep = ",", header = T)
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
na.strings, : line 1 did not have 2 elements
Best Solution
Looks like you just need to skip a few lines. I used
readLines(textConnection(examdata))
to determine where the actual data table began. Turns out it starts on the 32nd line. Therefore we can use theskip
argument inread.csv
to skip the first 31 lines. I used thestrip.white
argument because there seems to be some erroneous whitespace in the table.Since you'll probably want those numbers to be numeric, you'll need to remove the
$
sign and convert the columns to numeric so you'll be able to use them for any calculations you may do later.Now all the columns except the first are numeric.