%<-?% | R Documentation |
value
' is invalid or NULL
, this function will not assign values and nothing happens.Right-hand side checked assignment
Provides a way to avoid assignment to the left-hand side. If the statement
'value
' is invalid or NULL
, this function will not assign values and nothing happens.
lhs %<-?% value
lhs |
an object to be assigned to |
value |
value to be checked |
Assign value on the right-hand side to the left-hand side if
value
does exists and is not NULL
# Prepare, remove aaa if exists
if(exists('aaa', envir = globalenv(), inherits = FALSE)){
rm(aaa, envir = globalenv())
}
# aaa will not be assigned. run `print(aaa)` will raise error
aaa %<-?% NULL
# Assign
aaa %<-?% 1
print(aaa)
# in a list
a = list()
a$e %<-?% bbb; print(a$e)
a$e %<-?% 2; print(a$e)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.