Can we use tapply function in conjunction with ks.test in R? -


can use tapply function in conjunction ks.test in r ?

tapply used apply functions on multiple results @ single time.

tapply(airquality$month,airquality$day, ks.test) 

when used function got error this:

error in fun(x[[i]], ...) : argument "y" missing, no default 

can suggest there possibility of using tapply ks.test?

as @hubertl mentioned, ks.test in r requires y argument hence error telling 'y' missing. documentation, y should numeric vector in case of 2 sample ks test. if performing 1 sample ks test, y should string distribution comparing (e.g. pnorm normal, p.gamma gamma).

i think want:

tapply(airquality$month, airquality$day, ks.test, y = "pnorm") 

dplyr solution (list columns)

airquality %>% group_by(day) %>% do(test_result = ks.test(.$month, y = "pnorm")  

if wanted ks.test both variables want:

lapply(airquality[c("month", "day")], ks.test, y = "pnorm") 

Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -