How to get started in programming with documentation?


Which reports to us various objects in the our environment on the upper right is the console window I’ve typed my email there my email address so perfectly willing to receive emails from people and then on the lower right is a help screen where or is a is a window where help help files help instructions would appear or if I if I make any plots and one of the things I we’re going to do to start with is we’re gonna I’m going to load a a library and the library is entitled let me just move I mean let me do some housecleaning for a minute.

I want to look at my notes and look at my script over here okay I’m gonna take that down and I’m going so we’re going to look we need to run an invite to library so if I type in the command on the command window I’m so I’m in the command window here and I type in zoo lowercase C oo z it says there’s no documentation for specified but if I kept in question mark might say oh wait oh because I don’t have all right so I I’m going to need a library and I’m going to put in my in my script the command library the oo and then as you can see on the right hand upper right hand screen is a message that says that it attached the libraries the packaged zoo and if you want if you need to attach.

I’ll if you need to install a package what you do and this is the only package we’re going to need the only outside of outside of the basic tools within our this is the only package you’re going to need so if you need a new package you can go over to tools on the upper left hand corner and then click on install packages and then if you type in the letters 0 in that second window you probably should find that local satori no I guess it doesn’t matter goes to crayon okay so then you.

You’re going to need that package for this for this exercise I probably if I’d had a way of posting to our website I would have told people to do that before in so you’re going to need the package Zoo it’s actually not a package consisting of wild animals it’s a time-series package so you enter and I’m not sure what’s going to happen to me I’ve already got it installed but you know one of the more packages will be updated so it’s currently loaded prior to restarting strongly recommended okay.

I don’t want to restart our so but you’re going to need to do is go to tools install packages and then in the second bar of that window type the letters is Zed Oscar Oscar or zebra Oscar Oscar and you’re going to need to install that package we’re not going to use it right away but we are going to use it in a few minutes so let’s put up a URL or less or let’s just install our data actually let’s put a title up on the top of our analysis of us go bid data from USA facts dot org okay so there’s a comment on the first line of our screen pound analysis or hashtag analysis of Cova data from US fax so I’m going to save this file on my desktop just so that if anything happens I’ve been having this machine has been crashing so I want to make sure it.

I’m going to go to my desktop you probably can’t see me do that and I’m going to type in Co b ID underscore analysis dot our and it’s on my desktop there it is okay so it’s saved so I’m going to read in some data I’m going to use the command over here let’s look at our e ad CSV comma comma delimited values comma something and if I also figured out a way to make the that bigger if I go to tools I one told me and I forgot it no se tools global options advanced help faunal and let’s go make it 16 okay so there’s the there’s the can i all right there’s the make that bigger so on the lower right hand corner is a this is a help file for read table or read CSV you can see that it gives you help for read table as well as help for dot CSV CSV is comma something values comma separated values alright so here’s how to read CSV it says.

If you want to read a CSV file you put the name of the file in and then there are several defaults but basically what you need is read CSV so if you just if you type in read CSV not CSV without any arguments and you hit rid it says file is missing so I’m going to give it a file I’m going to give it a URL and the URL I’m going to give it is in quotes HTTP colon slash LD colon ette and I’m gonna make that window more visible please if you’re having any trouble following the commands or hearing me or understanding something this they’re not that many of us.

I don’t see we have six people so I’m one of them so let me know and I’m gonna I’m gonna put this data in a directory called files and the director name of the file is Co V ID dot CSV so if that command has worked I’ve got to give it a I have to give it an object so I’m gonna call it coded all right so there’s a command and if that command is successful R has gone off to that to that URL HTTP colon so on and so forth and it is buried burrow down into the files directory in that in my website and then it has gone and read the Cova dot CSV file so I’ll hit ctrl enter and it says on the bottom left of the our studio window it said that it read 147 observations of three variables and typically what I do is.

When I when I’ve created a new object I I try to investigate what it looks like one of the easiest things to do is to type head and you can see on the right-hand side of the screen so I’m going to make the whole screen bigger hope that I don’t know what that does for people again if you’re having any trouble seeing stuff or understanding things just put in a chat I have the chat window just to the right of my of my our studio window so we can see that on the upper right hand corner we’ve gotten a report from our that the object kovat is a at least three columns of data and if I actually want to know what kind of an object it is I can type in class coded and it tells me it’s a data frame.

I can find its dimension I already know those foot still 147 rose by three columns if I want to know a little bit more about its structure I can type in STR COV ID and that’s a it’s known the chat window just disappeared did I do that why would a chat window disappear I don’t know I’ll leave it so it says that it’s a data frame with 147 observations three variables as the date now let’s look at that date row it says that the date is a character variable.

The first value is quote 2020 – 0 1 – 23 and let me just do well on that a minute I’ve created this data set I created it from the USA facts org website they had formatted the dates in a different way but I’ve formatted the dates just as you would format a number with the big values at the beginning and the smaller values at the end so the first four characters represent the year separated by a dash and then the second two characters are the month and then the last two characters are the day so it’s very logically organized years are bigger than months are bigger than days but if.

I do a summary on this file or in this object so I’m going to make the script window a little smaller and the and the console window a little bigger if I do a summary on this file you can see it what it does is it summarizes as best it can information from the three columns of the data and again it reports that the cases have the minimum value of zero and a maximum of 374 three oh sorry three thirty seven thousand four hundred and the day range from a zero of a minimum of zero to a maximum of 3164 so let’s this I want to focus on date for the moment and come back and look at the cases and deaths so data is a character value which is not of any.

It’s not as much value to us as a as a analytical tool if we’re going to do some visualization we need to have date represented as some kind of a numeric object and but so let’s just let’s just clean that up and and let’s so what we can do is we can actually take kovat date the way I reference let’s just show you see so the way you can reference a specific column in a in a in a data frame is by representing the name of the data frame followed by the dollar sign not the naira sign followed by the name of the variable so I’ve just gotten the first six values of date and what I’m going to do is we’re going to transform Kovach date over in my script.

I’m going to assign it the value as date coded caller date and as I said if as I always said if if your what you’ve done is correct then you don’t get any response from the screen and again we didn’t get a response from the screen but I go up a couple of commands and type in summary kovat again we get a very different result for date data is now shown as a minimum of 22 – zero one – twenty-three and a maximum of 20 2006 – 17 which was two days ago so what I did was I went to the USA fact you’re not seeing the end of the console to the right oh so Allah they said that they’re not seeing the console I’m not sure yet Stephen asked are you on a mobile phone.

If you’re on a mobile phone I well item this is what’s the answer Emmanuel if you’re on a mobile phone maybe you are having trouble I think the can is everybody else able to see the entire screen – the four windows yeah last window yeah okay alright so what we’ve done is we transformed we’ve got via now have and I’m not going to go into any great details about what dates are although it’s a fundamental problem in understanding time series analysis but we now have a data frame consisting of three columns and if I go back to STR here I’m just going to move around the commands.

I’ve already typed it says that we have a data frame consisting again of 147 by 3 but now date is shown as a date class and the two other variables are shown as integers so we now have a date and what do I mean by that well let’s just let’s just spend a few minutes looking at date for example I can look at range Ovid cases and it says as we know it ranges from zero to thirty seven thousand four hundred now that means that for the data that I uploaded to my website the hundred and forty seven rows of that data frame report for each day the number of cases.

Those cases range from zero to 37,000 so which means that Rhys probably recently we don’t really know what the behavior of that variable is but if it’s an epidemic if that’s in the process of unfolding those that large number is probably occurring recently and the smaller numbers appear appear earlier but we can do the same thing with with with date and it says that the first date value is 20 21 23 which is January 23rd of this year and the last observation over the south the last one but the largest observation which also happens to be the last is June seventeenth two days ago.

Today’s Friday so that was on that was on Wednesday great but I can also for example do look at the difference of the rain so I’m going to go up and type in di FF and I’m going to put a close parenthesis so what I’m asking our to do is compute the difference between those two values and it does an interesting thing when I type control enter it says 146 days so it’s able to turn it’s able to interpret that difference of days into an actual value which consists of 146 days so say instead of going to a calendar and asking how many days there are between January 23rd and June 17 it gives us it does the computation for us and if indeed the days were much.

If the difference in those days was much larger it might report the difference in years I’m not sure it would reported in months and so forth so it so it is now transformed that data into a into a on a zooming remember it’s transform that date into it into a date object that we can do some we can do some computations on let’s go back then to the so we now have a data frame which is a data object and two integers let’s look at the case data I’m going to put put a command and now I’m going to put up a comment description of totals so let’s look at the at the totals.

Let’s look at some coded cases that’s like a death so what it’s done is it’s taken the cut that column and if I it says that the number of deaths that have occurred in the United States the number of reported deaths and again when I teach classes on epidemiology we spend a lot of time on the difference between the reported deaths on the actual desk there’s been a great deal of controversy in the US about whether all of the people who are dying of koba’s 19 are being reported as having done so and it’s not an easy decision to make sometimes to report one of what the cause of death is but it says that over the course of the over the course of the epidemic so far we have had in the u.s. about 117 thousand deaths.