Re: [R-SIG-Mac] How to find the path for a file to be read with read.table() in a Mac
Even better is to learn one of the many ways to start R in a working directory of your choice, so you don't have to mix code and data from different projects together in one directory just because that happens to be where your default R icon sets it up. Some ways: a) Use Terminal and the cd command before invoking R. b) Create a .RData file with nothing in it in the desired directory. Double-click that to automatically set the working directory there in R. c) Use RStudio, which lets you create an Rproj file that serves the same purpose as the .RData file but doesn't risk injecting broken code or old data into your working environment. On February 13, 2021 8:02:54 AM PST, "Parkhurst, David F." wrote: >Ah. That will simplify the process a lot! > >From: Duncan Murdoch >Date: Saturday, February 13, 2021 at 10:52 AM >To: Parkhurst, David F. , r-sig-mac@r-project.org > >Subject: Re: [R-SIG-Mac] How to find the path for a file to be read >with read.table() in a Mac >On 13/02/2021 10:42 a.m., Parkhurst, David F. wrote: >> I�ve several times to figure this out with no luck. I�ve moved a tab >delimited text file (created from excel) to the desktop to simplify the >path. If I click on the file and ask Get Info, it lists �Where� as >iCloud Drive > Desktop. If I copy that to the clipboard and paste that >into a read.table command in the R console, it comes up as >/Users/DFP/Desktop. But if I try >read.table("\\Users\\DFP\\Desktop\\moabsitechem"), >I get No such file or directory. How can I get that file into a data >frame? >> >> Is there some place in my Mac that I can put the file so I could >enter just the file name, and not the whole path? > >Sorry, forget to answer your actual question: > >You can use getwd() to find the working directory. If you put the file >there, you won't need to specify the path. > >Duncan Murdoch > > [[alternative HTML version deleted]] -- Sent from my phone. Please excuse my brevity. ___ R-SIG-Mac mailing list R-SIG-Mac@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac
Re: [R-SIG-Mac] How to find the path for a file to be read with read.table() in a Mac
You can also point R to the directory where the file of interest is, rather than moving the file to the directory where R is currently pointing. setwd(“~/Desktop”) Bryan > On Feb 13, 2021, at 9:02 AM, Parkhurst, David F. wrote: > > Thank you. I thought I�d seen in some book that in a Mac, one had to specify > paths in the way I tried. > > From: Duncan Murdoch > Date: Saturday, February 13, 2021 at 10:49 AM > To: Parkhurst, David F. , r-sig-mac@r-project.org > > Subject: Re: [R-SIG-Mac] How to find the path for a file to be read with > read.table() in a Mac > On 13/02/2021 10:42 a.m., Parkhurst, David F. wrote: >> I�ve several times to figure this out with no luck. I�ve moved a tab >> delimited text file (created from excel) to the desktop to simplify the >> path. If I click on the file and ask Get Info, it lists �Where� as iCloud >> Drive > Desktop. If I copy that to the clipboard and paste that into a >> read.table command in the R console, it comes up as /Users/DFP/Desktop. But >> if I try >> read.table("\\Users\\DFP\\Desktop\\moabsitechem"), >> I get No such file or directory. How can I get that file into a data frame? >> >> Is there some place in my Mac that I can put the file so I could enter just >> the file name, and not the whole path? > > It doesn't make sense to use backslashes in the path: macOS will see > those as part of the name, not as path separators. Just use > read.table("/Users/DFP/Desktop/moabsitechm") if that's the filename. > > Duncan Murdoch > > > [[alternative HTML version deleted]] > > ___ > R-SIG-Mac mailing list > R-SIG-Mac@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-mac ___ R-SIG-Mac mailing list R-SIG-Mac@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac
Re: [R-SIG-Mac] How to find the path for a file to be read with read.table() in a Mac
Ah. That will simplify the process a lot! From: Duncan Murdoch Date: Saturday, February 13, 2021 at 10:52 AM To: Parkhurst, David F. , r-sig-mac@r-project.org Subject: Re: [R-SIG-Mac] How to find the path for a file to be read with read.table() in a Mac On 13/02/2021 10:42 a.m., Parkhurst, David F. wrote: > I�ve several times to figure this out with no luck. I�ve moved a tab > delimited text file (created from excel) to the desktop to simplify the path. > If I click on the file and ask Get Info, it lists �Where� as iCloud Drive > > Desktop. If I copy that to the clipboard and paste that into a read.table > command in the R console, it comes up as /Users/DFP/Desktop. But if I try > read.table("\\Users\\DFP\\Desktop\\moabsitechem"), > I get No such file or directory. How can I get that file into a data frame? > > Is there some place in my Mac that I can put the file so I could enter just > the file name, and not the whole path? Sorry, forget to answer your actual question: You can use getwd() to find the working directory. If you put the file there, you won't need to specify the path. Duncan Murdoch [[alternative HTML version deleted]] ___ R-SIG-Mac mailing list R-SIG-Mac@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac
Re: [R-SIG-Mac] How to find the path for a file to be read with read.table() in a Mac
Thank you. I thought I�d seen in some book that in a Mac, one had to specify paths in the way I tried. From: Duncan Murdoch Date: Saturday, February 13, 2021 at 10:49 AM To: Parkhurst, David F. , r-sig-mac@r-project.org Subject: Re: [R-SIG-Mac] How to find the path for a file to be read with read.table() in a Mac On 13/02/2021 10:42 a.m., Parkhurst, David F. wrote: > I�ve several times to figure this out with no luck. I�ve moved a tab > delimited text file (created from excel) to the desktop to simplify the path. > If I click on the file and ask Get Info, it lists �Where� as iCloud Drive > > Desktop. If I copy that to the clipboard and paste that into a read.table > command in the R console, it comes up as /Users/DFP/Desktop. But if I try > read.table("\\Users\\DFP\\Desktop\\moabsitechem"), > I get No such file or directory. How can I get that file into a data frame? > > Is there some place in my Mac that I can put the file so I could enter just > the file name, and not the whole path? It doesn't make sense to use backslashes in the path: macOS will see those as part of the name, not as path separators. Just use read.table("/Users/DFP/Desktop/moabsitechm") if that's the filename. Duncan Murdoch [[alternative HTML version deleted]] ___ R-SIG-Mac mailing list R-SIG-Mac@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac
Re: [R-SIG-Mac] How to find the path for a file to be read with read.table() in a Mac
On 13/02/2021 10:42 a.m., Parkhurst, David F. wrote: I’ve several times to figure this out with no luck. I’ve moved a tab delimited text file (created from excel) to the desktop to simplify the path. If I click on the file and ask Get Info, it lists “Where” as iCloud Drive > Desktop. If I copy that to the clipboard and paste that into a read.table command in the R console, it comes up as /Users/DFP/Desktop. But if I try read.table("\\Users\\DFP\\Desktop\\moabsitechem"), I get No such file or directory. How can I get that file into a data frame? Is there some place in my Mac that I can put the file so I could enter just the file name, and not the whole path? Sorry, forget to answer your actual question: You can use getwd() to find the working directory. If you put the file there, you won't need to specify the path. Duncan Murdoch ___ R-SIG-Mac mailing list R-SIG-Mac@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac
Re: [R-SIG-Mac] How to find the path for a file to be read with read.table() in a Mac
On 13/02/2021 10:42 a.m., Parkhurst, David F. wrote: I’ve several times to figure this out with no luck. I’ve moved a tab delimited text file (created from excel) to the desktop to simplify the path. If I click on the file and ask Get Info, it lists “Where” as iCloud Drive > Desktop. If I copy that to the clipboard and paste that into a read.table command in the R console, it comes up as /Users/DFP/Desktop. But if I try read.table("\\Users\\DFP\\Desktop\\moabsitechem"), I get No such file or directory. How can I get that file into a data frame? Is there some place in my Mac that I can put the file so I could enter just the file name, and not the whole path? It doesn't make sense to use backslashes in the path: macOS will see those as part of the name, not as path separators. Just use read.table("/Users/DFP/Desktop/moabsitechm") if that's the filename. Duncan Murdoch ___ R-SIG-Mac mailing list R-SIG-Mac@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac
[R-SIG-Mac] How to find the path for a file to be read with read.table() in a Mac
I’ve several times to figure this out with no luck. I’ve moved a tab delimited text file (created from excel) to the desktop to simplify the path. If I click on the file and ask Get Info, it lists “Where” as iCloud Drive > Desktop. If I copy that to the clipboard and paste that into a read.table command in the R console, it comes up as /Users/DFP/Desktop. But if I try read.table("\\Users\\DFP\\Desktop\\moabsitechem"), I get No such file or directory. How can I get that file into a data frame? Is there some place in my Mac that I can put the file so I could enter just the file name, and not the whole path? ___ R-SIG-Mac mailing list R-SIG-Mac@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac