[R] lapply

David Winsemius dwinsemius at comcast.net
Sun Jul 31 18:06:53 CEST 2016


> On Jul 30, 2016, at 7:53 PM, roslinazairimah zakaria <roslinaump at gmail.com> wrote:
> 
> Dear r-users,
> 
> I would like to use lapply for the following task:
> 
> ## Kolmogorov-Smirnov
> ks.test(stn_all[,1][stn_all[,1] > 0],stn_all_gen[,1][stn_all_gen[,1] > 0])
> ks.test(stn_all[,2][stn_all[,2] > 0],stn_all_gen[,2][stn_all_gen[,2] > 0])
> ks.test(stn_all[,3][stn_all[,3] > 0],stn_all_gen[,3][stn_all_gen[,3] > 0])
> ks.test(stn_all[,4][stn_all[,4] > 0],stn_all_gen[,4][stn_all_gen[,4] > 0])
> ks.test(stn_all[,5][stn_all[,5] > 0],stn_all_gen[,5][stn_all_gen[,5] > 0])
> ks.test(stn_all[,6][stn_all[,6] > 0],stn_all_gen[,6][stn_all_gen[,6] > 0])
> 
> I would like to conduct the Kolmogorov Smirnov goodness of fit tests.

Either use `lapply` over the column indices or (probably more cleanly) use `mapply` over the two dataframes.

-- 
David
> 
> Is it possible?
> 
> 
> Thank you very much.
> -- 
> *Dr. Roslinazairimah Binti Zakaria*
> *Tel: +609-5492370; Fax. No.+609-5492766*
> 
> *Email: roslinazairimah at ump.edu.my <roslinazairimah at ump.edu.my>;
> roslinaump at gmail.com <roslinaump at gmail.com>*
> Deputy Dean (Academic & Student Affairs)
> Faculty of Industrial Sciences & Technology
> University Malaysia Pahang
> Lebuhraya Tun Razak, 26300 Gambang, Pahang, Malaysia
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list