Skip to content

Commit 406f7d1

Browse files
Proof reading: intro to r plotting
1 parent b836b26 commit 406f7d1

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

individual_modules/introduction_to_r/control_flow.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,15 +391,15 @@
391391
"metadata": {},
392392
"source": [
393393
"## Activity \n",
394-
"Can you edit the for loop to print the sentance backwards?"
394+
"Can you edit the for loop to print the sentence backwards?"
395395
]
396396
},
397397
{
398398
"cell_type": "markdown",
399399
"id": "604d6921-75ff-4ff9-9c4d-f59c312a2b8a",
400400
"metadata": {},
401401
"source": [
402-
"# IF Statements\n",
402+
"# if Statements\n",
403403
"\n",
404404
"As well as repeating tasks, it's possible we want R to only perform certain tasks in certain situations. To do this we need to write code that automatically decides between multiple options. The tool R gives us for doing this is called a conditional statement, and looks like this:"
405405
]

individual_modules/introduction_to_r/plots.ipynb

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"The mathematician Richard Hamming once said, “The purpose of computing is insight, not numbers,” and the best way \n",
3333
"to develop insight is often to visualize data. Visualization deserves an entire lecture (or course) of its own, \n",
3434
"but we can explore a few of R’s plotting features. R is synonymous with data analysis and visualisation. R is capable of plotting many \n",
35-
"different types of plots and importantly these are infinitely customisable. To mke a plot look the way we want,\n",
35+
"different types of plots and importantly these are infinitely customisable. To make a plot look the way we want,\n",
3636
"we need to take advantage of the many arguments available in plotting functions. \n",
3737
"\n",
3838
"The R base function ```plot()``` can generate a range of different plots from some user supplied data. \n",
@@ -254,8 +254,8 @@
254254
"id": "8200976c-a066-4fda-8a85-9dc58b59a224",
255255
"metadata": {},
256256
"source": [
257-
"Alternatively, we can provide a vector of colours, where the first colour will be the colour of the first point drawn, the second colour, the colour of the second point and so on. \n",
258-
"This vector does have to be the same length as the number of points. For example if we provide a vector of three colours, this will recycled until all the points have been pointed. "
257+
"Alternatively, we can provide a vector of colours, where the first colour will be the colour of the first point drawn, the second colour will be the colour of the second point, and so on. \n",
258+
"This vector does have to be the same length as the number of points. For example, if we provide a vector of three colours, this will be recycled until all the points have been pointed. "
259259
]
260260
},
261261
{
@@ -453,11 +453,11 @@
453453
"source": [
454454
"Note here, we only need to provide a vector of three colours, as there are only three boxes in the figure. \n",
455455
"\n",
456-
"As well as the ```plot()``` function R has some specific plot functions (box plots (boxplot()), histograms (hist()) \n",
457-
"and bar plots (barplot())) we can call instead. These functions use a lot of the same arguments to customise the visualise\n",
456+
"As well as the ```plot()``` function, R has some specific plot functions (box plots (boxplot()), histograms (hist()) \n",
457+
"and bar plots (barplot())) we can call instead. These functions use a lot of the same arguments to customise\n",
458458
"the appearance of the plot.\n",
459459
"\n",
460-
"For example we can recreate the same boxplot as follows\n"
460+
"For example, we can recreate the same boxplot as follows:\n"
461461
]
462462
},
463463
{
@@ -495,7 +495,7 @@
495495
"metadata": {},
496496
"source": [
497497
"Histograms are plotted using the function ```hist()```, which allows us to plot the frequency distribution of a vector. \n",
498-
"You can use standard plotting arguments such as col, but also used the argument breaks to adjust the amount of bins.\n"
498+
"You can use standard plotting arguments such as col, but we can also use the argument breaks to adjust the amount of bins.\n"
499499
]
500500
},
501501
{
@@ -607,7 +607,7 @@
607607
"id": "7c5e79ac-2a0a-4992-8ef5-31f183b67fa5",
608608
"metadata": {},
609609
"source": [
610-
"using ```abline()```, you can add horizontal lines (```h=```), vertical lines (```v=```), or diagonal lines(x, y). You can also specify the parameters of the straight line i.e the intercept (```a=```) and slope coefficient (```b=```). It can also be wrapped around a linear regression (```lm()```) to add a line of best fit.\n",
610+
"Using ```abline()```, you can add horizontal lines (```h=```), vertical lines (```v=```), or diagonal lines(x, y). You can also specify the parameters of the straight line i.e the intercept (```a=```) and slope coefficient (```b=```). It can also be wrapped around a linear regression (```lm()```) to add a line of best fit.\n",
611611
"\n"
612612
]
613613
},
@@ -682,7 +682,7 @@
682682
"We can make many additions to our plots. As there are so many, we will only explore the most common ones here but will \n",
683683
"list additional ones which may be useful in the future. \n",
684684
"\n",
685-
"We often need to add a legend to our, and can do this using ```legend()```. The ```legend()``` function allows us to \n",
685+
"We often need to add a legend to our visualisation, and can do this using ```legend()```. The ```legend()``` function allows us to \n",
686686
"define position, either by using x, y coordinates or by a word such as \"topleft\". We also provide the text, colours \n",
687687
"and background."
688688
]
@@ -728,9 +728,9 @@
728728
"```text()```, we provide x, y coordinates, \n",
729729
"the text to be written (```labels =```), size (```cex =```), and colour (```col =```) and font (```font =```). \n",
730730
"\n",
731-
"Using ```mtext()``` requires different arguments as it is relation to the margin side we put the text in. It requires \n",
731+
"Using ```mtext()``` requires different arguments as it is in relation to the margin side we put the text in. It requires \n",
732732
"the text (```text = ```), the side of the plot \n",
733-
"the text will go (side =) with 1 = bottom, 2 = left, 3 = top, 4 = right, the margin line to put the text on (line = ).\n"
733+
"the text will go in (side =) with 1 = bottom, 2 = left, 3 = top, 4 = right, and the margin line to put the text on (line = ).\n"
734734
]
735735
},
736736
{
@@ -770,12 +770,15 @@
770770
"metadata": {},
771771
"source": [
772772
"There are times when we may want to add additional axes or move and adjust the axes of a plot. For this, we use \n",
773-
"```axis()``` function after we create our plot. But first we need to tell R not to plot the default axes by \n",
773+
"an ```axis()``` function after we create our plot. But first we need to tell R not to plot the default axes by \n",
774774
"setting the argument ```axes``` to FALSE when running ```plot()```. ```axis()``` can be used to plot one axis at a time.\n",
775-
"Arguments for ```axis()``` including stating which side you want the axis to be drawn ```(side =)``` where 1 = below, \n",
776-
"2 = left, 3 = above and 4 = right, the positions of the tick-marks are drawn ```(at =)```, what the labels are \n",
777-
"```(labels =)```, how far from the axis the ticks should extend ```(line =)```, the position of the axis ```(pos =)```\n",
778-
" and if tick marks should be drawn ```(tick =)```. You can also change the line width ```(lwd =)```, colour ```(col =)```\n",
775+
"Arguments for ```axis()``` include:\n",
776+
"- stating which side you want the axis to be drawn ```(side =)``` where 1 = below, 2 = left, 3 = above and 4 = right\n",
777+
"- the positions the tick-marks are drawn ```(at =)```\n",
778+
"- what the labels are ```(labels =)```\n",
779+
"- how far from the axis the ticks should extend ```(line =)```\n",
780+
"- the position of the axis ```(pos =)```,\n",
781+
"- and if tick marks should be drawn ```(tick =)```. You can also change the line width ```(lwd =)```, colour ```(col =)```\n",
779782
" and type of line ```(lty =)```. You need to use ```axis()``` for each axis you want to add."
780783
]
781784
},
@@ -824,7 +827,7 @@
824827
"\n",
825828
"There are times when you want to adjust the size of the margins of a plot to make better use of the space available. \n",
826829
"Using ```par()``` with ```mar()``` and/or ```mgp()``` before calling ```plot()```, we can adjust the margins of our plot. \n",
827-
"The function ```par()``` is essentially the function to set the parameters of the plots that follow. We can can it multiple times In\n",
830+
"The function ```par()``` is essentially the function to set the parameters of the plots that follow. We can can use it multiple times in\n",
828831
"a script to change the appearance of different plots.\n",
829832
"\n",
830833
"Using the argument ```mar``` allows us to adjust the width of the margins on each side of the plot. They are specificed in the unit of \n",

0 commit comments

Comments
 (0)