Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasero committed Nov 15, 2024
1 parent 2e9da5d commit 6e40448
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 74 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion _sources/chapters/module-5/051-intro_to_R.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hellow world program\n",
"## Hello world program\n",
"\n",
"As is common in any first lesson on programming, one of the first things to do is write a \"Hello, World!\" program.\n",
"\n",
Expand Down
1 change: 0 additions & 1 deletion _sources/chapters/module-5/053-Control-structures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,6 @@
},
"source": [
"```{exercise}\n",
"\n",
":label: Rloops1\n",
"\n",
"1- Write a piece of code that prints \"x is an even number\" if a variable x (which you define) is even; otherwise, print “x is an odd number.” Test your code by setting x to both an odd and an even number. (Hint: You may find the modulus operator helpful here.)\n",
Expand Down
1 change: 0 additions & 1 deletion _sources/chapters/module-5/054-functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,6 @@
"metadata": {},
"source": [
"```{exercise}\n",
"\n",
":label: Rfunctions3\n",
"\n",
"3- Create a function named \"mysquare\", which takes two arguments, such that it first takes the square of the first one, and then adds the second one to it. Set the second argument to take the value 2 as default. Test it. \n",
Expand Down
88 changes: 45 additions & 43 deletions _sources/chapters/module-5/055-tidyverse.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
"name": "stderr",
"output_type": "stream",
"text": [
"── \u001b[1mAttaching core tidyverse packages\u001b[22m ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 2.0.0 ──\n",
"── \u001b[1mAttaching core tidyverse packages\u001b[22m ──────────────────────── tidyverse 2.0.0 ──\n",
"\u001b[32m✔\u001b[39m \u001b[34mdplyr \u001b[39m 1.1.4 \u001b[32m✔\u001b[39m \u001b[34mreadr \u001b[39m 2.1.5\n",
"\u001b[32m✔\u001b[39m \u001b[34mforcats \u001b[39m 1.0.0 \u001b[32m✔\u001b[39m \u001b[34mstringr \u001b[39m 1.5.1\n",
"\u001b[32m✔\u001b[39m \u001b[34mggplot2 \u001b[39m 3.5.1 \u001b[32m✔\u001b[39m \u001b[34mtibble \u001b[39m 3.2.1\n",
"\u001b[32m✔\u001b[39m \u001b[34mlubridate\u001b[39m 1.9.3 \u001b[32m✔\u001b[39m \u001b[34mtidyr \u001b[39m 1.3.1\n",
"\u001b[32m✔\u001b[39m \u001b[34mpurrr \u001b[39m 1.0.2 \n",
"── \u001b[1mConflicts\u001b[22m ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──\n",
"── \u001b[1mConflicts\u001b[22m ────────────────────────────────────────── tidyverse_conflicts() ──\n",
"\u001b[31m✖\u001b[39m \u001b[34mdplyr\u001b[39m::\u001b[32mfilter()\u001b[39m masks \u001b[34mstats\u001b[39m::filter()\n",
"\u001b[31m✖\u001b[39m \u001b[34mdplyr\u001b[39m::\u001b[32mlag()\u001b[39m masks \u001b[34mstats\u001b[39m::lag()\n",
"\u001b[36mℹ\u001b[39m Use the conflicted package (\u001b[3m\u001b[34m<http://conflicted.r-lib.org/>\u001b[39m\u001b[23m) to force all conflicts to become errors\n"
Expand Down Expand Up @@ -78,7 +78,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"id": "d918fd8a-9972-4684-b19b-c29fbbcd6df9",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -166,7 +166,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"id": "e0f0a6a6-16b9-4022-b9cc-0239322b9b87",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -240,7 +240,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"id": "af23dc2d-a2c6-434e-b5ef-cbc0632ea3ef",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -303,7 +303,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 5,
"id": "ecd1c1fa-1d39-4a55-bb14-151ea55bbca9",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -374,7 +374,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 6,
"id": "da0a2ec8-4668-4449-bd40-823af3d984c9",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -441,7 +441,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 7,
"id": "fdf9d334-4a41-4127-93d3-8e526161c420",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -508,7 +508,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 8,
"id": "3fc119a9-a2b3-4be1-9b84-e455a631058c",
"metadata": {},
"outputs": [],
Expand All @@ -519,7 +519,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 9,
"id": "85722a96",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -559,7 +559,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 10,
"id": "c2ac85e6-dd87-4793-8c15-f1eac303c1b0",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -592,7 +592,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 11,
"id": "c6d0ab7c-5fe6-491b-979c-b3a92e8af02a",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -665,7 +665,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 12,
"id": "5d72b712",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -739,7 +739,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 13,
"id": "9dd91a01",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -823,7 +823,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 14,
"id": "5c5ec278",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -904,7 +904,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 15,
"id": "78bb4fdb",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -987,7 +987,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 16,
"id": "111402d5",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1069,7 +1069,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 17,
"id": "047832aa",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1151,7 +1151,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 18,
"id": "4f454cc7",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1233,7 +1233,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 19,
"id": "8d0b72de-4f0f-46f9-9242-b1e4c80ea971",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1316,7 +1316,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 20,
"id": "23f841fa",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1397,7 +1397,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 21,
"id": "02c20b0b",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1477,7 +1477,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 22,
"id": "9a293c3d",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1520,7 +1520,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 23,
"id": "99bbf3d5",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1580,7 +1580,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 24,
"id": "6e10cc2a-1245-4775-934c-baed921aa7a9",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1649,7 +1649,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 25,
"id": "b8151b55-a423-4d50-a9f0-6ed970251f87",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1719,7 +1719,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 26,
"id": "a2f5b34a-14f5-43bc-9c9e-ddd26fb0d118",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1836,7 +1836,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 27,
"id": "c8b4e2b1-34bc-4bc5-b209-360559cc9929",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1881,7 +1881,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 28,
"id": "5e61f580-6882-4cad-8186-d7f4dedefec0",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1915,7 +1915,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 29,
"id": "f0112447-94b6-449c-82c4-286681334110",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1950,7 +1950,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 30,
"id": "a83f167f-48cd-4516-b379-b2c594206648",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -2007,7 +2007,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 31,
"id": "6e257ebf-1622-4cde-96c2-40f56d8c5dc6",
"metadata": {},
"outputs": [
Expand All @@ -2033,7 +2033,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 32,
"id": "299d4b3f-8479-4b3c-8959-49939f5513ed",
"metadata": {},
"outputs": [
Expand All @@ -2059,7 +2059,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 33,
"id": "60295c43-5f0e-4328-b5c1-4de3e87740f6",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -2109,33 +2109,35 @@
"\n",
"1- Import the data from \"https://vincentarelbundock.github.io/Rdatasets/csv/psych/sat.act.csv\", which contains SAT and ACT scores for a sample of students. Save it to a variable named sat.dat.\n",
"\n",
"2- Using the pipe (`%>%`) operator, perform the following operations in sequence:\n",
"2- Convert \"education\" and \"gender\" columns to factor type. (Hint: use `as.factor` function)\n",
"\n",
"3- Using the pipe (`%>%`) operator, perform the following operations in sequence:\n",
"\n",
"- Filter the data to include only observations where `age` is between 18 and 45 years.\n",
"- Create a new variable, `SATV.avg`, representing the average of `SATQ` and `SATV`.\n",
"- Select the columns `gender`, `education`, and `SATV.avg`.\n",
"- Create a new variable, `SAT.avg`, representing the average of `SATQ` and `SATV`.\n",
"- Select the columns `gender`, `education`, and `SAT.avg`.\n",
"- Group the dataframe by `gender` and `education`.\n",
"- Summarize the dataframe by computing the mean and standard deviation of `SATV.avg`.\n",
"- Summarize the dataframe by computing the mean and standard deviation of `SAT.avg`. Here, since there are some missing information, you will need to remove these observations. You can actually do this when using the `mean` and `sd` functions. Look into their documentation to figure out how to do this.\n",
"\n",
"Save the resulting dataframe in a variable named `sat.dat.preprocessed` and display it.\n",
"\n",
"3- With the resulting dataframe, create a barplot using `geom_bar`:\n",
"4- With the resulting dataframe, create a barplot using `geom_bar`:\n",
"\n",
"- Set the x position to each level of `education`, and the `height` (y position) to the mean of `SATV.avg`.\n",
"- Set the x position to each level of `education`, and the `height` (y position) to the mean of `SAT.avg`.\n",
"- To display a separate bar for each `gender`, set `fill = gender` in the aesthetics, and use `position = \"dodge\"` to place the bars side by side rather than stacked.\n",
"\n",
"Adjust the plot aesthetics to make it more visually appealing.\n",
"Adjust the plot aesthetics to make it more visually appealing. You may find the following page useful for this: https://r-graph-gallery.com/4-barplot-with-error-bar.html\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 1,
"id": "3d73f011-2ba9-4d02-9195-5a95955a7fe1",
"metadata": {},
"outputs": [],
"source": [
"# Your answers here"
"# Your answers from here"
]
}
],
Expand Down
Loading

0 comments on commit 6e40448

Please sign in to comment.