[R] do not perform function if the outcome is NA

Rui Barradas ruipbarradas at sapo.pt
Wed Jul 24 00:45:13 CEST 2013


Try the following.

standardised.abnormal.returns <- 
lapply(seq_len(ncol(abnormal.returns)),function(i) {
	if(standard.deviation[i,1] == 0)

Hope this helps,

Rui Barradas

Em 23-07-2013 22:58, iza.ch1 escreveu:
> Hi you all
> I have a question regarding the function. In my function I divide the values by the standard errors and sometimes the standard error is equal to zero and I get the result NA. Can I write the function in the way that if the outcome of the function is zero then the function is not conducted and it stays the value (not divided by standard errors)? the code for my function is the following:
> standardised.abnormal.returns<-lapply(seq_len(ncol(abnormal.returns)),function(i) {abnormal.returns[,i]/standard.deviation[i,1]})
> Thank you all for the help
> ______________________________________________
> R-help at r-project.org mailing list
> 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