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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -