Not work how? You need to tell us what kind of errors you see, otherwise, we 
can only guess.

I'd lose the file() construct. It sets up a connection object, which can be 
less than useful when read.table reads the file several time in order to 
decipher the column structure of the file.

So plain

filepath1 <- "/Users/michaelfeher/Documents/R 
Documents/COVID19/20200906-1822-total-cases-jones.data"

should be OK, provided that the file actually exists. In particular, check that 
the space in "R Documents" really is a space and not something that just looks 
like a space (no-break space is a common culprit).

If you can read the file, but it comes out weird, then you need to diddle the 
arguments to read.table, e.g.

> filepath <- "~/tmp/R files/test.data"
> read.table(filepath)
  V1 V2
1  x  y
2  1  2
3  3  7
4  9 13
> read.table(filepath, header=TRUE)
  x  y
1 1  2
2 3  7
3 9 13


-pd


> On 8 Sep 2020, at 00:04 , Mike Feher <mfeher1...@gmail.com> wrote:
> 
> Hi Peter,
> 
> Here is a snippet of the code I was trying to start with:
> 
> filepath1 <- file("/Users/michaelfeher/Documents/R 
> Documents/COVID19/20200906-1822-total-cases-jones.data")
> filepath1
> TotalCasesJones <- read.table(filepath1)
> 
> This definitely did not work for me.
> 
> Mike
> 
> On September 7, 2020 at 3:50:19 AM, peter dalgaard (pda...@gmail.com) wrote:
> 
>> 
>> 
>> > On 7 Sep 2020, at 07:09 , Ken Beath <k...@kjbeath.com.au> wrote: 
>> >  
>> >> On 7 Sep 2020, at 9:31 am, Mike Feher <mfeher1...@gmail.com> wrote: 
>> >  
>> [snip] 
>> >> 4. I tried to read in a set of dummy space-delimited data saved in an 
>> >> absolute path on my computer, but it would not work. I tried something in 
>> >> another path that did not have a subfolder with a space in it (I.e. I 
>> >> plan 
>> >> on storing my data in a folder called “R Documents” or something similar) 
>> >> and that didn’t work either, so I’m still wondering whether or not (a) 
>> >> things have to be in the library location (it seems like you could 
>> >> customize that) and (b) whether R recognizes spaces in file paths. 
>> >>  
>> >  
>> > Try using file.choose() to locate files using a dialog and it will return 
>> > the full name. Spaces shouldn’t matter provided that everything is 
>> > enclosed in quotes. Most people don’t use absolute references. They set 
>> > the working directory and then just use the name of the file. See under 
>> > the Misc menu.  
>> 
>> Also, how do you "read in" the data? Usually, read.table() or somesuch would 
>> be involved, although RStudio has an "Import data" functionality.  
>> 
>> -pd 
>> 
>> --  
>> Peter Dalgaard, Professor, 
>> Center for Statistics, Copenhagen Business School 
>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark 
>> Phone: (+45)38153501 
>> Office: A 4.23 
>> Email: pd....@cbs.dk  Priv: pda...@gmail.com

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd....@cbs.dk  Priv: pda...@gmail.com

_______________________________________________
R-SIG-Mac mailing list
R-SIG-Mac@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Reply via email to