You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/vega-in-r/brush-and-link.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,8 @@ series: vega-in-r-series
8
8
weight: 10
9
9
---
10
10
11
-
We have seen how to concatenate charts, we may now see how to connect them interactively.
12
-
- To do so, we first create a static chart using the step 1 of the code below.
11
+
We have seen how to concatenate charts, we may now see how to connect them interactively. The steps described here are based on the [Interactive Examples article](https://vegawidget.github.io/altair/articles/interactive.html).
12
+
- To get started, we create a static chart using the step 1 of the code below.
13
13
- The second step is to add a selection. Here we add a selection of type `interval` but a selection can also be `single` or `multi`[altair.selection reference](https://altair-viz.github.io/user_guide/generated/api/altair.selection.html?highlight=selection#altair.selection). In step 2, we also name the selection 'brush' and we update the static chart by including the selection function.
14
14
- Finally, in step 3, we update the color encoding of the data, so that every time the chart is brused the data inside the selection are colored, based on the nominal variable `Missing`, and the rest are colored lightgray.
Copy file name to clipboardExpand all lines: pages/vega-in-r/changing-data.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,12 +9,12 @@ weight: 3
9
9
---
10
10
Let's now use a more realistic example and visualize a dataset included in the `vega_datasets` package [https://github.com/vega/vega-datasets.html](https://github.com/vega/vega-datasets.html).
11
11
12
-
You can import the vega datasets using the altair library.
12
+
We can import the vega datasets using the altair library.
We can now make an altair R plot similar to the one at altair Python [https://altair-viz.github.io/gallery/natural_disasters.html](https://altair-viz.github.io/gallery/natural_disasters.html)
74
-
For now, we may filter the data in R and use the subset of the data to make the chart. On the data transform section we will see how to do the filtering inside the altair chart specification.
74
+
For now, we may filter the data in R and use the subset of the data to make the chart. On the data transform section we will see how to do the filtering inside the chart specification.
Copy file name to clipboardExpand all lines: pages/vega-in-r/data-transformations.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,8 @@ series: vega-in-r-series
8
8
weight: 6
9
9
---
10
10
11
-
As mentioned in the documentation of altair, [https://altair-viz.github.io/user_guide/transform/index.html](https://altair-viz.github.io/user_guide/transform/index.html) in most cases, it is suggested to perform transformations outside the chart definition, so in our case using R. Of course, data transforms inside the chart can also be useful in some cases.
12
-
So far, we have been filtering the data in R and then using the modified data in the chart specification. Now, we use the `transform_filter()` to subset the data inside the chart. We make the linechart we have seen in a previous section using the code below:
11
+
As mentioned in the [data transformations documentation](https://altair-viz.github.io/user_guide/transform/index.html) of altair, in most cases, it is suggested to perform transformations outside the chart definition, so in our case using R. Of course, data transforms inside the chart can also be useful in some cases.
12
+
So far, we have been filtering the data in R and then using the modified data in the chart specification. Now, we use the `transform_filter()` to subset the data inside the chart. [Here](https://altair-viz.github.io/user_guide/transform/filter.html#user-guide-filter-transform) is the filter transfrom documentation. We make the linechart we have seen in a previous section using the code below:
@@ -121,7 +121,7 @@ We use the field predicates to assess whether a data point satisfied certain con
121
121
122
122
<br/>
123
123
124
-
We now also use the `transform_window()` for data transformation to compute and plot a windowed aggregation of the deaths over all available years.
124
+
We now also use the `transform_window()` for data transformation to compute and plot a windowed aggregation of the deaths over all available years.[Here](https://altair-viz.github.io/user_guide/transform/window.html#user-guide-window-transform) is the window transform documentation.
Copy file name to clipboardExpand all lines: pages/vega-in-r/layered-chart.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ series: vega-in-r-series
8
8
weight: 7
9
9
---
10
10
11
-
We are now looking at how we can combine charts in one canvas in altair R.
11
+
We are now looking at how we can combine charts in one canvas in altair R. This section on how to combine charts, is based on the [View Composition article](https://vegawidget.github.io/altair/articles/view-composition.html).
12
12
13
13
First, we are discussing a layered chart example. Each chart can be made separately and combined uisng the `+` operator: `chart_layer_1 + chart_layer_2`.
14
14
Below, we make a chart that consists of a line layer and a point layer. The tooltip should be added to the top layer so that it is visible in the final chart.
Copy file name to clipboardExpand all lines: pages/vega-in-r/setting-things-up.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,9 +9,10 @@ weight: 1
9
9
---
10
10
11
11
To get this tutorial started, we need, first, to install anaconda, and second, activate an r-reticulate environment using conda. We also need to install vega_datasets using pip and finally, install the R packages reticulate and altair using install.packages() in Rstudio.
12
-
Most of the steps described here are taken from [altair R installation](https://vegawidget.github.io/altair/articles/installation.html).
12
+
Most of the steps described here are taken from [altair R installation](https://vegawidget.github.io/altair/articles/installation.html). Make sure you are using Python version 3.5 or higher to comply to the system requirements of the altair R package [altair CRAN](https://cran.r-project.org/web/packages/altair/altair.pdf).
13
13
14
-
After installing Anaconda, open the Anaconda Prompt. Update conda:
14
+
First, [install Anaconda](https://www.anaconda.com/distribution/) and after installing Anaconda, open the Anaconda Prompt.
15
+
Update conda:
15
16
```C
16
17
conda -V
17
18
conda update conda
@@ -49,6 +50,8 @@ Verify the installation using:
49
50
altair::check_altair()
50
51
```
51
52
53
+
If there is no error on the verification, we are ready to start!
54
+
<br/>
52
55
The procedure described above should be run only in the beginning. The following times you want to use altair in Rstudio, you only need to call `library("altair")`.
Copy file name to clipboardExpand all lines: pages/vega-in-r/simple-barchart.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,7 +71,7 @@ Here is a very simple barchart defined in altair R.
71
71
The dataset used for this chart is:
72
72
73
73
```R
74
-
Var1= c("a","b","c","d","e")
74
+
Var1= c("a","b","c","d","e")
75
75
Var2= c(11, 19, 22, 8, 14)
76
76
Var3= c("type1","type1","type2","type1","type2")
77
77
dataset=data.frame(Var1, Var2, Var3)
@@ -93,14 +93,16 @@ chart_1 = alt$Chart(dataset)$
93
93
)
94
94
```
95
95
96
-
What is the syntax in altair R? It is similar to the altair Python with the major difference the usage of the operator `$` to access attributes, instead of `.`. We should note that there are some other differences of the Python and the R package described at the [Field Guide to Python Issues](https://vegawidget.github.io/altair/articles/field-guide-python.html) together with examples.
97
-
We should also notice that we use the object `alt` to access the Altair API and create a chart using `alt$Chart`.
96
+
What is the syntax in altair R? It is similar to the altair Python with the major difference the usage of the operator `$` to access attributes, instead of `.`. We should note that there are some other differences of the Python and the R package described at the [Field Guide to Python Issues](https://vegawidget.github.io/altair/articles/field-guide-python.html) together with examples. Below, are the most common properties of the chart syntax:
97
+
-We first need to use the object `alt` to access the Altair API and create a chart using `alt$Chart`.
98
98
- The `data` to be visualised is called inside the `alt$Chart`.
99
99
- The `mark` used is specifed after `mark_`. Values as properties of the marks, for instance a hard-coded size or color, can be specified here.
100
100
- The `encode` determines the mapping between the channels and the data fields. The encoding that is dependent on the fields is specified here, not the encoding that has to do with values of the marks. Here, `x` and `y` are the position channels. The field type is specified after the field name. `O` stands for ordinal and `Q` for quantitative. Other types are `N` for nominal, `T` for temporal and `G` for goejson. The `x = "Var1:O"` is the short form of `x = alt$X("Var1", type = "ordinal")`. The two forms are equivalent but the long form is used when doing more adjustments unside encoding. We will see an example in the field transform section.
101
101
- The height and width of the plot is specified inside `properties`.
102
102
103
-
To display the chart in Rstudio `vegawidget(chart_1)` or `chart_1` will not work. We can instead save the chart using:
103
+
For more detailed references in Altair classes and functions, we may look to the [API reference](https://altair-viz.github.io/user_guide/API.html).
104
+
105
+
Now, to display the chart in Rstudio we may use `vegawidget(chart_1)` or `chart_1`. Alternatively, we can also save the chart using:
0 commit comments