Function writing
3 important questions on Function writing
How do you use the if() function in a function?
- func<-function(x){ #start of body
- if(specification){ #start of specification
- return(desired result)
- }#end of specification
- else(second specification){ #start of specification
- return(desired result)
- }#end of specification
- } #end of function
How can you make custom warnings and errors in your function?
- If(specification) {
- stop("error message")
- }
- this will cause the function to stop and the error message to arise
- If(specification) {
- warning("warning message")
- }
- this will spawn a warning message, but the code will run on.
What does it mean to say that a function doesn't influence the global environment?
The question on the page originate from the summary of the following study material:
- A unique study and practice tool
- Never study anything twice again
- Get the grades you hope for
- 100% sure, 100% understanding