Basics Flashcards
Open swirl package
library(“swirl”)
swirl()
get current working directory
getwd()
List all objects (i.e. variables) in your local workspace
ls()
List all the files in your working directory
list.files()
or
dir()
Determine the arguments that a function can take
args(function)
e.g args(list.files)
Note that it’s not args(list.files())
Create a new directory in the current working directory
dir.create(“newdir”)
Set working directory to “testdir”
setwd(“testdir”)
Create a file in current working directory
file.create(“newfile.R”)
Check is file exists in current working directory
file.exists(“file.R”)
Access information about the file “mytest.R”
file.info(“mytest.R”)
Rename “mytest.R” as “mytest2.R”
file.rename(“mytest.R”, “mytest2.R”)
Make a copy of “mytest2.R” called “mytest3.R”
file.copy(“mytest2.R”, “mytest3.R”)
Construct the path to a file from components in a platform-independent way
file. path()
e. g. file.path(“testdir2”, “testdir3”) creates testdir2/testdir3
Remove all variables from workspace
rm(list=ls())
see dataset dimensions
dim(dataset)