Getting started with R and RStudio

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone my name is Mike and I'm going to introduce you to our and to our studio which we'll get to in a few minutes first just so you know R is a statistical programming language it's open source which means it's free which means that there are lots of people who actively work on it making it better developing new things that it can do new capabilities it's just that's the nature of it it also means that there is a huge community out there that is willing to help when you have issues or things you need to do that you don't understand how to do they can help you with and it's also a scripting language which means that you write code so here I've opened up our this is the console you actually type in commands this is a command I'm assigning the value 1 to a and it creates a so it is a scripting language which also means you can write functions which is where the power lies because it's scripting actually is more powerful and much more flexible and it's open source meaning that people have developed 1,300 packages as hundreds and hundreds of things packages that help are do lots of different things it can work in maps you can create incredibly gorgeous graphics which by the way the New York Times Twitter Facebook all use our Google uses are it is a phenomenal language however this is the this is the standard way it looks when you download it and it's really not that great but first let's talk about a little bit about how to get our to get our you go to crayon dot our project org you click on whatever operating system you have I have a Mac so go there and then you download the package here for a Mac you download it install it just like any other pack inch or the Windows machine you go there you get bass well notice it says here this is what we want to do to install our for the first time you click that and see what you want there you go so download it right there and you will download it install it and it'll be on your computer but I don't recommend honestly using the vanilla version of the GUI interface it's just not that useful it's cumbersome you're moving Windows it's just difficult so I'm going to introduce you to our studio which is what this is you see here this is my my art studio now our studio you can get at our studio comm let's go ahead and go to our studio comm this is what it looks like when you first get there and you go to download now and you download it the desktop and it'll tell you when you click it it'll recommend one for your system it knows what kind of computer you have and you download that and install it now what our studio is is a development tubes a development environment for our it's a place that is built to make using are as effective and efficient as possible and it really does that our studio is really very good it has a console which is this down here where the commands are run it has a source editor which is where you can type in commands and script and save it for later it also has a workspace which has tells you the things that you've already created so I've created the variable ABC this ins thing it has a history so it keeps the commands that you have done and used and you can actually reuse those you can double click and they will be entered into the console and hit enter and it will actually execute or you can shift double-click and it'll go into the source editor which is pretty awesome and you can see where you entered that so say you want to know what were the what was the code before and after that when I enter that in whenever that was you click on this little arrow and it will take you there in fact even tells you win like the date and time and you can go back it also has a file browser now in the default version it's down here I've moved it up here and that's something you can do the options but it shows you where you are which is important and also lets you change the working directory so if you navigate somewhere so click on these ellipses is one way to navigate and you want to go say to the desktop it happened to be that I was already at the desktop but you can say go home and let's say I want to go to excuse me my box documents okay I can set that as working directory which means now our is going to be working from there our assumes it draws it has an easier place to call home we all need a home and ours home is the working directory and it assumes anything you enter in as a file name is going to draw from that folder or directory and so now we've said this is the working directory okay it it also has packages which are bundles of functions so these functions each function does something for you you put in some inputs it does some things to them and gives you outputs and packages or bundles of functions one such package is called tree and it does classification regression trees this other one that shows up here is OpenStreetMap it gives you access to maps and raster images which means you can do some really cool map things it also our studio also has plots you see I've created a plot here and you can see a plot history by going forward and backward and it also has a help the help is built-in so let's say you want to learn about the function which dot min you hit it in this search bar and it comes up and it tells you what it does determines the location ie index of the first minimum or maximum of a numeric vector there you go pretty amazing it also executes code so if you are in the source editor you can I'm going to hold command because I'm on a Mac but if you are in on a Windows machine you hit ctrl and you just hit command enter ctrl enter and step through the code and notice right here it skipped these blank lines that's really useful when you're doing this a lot or you can just highlight sections of code say I want to do these or let's say I just want to do a subset let's just say I just want to see that looks like like highlight it ctrl enter and then I see down here those values so very powerful in that way it also has code completion so let's say we want to look at some of the arguments in plot so notice I started it and I hit tab that's tab okay whoops it brings up the options and I can actually just go ahead and select one say X and I'm going to make it to be 1 through 10 and then I can hit comma in the next tab I can do it again and choose another thing just like that and then it plots so pretty awesome you can also complete file paths so let's say I have a I want to read in something and so what I did was I said look if I want to read something in a file path has to be a character string so you put it in quotes and it's literal so everything in there is a literal and I hit tab and it goes and it shows me all the potential file paths in the directory I'm in just putting any of you of course if you were to start putting one in it just it filters down to those so all files that begin of B all files it begins Bo X and so on now we're not going to use that but that's just to demonstrate also you can just go hit up and it'll go to previous things you've entered blocks of code that you've enter notice here it's got two lines because I selected two lines and it put it in there so that's a another fun feature that doesn't actually exist in our vanilla version to have blocks of code like that so another reason to get our studio it also has code navigation so if you hit command F in in on a Mac or ctrl F you can search things in your code say find all sections that have have the word data in there you can go next previous credits the only thing in there you can even replace so if you try to use a file on over and over again for different things where you can tweak a little bit that's a way to do it you can also find files or functions so it will find files for you up here in this option up here so you can if you've written a function or if there's a function that you know is open here somewhere you can find it by typing in the name of the function I don't have any open here but that's what that does and it also if I had more than one document open I could go backward or forward in in the documents that are opened here in these tabs there would be tabs there also you can create projects this is a project I created called how to are just makes it easier but I have other things that I'm working on as well right so if I wanted to go to my paper project I would click on that and go there you can also create projects and create a project and bring up this option you can do a new project and a new directory using an existing directory and version control we won't talk about that but that's pretty powerful as well and projects are nice because what it does is it saves your workspace so it saves everything that you've got open there save your workspace saves your history it even saves the pane layout so the way that you have gotten these you can adjust how this looks so it even saves how you've you've made it look for yourself which is makes it easier in the future you can also go going back to the plots I didn't explain you can export plots you can save them as a raster or you can save them in a vector format like PDF you can copy it to clipboard other things you can also go back and forth like I said it so it has quite a bit of functionality and finally it has help built in and I'm emphasizing that again using it simply because to learn are you're going to need a lot of help and so some other resources for for getting help with are is this page called step methods so quick are and and you can search functions so what if you want to know more about which type it in it excuse me and it's not working for some reason okay there we go okay so I just looked up a function called LM and I'm going to type the first one and it talks about multiple linear regression or let's say I want to look up indexing okay it's got some different things so subsetting data there we go here are ways you can subset data it's very very very helpful and it's written you know it explains it nicely he has a code commented he has code directly there a really great way to get help you can also use a basically filter Google search that highlights things in our here in our seek so you want to learn about linear regression put it in there and it loads and here is a tutorial somebody has created talking about how to do it and this is actually another really great site our bloggers if you get into our it there are people who actively develop new ways of doing things and show new capabilities of our and you can find out about them there anyway so that is our studio in a nutshell and our we'll talk a little bit more about how to actually do certain things in another video but there you go that's our studio so thanks so much glad you're here listening to how to R please comment you have any questions if you have anything nice you want to say just comment and subscribe tell your friends so everyone can become brilliant our users all right thanks so much have a go
Info
Channel: How To R
Views: 598,292
Rating: 4.7727399 out of 5
Keywords: R (Programming Language), RStudio, Introduction to R
Id: lVKMsaWju8w
Channel Id: undefined
Length: 14min 38sec (878 seconds)
Published: Tue Sep 10 2013
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.