Skip to content

(Update) Trouble remembering directories and file names in R?

July 17, 2012

Here’s what I do (on mac — but there’s probably a windows version of this advice — and linux people probably already know how to do what i’ll describe). A while back I got tired of going back and forth between Finder and R. E.g. I need to read in a text file into R but can’t remember where it is so I go to Finder and browse through directories until I find it and then go back to R but forget how a particular directory is spelled so I go back to Finder etc…

Update The advice below is bad. I’ve learned a lot since writing it. This is much better:

list.files()

Its system independent (unlike what’s below).

Here’s the advice. Its all based on the system command, which lets you access the command line in Terminal from an R command line (if you already just use R from Terminal or use emacs to do R etc, then you — like the linux people — won’t find anything interesting here). When you don’t remember what’s in the current working directory, just type:

system('ls')

and you will get a list of all files and directories in the current directory.

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: