Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Introspection/R/introspection-1.r
Normal file
5
Task/Introspection/R/introspection-1.r
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
if(getRversion() < "2.14.1")
|
||||
{
|
||||
warning("Your version of R is older than 2.14.1")
|
||||
q() # exit R, with the option to cancel
|
||||
}
|
||||
5
Task/Introspection/R/introspection-2.r
Normal file
5
Task/Introspection/R/introspection-2.r
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
bloop <- -3.4
|
||||
if(exists("bloop", envir=globalenv()) && exists("abs") && is.function(abs))
|
||||
{
|
||||
abs(bloop)
|
||||
}
|
||||
15
Task/Introspection/R/introspection-3.r
Normal file
15
Task/Introspection/R/introspection-3.r
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#Declare some integers
|
||||
qqq <- 45L
|
||||
www <- -3L
|
||||
#Retrieve the name of all the variables in the user workspace
|
||||
var_names <- ls()
|
||||
#Retrieve the actual variables as a list
|
||||
all_vars <- mget(var_names, globalenv())
|
||||
#See which ones are integers
|
||||
is_int <- sapply(all_vars, is.integer)
|
||||
#Count them
|
||||
sum(is_int)
|
||||
#Retrieve the variables that were integers
|
||||
the_ints <- mget(varnames[is_int], globalenv())
|
||||
#Add them up
|
||||
sum(unlist(the_ints))
|
||||
Loading…
Add table
Add a link
Reference in a new issue