In this video, we'll explore working in RStudio. Our learning objectives are to be able to create an import data files into RStudio, to access and install R packages, and work with data frames. Throughout our course, we will be using RStudio to port, handle and analyze data. Because RStudio requires R to work, you will need to install both on your computer. Keep in mind that R is the programming language and RStudio is the user interface. The first step is to download R and you may do so at www. r-project.org. On the left-hand side of the page under download, click on CRAN, which stands for Comprehensive R Archive Network. Next, you'll choose a CRAN mirror that is closest to you geographically. Once you've done so, select your operating system to download install R. You'll want to select the base distribution. Step Number 2 is to install RStudio. You can download RStudio at www.rstudio.com. Once you get to the RStudio website, click on the words, ''Download'' at the top of the page. Then scroll down to the free version of RStudio Desktop and click on the Download button underneath. Now you'll find the correct download for your operating system and click on the link to download. Now that we have R and RStudio installed, let's take a look at RStudio. Each time we open RStudio, we'll start by opening a new script file, by clicking on File, New File, and R script. You'll note that RStudio has four different frames and each frame has a different purpose. This frame is the script editor or Source Window is where you can create, edit, and save scripts. Your R code can be run by simply highlighting the code you want to run and pressing the Run button. We use this area to write our code because in this window the code can be edited or saved at any time. Another way to execute code is to simply place your cursor on the line of code you would like to run and hit the run button to transfer the code into the console where it will be executed. The lower left quadrant is the console area where the R code is executed and results are viewed. To the right of that is the area where we view plots, get help and install and unload packages. In this area, you can view any plots you create. Get help for R or installer load packages. The top right quadrant is the environment and history area. We use this area to import data as well as view any history of code executed. You can also see information about the files that have been imported, such as the number of variables and the number of observations in the data set. The main package we'll be using for our course is called LOLcat. To install LOLcat, you'll need to execute the following code once. This is the code. Let's do that now, in the script editor. In the script editor, we will type these three lines of code, install.packages and in quotes type in devtools. Next, type require devtools. Finally, install-githubburrm/lolcat. To run these three lines of code, we can simply put our cursor here and run this line of code by itself. Or we can highlight the code and run the remainder. Now of course I already have this installed on my computer, so I'm not going to finish running it at this time. Once you've installed the lolcat package, and once you've installed any package, for that matter, you'll need to load it anytime you open RStudio. We can do this by using the words require or library. The name of the package will go inside the parentheses. Once you've executed this command, you can then use the package and the functions in the package you've loaded. For lolcat, we can simply type in require and type the name of the package. You'll see that lolcat is now loaded and we can use the functions that are in it. Before we start working with datasets in R there are few things of importance for you to know. First, know that R is case sensitive. If you are repeatedly getting an error, it is possible that you've mistakenly typed in a lowercase or uppercase letter somewhere in your code. Secondly, if you'd like to put a comment into your code, you can use the hashtag symbol. Anything typed to the right of this symbol will not be executed. Lastly, one of the most frequently used operators in R is the assignment operator, which looks like a left pointing arrow. The assignment operator allows us to assign numbers, equations, vectors, variables, and data frames. Let's take a look at an example in R. In the script editor type in the following code, x and the assignment operator 15. Now I'll simply place my cursor here to execute this code by pushing run. Now in the console area, if I was to type the letter x, you'll see that it returns a value of 15. This shows us that we have assigned the number 15 to the variable x. To clear your screen, you can hold down your control key or command key and push the letter L on your keyboard. Let's try another example. Perhaps I would like to create a sequence or a vector of numbers. Let's look at this in an example. In the script editor, we'll type the following code. Y assignment operator, C, meaning I'm creating a vector, 1, 2, 3, 4, 5. I'll highlight this code. Actually put my cursor at the front of it, type run. In the console, when I push y, you'll see that it returns a string of numbers of sequential numbers, 1, 2, 3, 4, 5, and we've assigned that to the variable y. Next we're going to import data into R. We're going to import the example file from the Module 1 data called sample.txt. To do so, click the Environment tab and specifically select the Import Dataset button. Select the from text base option. Browse to the folder where you have saved the information and select it and click the Open button. Once you do so, you'll see a dialog box open. Be sure to click the radio button that says yes to indicate that your data has headers. Then click Import. Once I click Import, you'll see the name of my file and the different columns and variables that are in that file. The data sets will be using in our course will be imported like this. They're going to have a different variable names within the data frame. To select a variable, we use the data frame dollar sign variable syntax. For example, let's say we want to calculate the mean of the 10 values in the weight column right here. To do so, we would simply type in the following code. This time I'm going to type it directly into the console. I would type in mean, sample, dollar sign and select the weight variable. Then click on Enter, and you'll see that we've calculated the arithmetic average for the 10 weight values.