Quick R Tip – easily read files using file.choose()

I’ve been using R recently for a few things and the one thing I’ve often struggled with is getting the software to read external datasets (such as csv files) to work on.  The general code I’ve been using to do this is:-

data <-read.csv("My file path and file name")

but it’s a real pain in the backside to do and you can get some pretty weird errors if you don’t get the path and filename correct.

Anyway, today I found a much nicer way of loading in my data:-

data <- read.csv(file.choose())

Which pops up a standard Windows file dialog so that I can just select a file to read in.  Much easier and less prone to errors and resulting frustrated hair-pulling, I think.

Leave a Reply

Your email address will not be published. Required fields are marked *