Listing files in a directory using list.files ()

I am on Mac OS X 10.9.4 Maverics. I am using R console to download some files (using Rstudio does not affect my problem), R version 3.1.1, GUI 1.65 Snow Leopard build (6784). I have loaded some data using the following code:

dataset_url <- "" 
download.file(dataset_url, "")
unzip("", exdir = "diet_data")


Then if I check my directory:

# [1] "/Users/katarinamayer/Desktop/diet_data"
# character(0)


But if I just type:

# [1] "Andy.csv"       "David.csv"      "John.csv"       "Mike.csv"       "Steve.csv"      "weightmedian.R"


Why can't I get a list of my files when I specify my directory using list.files("diet_data")



source to share

1 answer

You are already in the directory diet_data

as shown in the output getwd()

. By default, list.files()

will display files in the path returned getwd()


If you do setwd("/Users/katarinamayer/Desktop/")

, then do list.files("diet_data")

, I trust that you will observe the behavior that you expect.



All Articles