Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. x<-data.frame(matrix(runif(1000*5), 1000, 5))
  2. head(x)
  3.  
  4. check.pattern<-function(y){
  5. #Check increasing, decreasing, and then increasing again
  6. y[2]>y[1] & y[3]>y[2] & y[4]<y[3] & y[5]>y[4]
  7. }
  8.  
  9. x$results<-apply(X=x, MARGIN=2, FUN=check.pattern)
  10. head(x)
  11.  
  12. > head(x)
  13. X1 X2 X3 X4 X5
  14. 1 0.4507316 0.61680485 0.5534436 0.95158639 0.7355047
  15. 2 0.8733650 0.05122706 0.8663237 0.60773953 0.2751080
  16. 3 0.5924487 0.68182261 0.8994460 0.06427961 0.4257301
  17. 4 0.5454436 0.50622038 0.4199539 0.60315238 0.4132902
  18. 5 0.2360781 0.40259646 0.8383073 0.38447181 0.2686289
  19. 6 0.5959003 0.80060159 0.1189321 0.12830038 0.1746429
  20.  
  21. > head(x)
  22. X1 X2 X3 X4 X5 results
  23. 1 0.4507316 0.61680485 0.5534436 0.95158639 0.7355047 FALSE
  24. 2 0.8733650 0.05122706 0.8663237 0.60773953 0.2751080 FALSE
  25. 3 0.5924487 0.68182261 0.8994460 0.06427961 0.4257301 TRUE
  26. 4 0.5454436 0.50622038 0.4199539 0.60315238 0.4132902 FALSE
  27. 5 0.2360781 0.40259646 0.8383073 0.38447181 0.2686289 FALSE
  28. 6 0.5959003 0.80060159 0.1189321 0.12830038 0.1746429 FALSE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement