[R] How to make the "apply" faster

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Sat Jul 9 22:33:49 CEST 2016


function(y) {sum(y>=70)}
-- 
Sent from my phone. Please excuse my brevity.

On July 9, 2016 1:19:27 PM PDT, Debasish Pai Mazumder <pai1981 at gmail.com> wrote:
>I have 4-dimension array x(lat,lon,time,var)
>
>I am using "apply" to calculate over time
> new = apply(x,c(1,2,4),FUN=function(y) {length(which(y>=70))})
>
>This is very slow. Is there anyway make it faster?
>
>-Debasish
>
>	[[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.



More information about the R-help mailing list