خرید بک لینک

Vote count: 0

My function works fine by itself but won't work with sapply...

getFlights <- function(data, code) {
x <- data %>% 
filter(origin == code ) %>%
select(origin, dest, flight) %>%
summarise(incoming = length(unique(flight))) 

y<- data %>%
  filter(dest == code) %>%
  select(origin, dest, flight) %>%
  summarise(outgoing = length(unique(flight))) 

z <- cbind(x,y)

retu(z)}

When the function works by itself, it works fine! like this:

getFlights(data = bdl, code = "DFW")

But when I tried to use sapply

airports <- c("JFK", "LGA", "EWR")
sapply(airports, FUN = getFlights)

I got an error message, and the same for lapply too :

Error during wrapup: no applicable method for 'filter_' applied to an object of class "character"

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 3 فروردين 1395 ساعت: 9:09

صفحه بندی