 All right, so welcome back also to people that are watching it on Moodle or the people that are watching it on YouTube Last part of today's lecture, so I think we have another 50 minutes left still have 12 slides So I think we will be done a little bit earlier today All right, so the applications I already talked about this a little bit, but many Statistical models or many statistical tests they assume that you have a normal distribution in Either the input or in the error term so after fitting some parameters So for example the Shapiro Wilkes test of normality can tell you if your distribution is a normal distribution so it is built into r so if you have a Vector of numbers then you can use Shapiro test give it your list of our give it your vector of numbers and then it will give you a P value saying that it is this likely that your distribution is a normal distribution Besides that you have the D'Agostini k-square test is a goodness of fit normality test based on sample skewness and sample cartosis So it's provided by external packages. So if you have a normal distribution Which is still kind of normal, but has a certain skew or a certain kind of kind of cartosis Then this test can even tell you if the the distribution that you have is good enough to do a certain Statistical test so are because it's about statistics and it's the language for statistical computing The advantage of having a normal distribution is is that it's a more powerful test So you get more statistical power when your distribution is a normal distribution and that this is just because if the distribution that you have is normal or DJ Agostino turned out But no if it's and so if it's if it's very if it's a normal distribution Then you get more statistical power because had the underlying assumptions of the test They are true so that means that you can use a more powerful statistical test instead of having to switch to non-parametric Testing which generally uses the rank of the numbers and not the real numbers So hey, it it has a little bit of a drawback of being forced to use Non-parametric statistics. All right, so a little bit about plots We are going to have a whole lecture about plots and making them beautiful that will be not next week but the week after that and if everything goes well, we will also have a guest lecture for like 30 minutes to an hour and Misha friend of mine will talk about his work where he uses are to create real-time plots to measure closed ecological systems, so a closed ecological system is a tube And in this tube there is water and their plants and their little animals And this system is at an equilibrium or that that is the goal to keep this system at an equilibrium of course Keeping it at an equilibrium is not good enough because you want to add energy to that system to produce food and his final goal is to have a closed ecological system which Produces more or less net food or net energy so it can be used on things like space travel Hey, you can imagine that if you are on a spaceship to Mars Then of course during the six months that you're traveling you need to grow your own food But you want to do this in a in a closed ecological system because of course hey You you don't want any outside interference to it So he uses are together with our dunios to kind of measure this system in real-time and then create plots and See what's going on. So hey measures things like co2 and he will tell you much more about it. So if everything goes Okay, then next week. We'll have the week off because it's a holiday and then on the 20th We will have first a lecture about plots so everything about plots and then Misha in the end to talk to you about his work on creating Well real-time updating bar plots and graphs and these kinds of things but in our Creating a plot can be done using the plot function, which of course is very logical So what the plot function does when you call it with a vector of numbers? Is that it creates a plot window and it figures out based on the numbers that you gave it? What the range of the data is so the minimum value the maximum value and it will put this on the y-axis and Then on the x-axis it will just be one to the number of numbers and then it will create this Dot plot of the measurements that you put in So if you want to add for example a second vector of numbers to an already existing plot You can use the points function so the plot function does nothing but set up the window because it looks at the numbers that you input and then it Calls points on your values that you create So the points function is a little bit a misnamed function because it doesn't just create points it also can create lines and Stare plots and all kinds of other plots, but it is the main plotting function in R So it allows you to put points or lines or these kinds of things on a plot window and to visualize your data If you create your own plots, then you can also use the axis function So the axis function allows you to define what is visible on the x-axis. So head the side For the x-axis is one the y-axis of a plot is side number two Then you have side number three, which is the axis on the other side of the y-axis So that's generally called the z-axis and then you have also side equals four And that's the opposite of the x-axis on the top of the plot generally You don't use side number three and side number four, but sometimes you want to create a plot Which has like a double axis system so it has a y-axis and it has a z-axis on the other side because you want to visualize two types of data one being in a Range which you plot on y and the other type of data being in another range which you then plot on the other axis So there's two more parameters There's the at parameter which says at which points you want to have tick marks And then you have labels and these are the labels that are put at the different at positions, right? So you can say Axis side is one so on the x-axis at one so at the position number one Take a label for example genotype a or whatever you want to put there When you create plots you also have to create a legend to explain what the different size and colors and shapes of dots mean So you can use that you can use the legend function for that The plot window of course is a 2d window But the image function is there to create kind of a heat map function So if you want to have a plot which is completely filled like a nice heat map Then you can in our use the image function and that creates kind of a 2d plot of your data So if you have a data, which is just a matrix filled with numbers Then you can call the image function on it and then what it will do it will take the x-axis From the x and the number of columns will be the y-axis and then hey It will based on the value in the matrix will then assign a color to it So the assigning of colors in the image function uses the brakes function So the brakes function sets different color boundaries. So you can say all numbers between zero and one are white All numbers between one and three are for example blue and all numbers which are three or higher Get a color which is purple, right? So you can define for each break So for each more or less section of your data, you can decide which color to use Of course, you don't have to do that. You can also just use the standard image function So the plot function is for more or less 2d plots when you have an x and a y measurement The image function if you have a matrix of measurements and you want to visualize all of them using a nice color scheme And then you can use the brakes So there are some types of specialty plots for example like the box plot So here we have the guinea pig tooth growth So how we can see different dosages of vitamin C and then here we see the length of the guinea pig tooth You can also use a level plot for heat maps Yes, yes, you also have level and you also have contour which creates these nice contour plots which looked like a Weather map right on a weather map you see like high pressure area low pressure area and that is done using contour So the contour function and indeed you can use a level plot to create heat maps as well And you can use the heat map function as well. Although. I don't really like the heat map function because it is It's a little bit obtuse So it's not as flexible as using the image function, but using the image function compared Combined with stuff like a contour It looks really nice. So if you have like a height map, yes, so you have for example, you're doing measurements of Of an area and you measure how high a certain area is then it's really nice to have a heat map to do things like colors like Everything below a thousand meters is green everything between a thousand and two thousand is is brown and everything above that is white I don't like the heat map function as well No, I I don't like it at all because it messes with the margins and it it's not flexible and in any case So I always try to use the image function the only Saving grace of the heat map function is is that it provides automatic built-in clustering But who needs that you can cluster your data yourself using any clustering function and then just reorder it So yeah, no, I'm not a big fan of the heat map function Although the heat map function It does have this really nice dendro grams on the side and you also have like this ability to do like a little color based on The group of which the data is in All right, so box plots are a very specialized type of plot So you generally don't want to make them yourself. So there's the box plot function in our which allows you to create box plots This is an experiment On guinea pigs and how the teeth of guinea pigs grow and hey, you see the length of the tooth according to different Different vitamin C dosages on the one axis and then you see that vitamin C is done Is given using ascorbic acid or just orange juice and you see that indeed have when we look at the box plot We see that giving guinea pigs orange juice is good for the teeth Or at least the teeth grow larger But only in a certain dosage of vitamin C. We see that for example here between the two groups There's no real difference Here we also see that there's no real difference and we can see that from the notch So the notch is something that you can set in the box plot function So you can say not just true or not just false but when you set the not just being true it shows you this kind of cave in on the side of the box plot right and this is more or less the standard Standard error in in the measurements So when you have two groups and the notches do not overlap Then there is a significant difference when the notches overlap So you see here that this notch includes this notch. So there's no significant difference between these two groups There is also no significant difference between these groups So it allows you to very quickly visualize your data and give people an idea of What is significantly different and what is not significantly different without even using a statistical test One of the other parameters for the box plot that you can set is the far width and that means that the width of the box plot So the the bulkiness of the bot plot is Based on the number of observations in the group So if you have a very low number of observations in the group Then you will have a very skinny box plot and if you have a large number of observations in the group You will have a very fat box plot. So hey, you can kind of Add this additional data to the plot What is the difference between whisker and box plot it's it's called the box and whiskers plot So the box of course is this is this yellow part and then the whiskers are the things that are outside You also see an outlier here, right? So it also plots the outlier so the the the measurements which are which are outside of the whiskers And the whiskers are chosen in such a way that they generally represent two standard deviations Although you can you can set that yourself. You can say I want whiskers which are Three standard deviations or five standard deviations away The general box in the box plot is one standard deviation So like that 50% of data falls into the box and then another like Well 22 and a half percent is in the whisker and other 22% isn't the upper whisker And then if if there are data points which are outside of that Then they are shown as individual dots and those are generally considered the outliers so two things that you can add the notch the notch automatically makes this Capings in here. So hey, it's not a standard square box plot and here you can see that in this case, right? These two groups although they look by eye to be relatively different You can see that there's probably no statistical difference because the notch ends here And then it overlaps with this notch here, which is slightly outside of the box So that means that there's not a lot of observations here If you want to also add the observations you can use the far-width parameter And then it will scale the side or the bulkiness of the box plot based on the number of observations in there Histograms are again very commonly used. So R has a built-in histogram function called HIST HIST can be done using the frequency So you can say frequency is true or frequency is false and In if you say set frequency to true then it will show you the number or it will be based on the number of observations and Had then here because this is one which has been done by frequency is false And then it says it gives you the density. So now the entire area of the plot will be one and Individual bars will be scaled based on the density So the number of observations compared to the total number of observations Of course if you want to compare Two groups which have very different numbers of observations Then you want to do this by the density and not the frequency, right? Because otherwise if one group of measurements has a thousand measurements and another group only has like 50 head And of course the the the thousand observations will be much higher because head will go like this group has a hundred observations Which is more than the total number of observations here So by setting setting it from frequency to density you can compare two Groups with each other which have a relatively big difference in the number of observations It has a parameter called breaks where you can set how many Where it should or how it should kind of group data? So you can see here that I used it because here you can see that these groups are Relative so this is from 0 to 5 from 5 to 10 from 10 to 15 to 20 And so you have like breaks here, but here you see that the groups become much much bigger so you can set your own breaks and it will Count how many observations you have in each of your kind of breakpoint sets? So not every bar has to have the same width You can have a group from 0 to 5 and then the next group going from 5 to 10 And then the group after that going from 10 to 100 So hey it is also possible to make histograms for example on our logarithmic scale where you just Increase the size of the group every time by 10 Histogram has a plot parameter if you set the plot parameter to false It will not it will not draw the plot, but it will return the value So it will return the number of observations in each of the groups Which is sometimes very handy because if you want to kind of subdivide your data into different sections, right? So you want to say how many observations do I have from 0 to 20 and how many of then you can use the return of the histogram function So the histogram returns something which you can put in a variable and you can use later If you don't want it to create the plot because you're not interested in the plot You're just interested in the statistics that it calculates Then you just say plot is false and then it doesn't do the plot, but it does do the calculation So it will give you for example the density. So how many or what percentage of numbers are between 0 and 1? All right, so I already told you that you can use the image in the heatmap function So the image function creates a grid of colored rectangles with colors corresponding to the values in Z So the more or less the the measurements within the matrix So the heatmap function is different It is less flexible, but it has as an advantage that it does automatic clustering and it can use side colors So side colors means that for every individual For example, you can say well this individual has gotten high treatment and another individual has gotten low treatment right so you can use two or three colors to designate groups and then it will draw that at the side and Generally what you want to see is this that you have a nice heatmap where several groups are splitting out So that individuals who got the high dosage are grouping together and individuals which had the low dosage are also grouping together so I generally prefer the image function and I would say practice with the image function before you start using the heatmap function To prevent some of these issues with the standard heatmap function There's also a heatmap dot-2 function. So that's called heatmap dot-2 And that is a slightly improved version of the standard heatmap function, but still it suffers from the same problems is that the The dendrograms on the side They take up some of the margins meaning that you can't really decide where if you want to draw like additional lines in the plot It's really difficult to figure that out using heatmap. It's very easy using an image function So the image function had a heatmap function internally uses the image function as well. All right, so there's If you want to make plots, right? Then there's a whole bunch of additional parameters that you might want to set for example You want to say that the the font label. So I want to use a different font, right? I don't like the standard font or the journal requires me to have plots and these plots should use Ariel or courier new or they should be in wingdings, right? So are allows you to set the font of for example the labels But also the font of the main and and all of the other texts that you use in the plot So if you want to set or query graphical parameters, you can use the par function So the par function for example here I use it to set some parameters So I say that the label font sort of the the font on the labels on the x-axis and the y-axis Should use font number or two. Of course, you can also specify that by name So you can say font that lap is Ariel and then it will use the Ariel font to do the plotting the font that axis is the ink is the is the Oh, no the font that label is the is the label So that's the label of the x-axis and the label of the y-axis the font of axis is actually the font used for the tick marks on the axis You have to see x dot axis, which is the magnification So here I say make them one make them 50% bigger and also make the labels 50% bigger There's literally a hundred and fifty or something options that you can set for plots to make them kind of adjustable Yes, so you have magnification your CRT. You have the family the font The label the last the LTI so the line types the line thickness And so there's a lot of things that you can set Using this par function if you want to know what you can set then you can just do in our Question mark par and so just type question mark then do par And then it will give you an overview of all of the different things that you can set And I think it also has some images to show you for example if you are dealing with things like Margin so you have an inner margin. You have an outer margin. You have a max which is the margin between two plots You have pch, which is the point size The type of the x-axis if you should plot it or if you shouldn't plot it. So there's like a hundred and sixty options, but Can you also add another axis with par? No, that's what the axis function is for so if you want to add a third axis Opposite of the y-axis then you can say axis three and then you can specify Where you want to have your tick marks and then you can also give labels to these tick marks So if you want to Change for example, yes, so instead of writing a million you want to say one Mio, then you can you can use the axis function So if you want to give an axis then the axis function will do that The par is more like global plot parameters like How many dpi should my plot be? What font family should I use so those are general things which generally can't be set in the individual plots So many options if you want to know all of them just do question mark par and it opens up a like Five page help file or ten page help file with all the different options that you can set With a description of how you can use it and what the default values are All right, so how to plot? So in R generally when people use the R window, right then you would just say plot something But generally if you want to use your plot You're not wanting the plot to show up in R But you want to have your plot for example in a PNG or a JPEG, right? You want to have a file on your hard drive? So generally I first make my plots using just a plot function When it works and I want to write it to the disk then I use this structure So the first thing that I do is say PNG which opens up the PNG device I give it a name. I give it a width and a height and here I can also set the DPI So the the kind of resolution of the image I then set up all of the parameters that I need for example the font size the type of font How big I want my labels to be? All of these parameters so the global parameters Then I create an empty plot and this is what I generally do so I create an empty plot I give my own x and y More or less axis, right? So here I say the x axis should run from zero to a hundred the y axis should run from zero to thousand Type equals none if I would not specify type equals none It would put a dot at zero zero and it would put a dot at a hundred a thousand So by saying type equals none I suppress the plotting of the values that I gave to the x and y it kind of and because I told you that the plot function Internally uses the points function to draw the points so by saying type equals none it doesn't call the point functions So it will just say It creates an empty window and then I add the points or the lines or the arrows myself Using either the points function or I use the arrow function or I use lines or rectangles So had then I do my own kind of custom plot after I'm done Then I say dev.off and at this point it will save my PNG So it will hey it will execute all of the commands and then it will save the PNG to disk So PNG just opens up the device. It's very similar to when you read the text file, right? And you use a connection for it So if you use it a connection then you have to close the connection in the end the same thing holds for plots So you open up a connection to a file then it streams the parameters into it the plot It creates the window and then you add the points the lines or rectangles that you want to add And then when you say dev.off it closes the file and creates more or less the image So if you forget to do dev.off then you will have a file which is zero bytes and it won't have anything in there So only when you do dev.off will it save it to the hard drive So this is more or less my default for making plots If I want to create multiple plots, right? I want to have like a four by four plot So I want to have in a single window. I want to have like four plots next to each other I can use this par function, right? Which sets up global parameters here. I'm saying MF row So This is just the way to tell R that I want to do multiple plots And in this case I want to have four plots two rows two columns So MF row is means that this is two rows And then the second one is the number of columns that I have and then I can create four plots And these plots will go into the four empty slots that I defined here So you can create multiple plots if you want to do it more complex and you want to have like a First plot being very big like taking the whole width of the of the picture And then the second plot only taking half of the width of the picture then I can use the layout function So the layout function allows you to come up with all kinds of weird Structures on how you want your plots to look And the way that you do it is you say I create a matrix and in this matrix I give numbers so one means the first plot Then zero means no plot and then two means second plot and then When I use the layout that show so it give this matrix to the layout function when I do layout that show NF Then it shows my layout in the R window So what I define here and this is generally you it's something that you draw on paper, right? So you you kind of make a little sketch of how you want your plot to look So I want to have like one plot on the top And I want to have like a little one on the side or I have one on the bottom And then hey you just define this as a matrix and in this case Hey, I just do two by two So head one one means use the two top rows, right? So the both rows are filled with ones and then I do layout that show If you want I can give you an example of this that that something that might be Then you can more visualize it in a way, right? Let's do an example since we still have like a little bit left and I still have three slides left So we can do a little example. So all right, so let's go to the R window All right, so we have in the R window. So we made this plot, right? So let's let's just use this one So we're going to say I'm going to create a matrix, right? And I want to have I have three color channels, right? So let's make Red green blue right so use the red channel the green channel and the blue channel and then have like the first two Channels on the top and then empty space and then another one So I'm going to say I want a matrix inside of my matrix I want to have one two zero and three and this is going to be a two by two matrix Two by two matrix and I say by row By row equals true. Oh Sorry small letter R, right? So now this is my matrix and now this matrix I am going to use as my layout So I'm going to say layout and then I'm going to say ML for my layout and now I can do Let me look it up. So now I can do layout dot show ML Right, so now it says when I call plot once it will be here when I call it twice It will be here and when I call it the third time it will be here, right? So if I would now do plot 1 to 10 Then you can see it will put it here The next one for example one to a hundred will be here and the third one one to a thousand will go here Right, so it just takes the matrix and interprets this so I can do even more complex, right? Because I can say well Imagine that I want to add like a little bit here, right? So I want to have like a new plot here on the side then I can say well I want to have a layout which is For example 1 1 right because I want to have more of a horizontal layout then I'm going to say 2 goes there and Then I want to say 0 comma 0 and then the 2 plot goes here again, right? So if we look at this matrix Then oh, this is of course a 3 by 2 made 2 by 3 matrix Right, so now it looks 1 1 2 2 0 0 So now I have the space for 2 for 2 plots, right? So 1 which will be horizontal and if I then say layout All right, we won't do the next slide in Dutch then so if I now say layout call it ml I can do the layout that show again And now it will show my layout and now you can see that the first plot is going to go here And the second plot is going to go here if I think well This is too much space for the second one And I actually want to have like a third one or third one here and the fourth one here Then of course I can just adjust my layout saying I want to have the third plot going here Then the fourth plot going here But I want to increase the size of the first one by 2 for example And then I'm going to say these ones are 2 and this one is 3 and then this is 5 So 2 by 5 Right, so if I would show you the matrix Then the matrix would look like this So I have now four spots for the first plot then there's the second which will go across two columns and then I have plot number Oh, no, that's that's wrong. So this should be 3 3 4 4 So I need to get rid of this and I want to make this one 3 and I want to make this one 4 right so this is more or less how I want it so one plot in the Top here then I want to have a very small plot here on the side And I want to have plot number 3 and plot number 4 go here So now when I use the layout function I can lay it out And then now it will notice that the layout of the window has changed So now I can just say plot 1 to 10 right so the first plot goes here, right? So this is this is like four fifths of the whole plot the second plot Will go here right so that's that's like one fifth of the total thing, but across two columns the third plot Let's just use this nice graphic that we had So just take the red channel here Right so the red channel goes here And then I can take the green channel going to the other side and filling up the last spot And and put it here Right so using the layout function I can be very very flexible in in where I want to have my plots And I can kind of create a single image and it just functions by if I have five rows Then it will just divide the entire plot window into five sections And here I am assigning four sections to this plot and only one section to this one But this one goes across two columns and of course I can use any size matrix So in theory I could do like 50 plots in a single window Clear another example do we want to have more angry birds or artists? I think this is good enough, right? All right, so that's how you can use the layout function And the layout that show just shows you the current layout that you have selected And so and you can even use multiple layouts and store them in variables and reuse them But this is kind of the way that you want to set up multi plots All right back to the presentation All right next slide in Dutch Go for it the apply function so After this lesson we have assignments and if you do the assignment Then you will see that you have to calculate a whole number of things like the average and standard deviation And that kind of thing so you can you can save a lot of time Save time through the apply function to use and if the apply function is used then you don't have to forget that the margin So the apply function is defined as x and that is the matrix that we use Then we have the margin which is 1 2 I never use I never use 1 and 2 and then we have the fun and that is the function that we want to fit So if we if we do this statement then we say Pass to on my matrix Over the column the function gemiddled and it got you a hoop time sparing in in the assignments, so he used the Assignments used the apply function as you that cunt Anderson it meant a for loop of men and while loop to do All right, so just quickly recap in in English So during the assignments you can save a lot of time coding effort by using the apply function So the apply function we already saw it But it will save you a lot of time because otherwise you have to write a for loop or a while loop and then save and these kinds of things But the apply function is going to help you during the assignments a lot So just as an example we have apply which works on a matrix called x then we have the margin So in many of these assignments the margin will be 1 when we want to do something by the rows and The margin can be 2 when we want to do something by the different columns The fun is the function that we want to apply and often these functions will be like mean or median or standard deviation And then it's just for you guys to save time during the assignments Try and use the apply function Of course, I would also advise if it works via the apply function also try to do it using Using a for loop right just to practice your for loops Or your while loops just try and use them as well But the apply function will save you a lot of time and will create like really tiny one-liners Which otherwise would be for acts in one to the number of columns Take the column from the matrix calculate the mean store the mean in a variable and these kinds of things So you don't have to do that you can do that automatically with the apply all right, so We can also subset right, so if we don't Want to have the mean calculated across all columns, but just a couple of columns right? It might be that our matrix has a column, which is not numeric then we can say Subset so we have MDF which are our matrix right so MDF is just called the name of the matrix So take a subset of this matrix select columns one and column two and Across this subset right so I'm just taking the whole matrix and scaling it down to the first two columns And then what I'm saying is apply to that to the columns the mean Right, and we can also use a filter so get the means for a certain number of columns and use the column filter So we can subset the matrix. I only want The column I want the values in the column temperature to be below 25 And I only want to select column one and column two and then again to this subset that I just made Apply to the columns the function mean Right, so subset is your friend. It really helps you What does the two do so that the two is here the margin? So if you would say one it would do them the average across the rows And if you say to then it will do the mean across the columns And I never use margin one two, so just forget about this last line, but margin one means Take this function and for each row do it a margin of two means for every column do this All right, so the subset function and the apply function are going to be really really useful during the assignments Because we are going to have taking or you have to make some subsets And then you have to calculate things like it's like means and medians and these kinds of things All right, and that's it for today. So Finished nicely in time 12 minutes before five So if there are any questions, let me know And next Tuesday at three we will again have our No, the lecture next week does not take place because it's a holiday So we will be having the next lecture on the 20th if I'm saying that correctly. So that's Yeah, 14 days from now. So that will be the 20th. There will be an assignments help section so on Tuesday because it's not a public holiday yet on Tuesday at three We will have our weekly zoom meeting For people that need help with the assignments. So if you want to get some help next week I will have to see if we want to do it the week after as well because then we have two zoom help meetings for assignments But that's just up to you. If you you think that well, it will be good to have like two of these meetings to talk about the assignments The assignments are really short this week But I also Uploaded additional assignments. So there are on the top of the Moodle. There's an extra assignments or additional assignments Maybe do a different day for the week after that is a very good idea test the starters That's why you have the little diamond in front of your name Yeah, that's why you have the diamond That's a good idea. Um, I will uh, yeah, I will send around a mail then so we will do it next week on Tuesday and then the week after um General gulok what graphics package can you recommend ggplot? none Use are Use what's available Only then start learning more complex stuff to do ggplot I in my whole career have never used ggplot I think the syntax of ggplot is just completely confusing Um, and I can't use it. I have colleagues who use it So if you are like I told you guys that there is an extra lecture or there's probably two spots for extra lectures at the end If you want to have a lecture about ggplot That is possible But I'm not going to do it because I Totally hate ggplot and that's just my personal opinion I don't know what an is is and then with a layout and grouping factors and these kinds of things I make my plots using plot image point rectangle Arrow these kinds of things Will there be any lectures? Yes, there will be a lot of so all the coming lectures won't really be about Basic r programming anymore because you already know how to program you can do a for loop You can do an if statement you can make a subset you can load in your data You can write out your data all of the lectures that are coming So next lecture on the 20th will be about plots. So creating nice looking graphics for publication and powerpoint and after that Let me tell you what you're up for So let me go to my overview of the lectures pptx our course All right, so lecture number five on the 20th will be plots then there will be a whole lecture talking about statistical testing Then there will be a lecture For me because I need to ask you guys some exam questions Which is about algorithms and functions and I just live talking about recursion and these kinds of things Then we will have A regression lecture. So everything about regression and more And then there will be linear mixed models So what is the difference between a random slope and a random intercept model and how to interpret the results from that There will be a lecture lecture number 10 about Creating an r package and getting rich off Having other people using your code and and being able to do that Um, I have a lecture planned about common idioms So common ways to do things in r so stuff which come back over and over again And then there will be a Your own or your own choice so one person last Last the last assignment series said that he had a really nice data set concerning fishing or Doing like electric fishing things So I just got the mail and I didn't read but I will make one lecture for him because he gave me part of his data set or the whole data set and I will just make a lecture about that. Um, so if there's anything that you want for example, I want to know more about Ggplot or I want to know more about block designs or I want to know more about How to create really professional loop and graphics in r or I want to Make little animated gifs in r. You can actually make animated gifs in r Let me let me look that up for you guys because you you might get a kick out of this. Um I did this for a colleague. Um I wrote a little simulation program, which I call the cow culling simulator And let me look it up for you guys, which is just Doing Like weird stuff with r right doing weird stuff with r is something that's always fun because you it teaches you something And I hope that I have everything installed. Um, I hope so because it uses emojis I'm really a fan of emojis. So let's do it like this. Oh, yeah, I have the emojis installed So let's close the plot window difference in differences, maybe Or does it take too long? How do you mean difference in differences? Because you can just use the diff function to get the differences And if you want the differences in the difference, then then you use the diff function on the diff function um So you mean like I have a row of numbers like c one four six and eight nine or something like that Right, these are numbers then I take the difference Right, so between one and four you have three and then if I want to we have the difference of the difference Then I just do the diff of the diff. Oh, um, the diff of the diff Which is the difference of the difference Is that what you want? Probably not. Um, anyway, let me show you the the the the the the The weird stuff that you can do it are I mean the statistical technique if to find out whether there is causality There is no statistical technique to find out if there is causality causality is not mathematically defined So you can't you can't do that Mathematic well, that's not entirely true because I'm working in a field which is quantitative genetics, right? and Mendelian randomization Does allow you to define causality So but if you're interested then we can do a lecture about that like I'm more than more than willing to do that um, but then We probably want to have a vote on that because I don't think that everyone is Into hardcore statistical genetics But yeah, we could talk a little bit about causality It's actually part of my phd thesis as well I've been doing a lot of work on causality and doing causal networks from gene expression data and Using like recombinant inbred lines and these kinds of things Anyway, I just wanted to show you and I hope this works actually to Because I don't I never tried doing animated gifs in r Using so I'm just going to make the window a little smaller so that we have the nice plotting window So fun stuff in r. So like I told you guys I made a cow killing culling simulator which simulates The effect on the genotype frequencies When the farmer starts selecting cows for things like milk production and to kind of Show people that simulations in r are really fun and you can do all kinds of animated gifs I decided to make something which is this So um, this is also something that you can do in r So here I'm just using emojis and I'm just using like refreshing the window To kind of make really fun animated gifs In r and you can do that like you can you can do anything in r that you want and ggplot cannot do this But r can so Like that's why I think r is superior to ggplot So if there's anyone out there that wants to kind of challenge me and say well, you can do this in ggplot as well Show me how to do this in ggplot and I might consider learning it but uh up until now no If I can't use emojis and just make like little moving pictures and have cows get hit by by like bananas and stuff Then um, I'm not interested in your plotting methods. Um, but I I do love these kinds of things like banana and then And I made a lot of these like there's like I have like a folder with like stupid crap that you can do it r Anyway, uh, I will stop the recording for the people and moodle