Skip to content

Commit 8cdec29

Browse files
Merge pull request #247 from coding-for-reproducible-research/improve-your-r-code-material
fix typos and tidy printing at the start of each notebook
2 parents 2838c99 + 6982781 commit 8cdec29

File tree

8 files changed

+177
-237
lines changed

8 files changed

+177
-237
lines changed

individual_modules/improve_your_r_code/data_table.ipynb

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,30 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
6-
"metadata": {},
7-
"outputs": [
8-
{
9-
"name": "stderr",
10-
"output_type": "stream",
11-
"text": [
12-
"/Users/cc1333/Library/Python/3.9/lib/python/site-packages/rpy2/ipython/rmagic.py:77: UserWarning: The Python package `pandas` is strongly recommended when using `rpy2.ipython`. Unfortunately it could not be loaded (error: No module named 'pandas'), but at least we found `numpy`.\n",
13-
" warnings.warn('The Python package `pandas` is strongly '\n"
14-
]
15-
}
16-
],
17-
"source": [
18-
"%load_ext rpy2.ipython"
19-
]
20-
},
21-
{
22-
"cell_type": "code",
23-
"execution_count": 2,
24-
"metadata": {},
5+
"execution_count": null,
6+
"metadata": {
7+
"editable": true,
8+
"slideshow": {
9+
"slide_type": ""
10+
},
11+
"tags": [
12+
"remove-input"
13+
]
14+
},
2515
"outputs": [],
2616
"source": [
27-
"%%R\n",
28-
"suppressPackageStartupMessages({\n",
29-
" suppressMessages({\n",
30-
" library(data.table)\n",
31-
" library(dplyr)\n",
32-
" })\n",
33-
"})"
17+
"%load_ext rpy2.ipython"
3418
]
3519
},
3620
{
3721
"cell_type": "markdown",
38-
"metadata": {},
22+
"metadata": {
23+
"editable": true,
24+
"slideshow": {
25+
"slide_type": ""
26+
},
27+
"tags": []
28+
},
3929
"source": [
4030
"# Fast Data Manipulation Using the `data.table` Package\n",
4131
"## Overview\n",
@@ -751,17 +741,9 @@
751741
},
752742
{
753743
"cell_type": "code",
754-
"execution_count": 22,
744+
"execution_count": null,
755745
"metadata": {},
756-
"outputs": [
757-
{
758-
"name": "stdout",
759-
"output_type": "stream",
760-
"text": [
761-
"NULL\n"
762-
]
763-
}
764-
],
746+
"outputs": [],
765747
"source": [
766748
"%%R\n",
767749
"# Write your code here"
@@ -777,7 +759,7 @@
777759
],
778760
"metadata": {
779761
"kernelspec": {
780-
"display_name": "Python 3",
762+
"display_name": "Python 3 (ipykernel)",
781763
"language": "python",
782764
"name": "python3"
783765
},
@@ -791,7 +773,7 @@
791773
"name": "python",
792774
"nbconvert_exporter": "python",
793775
"pygments_lexer": "ipython3",
794-
"version": "3.9.6"
776+
"version": "3.9.19"
795777
}
796778
},
797779
"nbformat": 4,

individual_modules/improve_your_r_code/microbenchmark.ipynb

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,30 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
6-
"metadata": {},
7-
"outputs": [
8-
{
9-
"name": "stderr",
10-
"output_type": "stream",
11-
"text": [
12-
"/Users/cc1333/Library/Python/3.9/lib/python/site-packages/rpy2/ipython/rmagic.py:77: UserWarning: The Python package `pandas` is strongly recommended when using `rpy2.ipython`. Unfortunately it could not be loaded (error: No module named 'pandas'), but at least we found `numpy`.\n",
13-
" warnings.warn('The Python package `pandas` is strongly '\n"
14-
]
15-
}
16-
],
17-
"source": [
18-
"%load_ext rpy2.ipython"
19-
]
20-
},
21-
{
22-
"cell_type": "code",
23-
"execution_count": 2,
24-
"metadata": {},
5+
"execution_count": null,
6+
"metadata": {
7+
"editable": true,
8+
"slideshow": {
9+
"slide_type": ""
10+
},
11+
"tags": [
12+
"remove-input"
13+
]
14+
},
2515
"outputs": [],
2616
"source": [
27-
"%%R\n",
28-
"suppressPackageStartupMessages({\n",
29-
" suppressMessages({\n",
30-
" library(microbenchmark)\n",
31-
" })\n",
32-
"})"
17+
"%load_ext rpy2.ipython"
3318
]
3419
},
3520
{
3621
"cell_type": "markdown",
37-
"metadata": {},
22+
"metadata": {
23+
"editable": true,
24+
"slideshow": {
25+
"slide_type": ""
26+
},
27+
"tags": []
28+
},
3829
"source": [
3930
"## Measuring Speed with Microbenchmark\n",
4031
"One way of measuring the time taken to run an R function is to invoke the `Sys.time()` function from the `base` R package. Consider the following toy function:"
@@ -211,7 +202,7 @@
211202
],
212203
"metadata": {
213204
"kernelspec": {
214-
"display_name": "Python 3",
205+
"display_name": "Python 3 (ipykernel)",
215206
"language": "python",
216207
"name": "python3"
217208
},
@@ -225,9 +216,9 @@
225216
"name": "python",
226217
"nbconvert_exporter": "python",
227218
"pygments_lexer": "ipython3",
228-
"version": "3.9.6"
219+
"version": "3.9.19"
229220
}
230221
},
231222
"nbformat": 4,
232-
"nbformat_minor": 2
223+
"nbformat_minor": 4
233224
}

individual_modules/improve_your_r_code/parallelisation.ipynb

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,30 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
6-
"metadata": {},
7-
"outputs": [
8-
{
9-
"name": "stderr",
10-
"output_type": "stream",
11-
"text": [
12-
"/Users/cc1333/Library/Python/3.9/lib/python/site-packages/rpy2/ipython/rmagic.py:77: UserWarning: The Python package `pandas` is strongly recommended when using `rpy2.ipython`. Unfortunately it could not be loaded (error: No module named 'pandas'), but at least we found `numpy`.\n",
13-
" warnings.warn('The Python package `pandas` is strongly '\n"
14-
]
15-
}
16-
],
17-
"source": [
18-
"%load_ext rpy2.ipython"
19-
]
20-
},
21-
{
22-
"cell_type": "code",
23-
"execution_count": 2,
24-
"metadata": {},
5+
"execution_count": null,
6+
"metadata": {
7+
"editable": true,
8+
"slideshow": {
9+
"slide_type": ""
10+
},
11+
"tags": [
12+
"remove-input"
13+
]
14+
},
2515
"outputs": [],
2616
"source": [
27-
"%%R\n",
28-
"suppressPackageStartupMessages({\n",
29-
" suppressMessages({\n",
30-
" library(parallel)\n",
31-
" library(parallelly)\n",
32-
" })\n",
33-
"})"
17+
"%load_ext rpy2.ipython"
3418
]
3519
},
3620
{
3721
"cell_type": "markdown",
38-
"metadata": {},
22+
"metadata": {
23+
"editable": true,
24+
"slideshow": {
25+
"slide_type": ""
26+
},
27+
"tags": []
28+
},
3929
"source": [
4030
"# Parallelisation Using the `parallel` Package\n",
4131
"The following section is based off of [these notes](https://dept.stat.lsa.umich.edu/~jerrick/courses/stat506_f24/16-parallel-processing.html) written by Josh Errickson at the University of Michigan. Additional information can be found in the [documentation](https://stat.ethz.ch/R-manual/R-devel/library/parallel/doc/parallel.pdf) for the parallel package.\n",
@@ -251,7 +241,7 @@
251241
],
252242
"metadata": {
253243
"kernelspec": {
254-
"display_name": "Python 3",
244+
"display_name": "Python 3 (ipykernel)",
255245
"language": "python",
256246
"name": "python3"
257247
},
@@ -265,7 +255,7 @@
265255
"name": "python",
266256
"nbconvert_exporter": "python",
267257
"pygments_lexer": "ipython3",
268-
"version": "3.9.6"
258+
"version": "3.9.19"
269259
}
270260
},
271261
"nbformat": 4,

individual_modules/improve_your_r_code/rcpp.ipynb

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,30 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
6-
"metadata": {},
7-
"outputs": [
8-
{
9-
"name": "stderr",
10-
"output_type": "stream",
11-
"text": [
12-
"/Users/cc1333/Library/Python/3.9/lib/python/site-packages/rpy2/ipython/rmagic.py:77: UserWarning: The Python package `pandas` is strongly recommended when using `rpy2.ipython`. Unfortunately it could not be loaded (error: No module named 'pandas'), but at least we found `numpy`.\n",
13-
" warnings.warn('The Python package `pandas` is strongly '\n"
14-
]
15-
}
16-
],
17-
"source": [
18-
"%load_ext rpy2.ipython"
19-
]
20-
},
21-
{
22-
"cell_type": "code",
23-
"execution_count": 2,
24-
"metadata": {},
5+
"execution_count": null,
6+
"metadata": {
7+
"editable": true,
8+
"slideshow": {
9+
"slide_type": ""
10+
},
11+
"tags": [
12+
"remove-input"
13+
]
14+
},
2515
"outputs": [],
2616
"source": [
27-
"%%R\n",
28-
"suppressPackageStartupMessages({\n",
29-
" suppressMessages({\n",
30-
" library(Rcpp)\n",
31-
" library(microbenchmark)\n",
32-
" })\n",
33-
"})"
17+
"%load_ext rpy2.ipython"
3418
]
3519
},
3620
{
3721
"cell_type": "markdown",
38-
"metadata": {},
22+
"metadata": {
23+
"editable": true,
24+
"slideshow": {
25+
"slide_type": ""
26+
},
27+
"tags": []
28+
},
3929
"source": [
4030
"# Acceleration via `Rcpp` (advanced)\n",
4131
"## Overview\n",
@@ -354,7 +344,7 @@
354344
],
355345
"metadata": {
356346
"kernelspec": {
357-
"display_name": "Python 3",
347+
"display_name": "Python 3 (ipykernel)",
358348
"language": "python",
359349
"name": "python3"
360350
},
@@ -368,7 +358,7 @@
368358
"name": "python",
369359
"nbconvert_exporter": "python",
370360
"pygments_lexer": "ipython3",
371-
"version": "3.9.6"
361+
"version": "3.9.19"
372362
}
373363
},
374364
"nbformat": 4,

0 commit comments

Comments
 (0)