-
Notifications
You must be signed in to change notification settings - Fork 1
/
Easy_test_ggplot2_issues.Rmd
144 lines (133 loc) · 8.15 KB
/
Easy_test_ggplot2_issues.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
---
title: "R Notebook"
# output: html_notebook
editor_options:
chunk_output_type: inline
---
```{r}
library(ggplot2)
library(reshape2)
library(animint2)
```
```{r}
#Showing the status generated after loading libraries below:
```
```{r}
# Attaching package: ‘ggplot2’
#
# The following objects are masked from ‘package:animint2’:
#
# %+%, %+replace%, aes, aes_, aes_all, aes_auto, aes_q, aes_string,
# annotate, annotation_custom, annotation_logticks, annotation_map,
# annotation_raster, as_labeller, autoplot, benchplot, borders,
# calc_element, continuous_scale, Coord, coord_cartesian, coord_equal,
# coord_fixed, coord_flip, coord_map, coord_munch, coord_polar,
# coord_quickmap, coord_trans, CoordCartesian, CoordFixed, CoordFlip,
# CoordMap, CoordPolar, CoordQuickmap, CoordTrans, cut_interval, cut_number,
# cut_width, discrete_scale, draw_key_abline, draw_key_blank,
# draw_key_boxplot, draw_key_crossbar, draw_key_dotplot, draw_key_label,
# draw_key_path, draw_key_point, draw_key_pointrange, draw_key_polygon,
# draw_key_rect, draw_key_smooth, draw_key_text, draw_key_vline,
# draw_key_vpath, element_blank, element_grob, element_line, element_rect,
# element_text, expand_limits, facet, facet_grid, facet_null, facet_wrap,
# fortify, Geom, geom_abline, geom_area, geom_bar, geom_bin2d, geom_blank,
# geom_boxplot, geom_contour, geom_count, geom_crossbar, geom_curve,
# geom_density, geom_density_2d, geom_density2d, geom_dotplot,
# geom_errorbar, geom_errorbarh, geom_freqpoly, geom_hex, geom_histogram,
# geom_hline, geom_jitter, geom_label, geom_line, geom_linerange, geom_map,
# geom_path, geom_point, geom_pointrange, geom_polygon, geom_qq,
# geom_quantile, geom_raster, geom_rect, geom_ribbon, geom_rug,
# geom_segment, geom_smooth, geom_spoke, geom_step, geom_text, geom_tile,
# geom_violin, geom_vline, GeomAbline, GeomAnnotationMap, GeomArea, GeomBar,
# GeomBlank, GeomBoxplot, GeomContour, GeomCrossbar, GeomCurve,
# GeomCustomAnn, GeomDensity, GeomDensity2d, GeomDotplot, GeomErrorbar,
# GeomErrorbarh, GeomHex, GeomHline, GeomLabel, GeomLine, GeomLinerange,
# GeomLogticks, GeomMap, GeomPath, GeomPoint, GeomPointrange, GeomPolygon,
# GeomQuantile, GeomRaster, GeomRasterAnn, GeomRect, GeomRibbon, GeomRug,
# GeomSegment, GeomSmooth, GeomSpoke, GeomStep, GeomText, GeomTile,
# GeomViolin, GeomVline, gg_dep, ggplot, ggplot_build, ggplot_gtable,
# ggplotGrob, ggproto, ggproto_parent, ggsave, ggtitle, guide_colorbar,
# guide_colourbar, guide_legend, guides, is.Coord, is.facet, is.ggplot,
# is.ggproto, is.theme, label_both, label_bquote, label_context,
# label_parsed, label_value, label_wrap_gen, labeller, labs, last_plot,
# layer, layer_data, layer_grob, layer_scales, lims, map_data, margin,
# mean_cl_boot, mean_cl_normal, mean_sdl, mean_se, median_hilow, Position,
# position_dodge, position_fill, position_identity, position_jitter,
# position_jitterdodge, position_nudge, position_stack, PositionDodge,
# PositionFill, PositionIdentity, PositionJitter, PositionJitterdodge,
# PositionNudge, PositionStack, qplot, quickplot, rel, remove_missing,
# resolution, Scale, scale_alpha, scale_alpha_continuous,
# scale_alpha_discrete, scale_alpha_identity, scale_alpha_manual,
# scale_color_brewer, scale_color_continuous, scale_color_discrete,
# scale_color_distiller, scale_color_gradient, scale_color_gradient2,
# scale_color_gradientn, scale_color_grey, scale_color_hue,
# scale_color_identity, scale_color_manual, scale_colour_brewer,
# scale_colour_continuous, scale_colour_date, scale_colour_datetime,
# scale_colour_discrete, scale_colour_distiller, scale_colour_gradient,
# scale_colour_gradient2, scale_colour_gradientn, scale_colour_grey,
# scale_colour_hue, scale_colour_identity, scale_colour_manual,
# scale_fill_brewer, scale_fill_continuous, scale_fill_date,
# scale_fill_datetime, scale_fill_discrete, scale_fill_distiller,
# scale_fill_gradient, scale_fill_gradient2, scale_fill_gradientn,
# scale_fill_grey, scale_fill_hue, scale_fill_identity, scale_fill_manual,
# scale_linetype, scale_linetype_continuous, scale_linetype_discrete,
# scale_linetype_identity, scale_linetype_manual, scale_radius, scale_shape,
# scale_shape_continuous, scale_shape_discrete, scale_shape_identity,
# scale_shape_manual, scale_size, scale_size_area, scale_size_continuous,
# scale_size_date, scale_size_datetime, scale_size_discrete,
# scale_size_identity, scale_size_manual, scale_x_continuous, scale_x_date,
# scale_x_datetime, scale_x_discrete, scale_x_log10, scale_x_reverse,
# scale_x_sqrt, scale_y_continuous, scale_y_date, scale_y_datetime,
# scale_y_discrete, scale_y_log10, scale_y_reverse, scale_y_sqrt,
# ScaleContinuous, ScaleContinuousDate, ScaleContinuousDatetime,
# ScaleContinuousIdentity, ScaleContinuousPosition, ScaleDiscrete,
# ScaleDiscreteIdentity, ScaleDiscretePosition, should_stop, Stat, stat_bin,
# stat_bin_2d, stat_bin_hex, stat_bin2d, stat_binhex, stat_boxplot,
# stat_contour, stat_count, stat_density, stat_density_2d, stat_density2d,
# stat_ecdf, stat_ellipse, stat_function, stat_identity, stat_qq,
# stat_quantile, stat_smooth, stat_spoke, stat_sum, stat_summary,
# stat_summary_2d, stat_summary_bin, stat_summary_hex, stat_summary2d,
# stat_unique, stat_ydensity, StatBin, StatBin2d, StatBindot, StatBinhex,
# StatBoxplot, StatContour, StatCount, StatDensity, StatDensity2d, StatEcdf,
# StatEllipse, StatFunction, StatIdentity, StatQq, StatQuantile, StatSmooth,
# StatSum, StatSummary, StatSummary2d, StatSummaryBin, StatSummaryHex,
# StatUnique, StatYdensity, theme, theme_bw, theme_classic, theme_dark,
# theme_get, theme_gray, theme_grey, theme_light, theme_linedraw,
# theme_minimal, theme_replace, theme_set, theme_update, theme_void,
# transform_position, update_geom_defaults, update_labels,
# update_stat_defaults, waiver, xlab, xlim, ylab, ylim, zeroGrob
```
```{r}
#reading and conversion
df <- read.csv("futures data.csv")
df$Trade.Date <- as.Date(df$Trade.Date, format="%d/%m/%y")
df_new <- melt(df[, c("Trade.Date", "USD.AF8.FUT", "JPY.AF8.FUT", "GBP.AF8.FUT", "EUR.AF8.FUT")], id="Trade.Date")
bp<-c("2011-01-01", "2012-01-01", "2013-01-01", "2014-01-01", "2015-01-01", "2016-01-01",
"2017-01-01", "2018-01-01")
bpoints = as.Date(bp, format="%Y-%m-%d")
df_new$year <- as.numeric(format(df$Trade.Date,'%Y'))
df_new$bucket <- cut(df_new$year, breaks = c(2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018))
head(df_new)
```
```{r warning=FALSE}
theme_config = theme(plot.background = element_rect(fill = "lightsteelblue2", colour = "red"), plot.title = element_text(size = 20, face="bold", hjust = 0.5),
plot.subtitle = element_text(size = 10, hjust = 0.5),
plot.caption = element_text(size = 10),
axis.text.x = element_text(size = 10, angle=30, hjust = 0.5),
axis.text.y = element_text(size=10, angle = 30),
panel.background = element_rect(fill = "pink"),
panel.grid.minor =element_line(color = "white", linetype = "dashed"))
gg_anm2_sel <- ggplot(df_new) + geom_freqpoly(binwidth=5, aes(x=value, color=variable)) + labs(title="Futures FX Data: Frequency Polygon", subtitle="2010-2018", x="Price", y="Count", caption="Source: MSEI") + theme_config + scale_x_continuous(breaks=seq(0, 150, 5))
gg_anm2_out <- ggplot(df_new) + geom_point( aes(x=df_new$Trade.Date, y=value, color=variable, showSelected.variable=df_new$bucket, fill= bucket)) + labs(title="Futures FX Data: Data Points", subtitle="As per year selected", x="Dates", y="Future Exchange Rate(INR)", caption="Source: MSEI") + theme_config
plot <- list(plot1=gg_anm2_sel, plot2=gg_anm2_out)
#structure(plot, class="animint2")
animint2gist(plot, description = "Futures Currency Market")
```
```{r}
#Gives the following error:
# Error: Use of clickSelects and showSelected as aesthetics has been deprecated. Please use as parameters. Problem: Plot: plot1
```
```{r}
#In case of using clickSelects and showSelected as parameters, following error occurs:
#Error: Unknown parameters: showSelected.variable
~~