Write R code(s) to create a new environment called my_envir . Create a variable
ID: 3661659 • Letter: W
Question
Write R code(s) to create a new environment called my_envir.
Create a variable called num with the value of 3.14, and assign it to the environment called my_envir created in question 9.
Use two ways to retrieve the variable num (created in question 10) from my_envir (create in question 9).
Write a function called total that accepts two numbers. It returns the sum of these two numbers. For example, total(3,4) returns 7.
Write a function called positives that accepts a numeric vector. It returns a logical vector where positive numbers in the numeric vector result in TRUE, and zero or negative numbers in the numeric vector result in FALSE. For example, positives(c(1,0,-2,4)) returns TRUE FALSE FALSE TRUE.
Explanation / Answer
Function to find total.
total <- function(x, y){
add <- x+y
return(add)
}
positives <- function(c){
result <- all(vec<=0)
if(result == TRUE){ return(FALSE) }
else { return(TRUE) }
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.