Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. > TestFunc
  2. function(flights) {
  3. ans <- data.table:::`[.data.table`(flights,
  4. carrier == "AA",
  5. .(mean1 = mean(arr_delay), mean2 = mean(dep_delay)),
  6. by=.(origin, dest, month))
  7. return(ans)
  8. }
  9. <environment: namespace:rmypackage>
  10. > flights <- data.table::fread("flights14.csv")
  11. > TestFunc(flights = flights)
  12. Error in `[.data.frame`(x, i, j) : could not find function "."
  13. Called from: `[.data.frame`(x, i, j)
  14.  
  15. > TestFunc <- function(flights) {
  16. + ans <- data.table:::`[.data.table`(flights,
  17. + carrier == "AA",
  18. + .(mean1 = mean(arr_delay), mean2 = mean(dep_delay)),
  19. + by=.(origin, dest, month))
  20. + return(ans)
  21. + }
  22. > TestFunc(flights = flights)
  23. origin dest month mean1 mean2
  24. 1: JFK LAX 1 6.590361 14.2289157
  25. 2: LGA PBI 1 -7.758621 0.3103448
  26. 3: EWR LAX 1 1.366667 7.5000000
  27. 4: JFK MIA 1 15.720670 18.7430168
  28. 5: JFK SEA 1 14.357143 30.7500000
  29. ---
  30. 196: LGA MIA 10 -6.251799 -1.4208633
  31. 197: JFK MIA 10 -1.880184 6.6774194
  32. 198: EWR PHX 10 -3.032258 -4.2903226
  33. 199: JFK MCO 10 -10.048387 -1.6129032
  34. 200: JFK DCA 10 16.483871 15.5161290
  35. >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement