Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > TestFunc
- function(flights) {
- ans <- data.table:::`[.data.table`(flights,
- carrier == "AA",
- .(mean1 = mean(arr_delay), mean2 = mean(dep_delay)),
- by=.(origin, dest, month))
- return(ans)
- }
- <environment: namespace:rmypackage>
- > flights <- data.table::fread("flights14.csv")
- > TestFunc(flights = flights)
- Error in `[.data.frame`(x, i, j) : could not find function "."
- Called from: `[.data.frame`(x, i, j)
- > TestFunc <- function(flights) {
- + ans <- data.table:::`[.data.table`(flights,
- + carrier == "AA",
- + .(mean1 = mean(arr_delay), mean2 = mean(dep_delay)),
- + by=.(origin, dest, month))
- + return(ans)
- + }
- > TestFunc(flights = flights)
- origin dest month mean1 mean2
- 1: JFK LAX 1 6.590361 14.2289157
- 2: LGA PBI 1 -7.758621 0.3103448
- 3: EWR LAX 1 1.366667 7.5000000
- 4: JFK MIA 1 15.720670 18.7430168
- 5: JFK SEA 1 14.357143 30.7500000
- ---
- 196: LGA MIA 10 -6.251799 -1.4208633
- 197: JFK MIA 10 -1.880184 6.6774194
- 198: EWR PHX 10 -3.032258 -4.2903226
- 199: JFK MCO 10 -10.048387 -1.6129032
- 200: JFK DCA 10 16.483871 15.5161290
- >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement