Last active
December 5, 2021 13:00
-
-
Save thistleknot/9739099941f8d2942a99ab21383cbf87 to your computer and use it in GitHub Desktop.
Create Columns in R on the fly using lapply (functional programming)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create columns on the fly | |
combo_s <- do.call(cbind,lapply(1:length(sndif_), function(d) | |
{ | |
if(sndif_[d]*season == 0) | |
{ | |
temp <- raw[,d,drop=FALSE] | |
}else | |
{ | |
temp <- raw[,d,drop=FALSE] | |
for(dif in 1:sndif_[d]) | |
{ | |
temp <- temp-dplyr::lag(temp,1*season) | |
} | |
} | |
return(temp) | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment