Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. # Create a function
  2. check_it <- function()
  3. if(x>500){
  4. return("green")
  5. } else if(x<0) {
  6. return("red")
  7. } else {
  8. return("blue")
  9. }
  10.  
  11. # Create a loop using check_it
  12. for(x in 1:nrow(all_data)) {
  13.  
  14. # Given this hint
  15. # Hint: You can use 1:nrow(all_data) as a set of indices
  16. # to do something like the following inside the loop:
  17. # all_data[i, "color"] <-
  18. # check_it( all_data[i, "growth"] )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement