Pssst: R bug not here? Send the bug to Slack #rpalauworkshop, including ?rbug in your message so that we can search for it.
Explanation: There is a parenthesis somewhere that is not matching. In the example above there is an extra closing parenthesis after the
2
without a sister open parenthesis.
> some.object <- 2 # now this will work
Explanation: Mathematical operations in R only work with numbers, is one of
obj1
orobj2
a character?
> obj1 <- 3
> obj2 <- "hi"
> obj1 + obj2 # bug!
> obj2 <- "3" # watch out, 3 is between quotation marks so interpreted as a character
> obj1 + obj2 # bug!
> obj2 <- 3
> obj1 + obj2 # no bug since both obj1 and obj2 are numbers now
Explanation: The object ‘yourvar’ is not in the R environment. Did you assign it a value?
> ls() # to view the objects currently in the R environment
> yourvar <- 2 # assign the value 2 to yourvar
> yourvar # now print it
## [1] 2
> yourvar * 2 # success
## [1] 4
If it is the column of a dataframe, make sure you specify that with mytunadf$yourvar
.
Explanation: the file ‘file.txt’ is not in your current working directory.
> # To see the current location of the working directory
> getwd()
> # To change the location of your working directory
> setwd("/my/new/working/directory") # specify path here, e.g. "C:/Projects/OFP-data" (note the "")
> # To see what files are in your current working directory
> list.files() # is file.txt here?
Copyright © 2017 Pacific Community. All rights reserved.