Skip to content

Instantly share code, notes, and snippets.

View tchakravarty's full-sized avatar

Tirthankar Chakravarty tchakravarty

View GitHub Profile
@drsimonj
drsimonj / multiple_lags.R
Last active July 8, 2022 14:53
Example of creating multiple lags with dplyr
library(dplyr)
d <- data_frame(x = seq_len(100))
d
#> # A tibble: 100 x 1
#> x
#> <int>
#> 1 1
#> 2 2
#> 3 3
@ctufts
ctufts / group_by_and_ggplot.R
Created July 11, 2016 19:56
dplyr group_by and ggplot example
plot_df <-df %>% group_by(feature) %>%
do(
plots = ggplot(data = .) + aes(x = xcol, y = ycol) +
geom_point() + ggtitle(.$feature)
)
# show plots
plot_df$plots
@mbusigin
mbusigin / llxc.R
Created December 10, 2013 02:53
Lead/Lag Cross Correlation between XTS objects
llxc = function( a, ll=-12:12, legend.loc="topleft", displayLegend=T, legend.cex=1.0, overplot=F )
{
if ( ncol(a) < 2 )
{
print( "Not enough columns")
return;
}
a = na.omit(a)