getwd()
[1] "/home/dw/rexrepos/tmp"
setwd("d:/daniel/work/r/")
Create some objects
7
Aval <- 15
Bval <- 10
Cval <-ls()
[1] "Aval" "Bval" "Cval" "dirMd" "dirR"
[6] "dirTmp" "fIn" "fName" "fOut" "markdEngine"
[11] "siteGen"
List available objects
# objects in .GlobalEnv workspace that have a capital C in their name
ls(".GlobalEnv", pattern="C")
character(0)
exists("Bval")
[1] TRUE
exists("doesNotExist")
[1] FALSE
Remove objects
Aval
[1] 7
rm(Aval)
# this will give an error Aval
Error in eval(expr, envir, enclos): Objekt 'Aval' nicht gefunden
## rm(list=ls(all.names=TRUE)) # remove all objects from the workspace
Bval
[1] 15
print(Bval)
[1] 15
4.5) (Bval <-
[1] 4.5
.Last.value
[1] "nanoc"
get("Bval")
[1] 4.5
"Bval"
varName <-get(varName)
[1] 4.5
ls()
[1] "Bval" "Cval" "dirMd" "dirR" "dirTmp"
[6] "fIn" "fName" "fOut" "markdEngine" "siteGen"
[11] "varName"
"varNew"
newNameVar <-assign(newNameVar, Bval)
varNew
[1] 4.5
search()
[1] ".GlobalEnv" "package:stringr" "package:knitr"
[4] "package:stats" "package:graphics" "package:grDevices"
[7] "package:utils" "package:datasets" "Autoloads"
[10] "package:base"
How R Searches and Finds Stuff
By default, savehistory()
saves the command history to the file .Rhistory
in the current working directory.
history()
savehistory("d:/daniel/work/r/history.r")
By default, save.image()
saves all objects in the workspace to the file .RData
in the current working directory.
save.image("d:/daniel/work/r/objects.Rdata")
R markdown - markdown - R code - all posts