file path on R studio Mac for read.table

siameseneko picture siameseneko · Feb 17, 2018 · Viewed 11.8k times · Source

Sorry for the very basic question, but I have trouble importing a text file into R Studio on my mac.

I'm trying to do multiple linear regression on this set of data that looks like this:

HDL,TCC,SPB
47,287,0
38,236,0
47,255,0
......

When I use file > import data set > from CSV, the resulting column won't allow me to the the lm() function, or at least I don't know how to use it.

When I use read.table(~/Desktop/HW.txt), it shows:

Error: unexpected '/' in "read.table(~/"

When I use read.table(/Users/yifeiwang/Desktop/HW2.txt), it shows:

Error: unexpected '/' in "read.table(/" 

How can I fix this or how can I import my text file in a matrix form?

Answer