So now let’s read the “MayWeather” tab of the googlesheet into R as a dataframe, and inspect the structure of the data using the handy str() function. In our last step, we prepared our connection with Google Sheets, and in this step, we’ll import the data. This is the one tab in the Google Sheet that contains the weather data for the month of May. When you execute this command, you should see the word “MayWeather” printed out on the console, which is the box in the bottom left. Enter the following line of code into your environment, highlight them with your cursor, and press ctrl+enter to execute them.Īt this point you should see a new variable titled “WeatherDataURL” in the upper righthand box, as can be seen in the image below.īefore we move on to the next step, let’s execute one more line of code, which allows us to inspect our new variable, “WeatherDataURL.” Now that you’ve installed the package, you can import the data. The first line tells the computer to install the package titled “googlesheets,” and the second line tells the computer to turn on the package, making it available for you to use. To install this particular package, you execute the following lines of code: Going through this step is also a useful introduction to the concept of packages, which are functions created by other members of the R programming community. Fortunately, there is a handy package for Google Sheets data access. To get the googlesheets data into R, you need to import it. You can see that dataset here.īefore we go on, I should note that you can import data into RStudio in many different ways. So, I pulled in some rainfall data from the National Oceanic and Atmospheric Administration. The greater Washington, D.C., area experienced a recordbreaking month of rainfall. Looking back on May in Washington, D.C., one of the recurring themes of the month was RAIN. You can, of course, build up a dataset directly in RStudio, but it’s nice to have something to work with when first exploring the programming language.įor the sake of this exercise, I’ve created a dataset in Google Sheets for you to work with. The next thing to do when getting started in R, is to identify a dataset you’d like to work with. Once you get your software installed and booted up, you should see something that looks approximately like the image below. Step 0: Install R and RStudioįirst, you’ll need to install R and RStudio on your computer. You could, of course, accomplish each of these tasks directly in Google Sheets, but bringing the data into RStudio opens up a new world of analytical possibilities. In this exercise, we’re going to execute the following commands: 1) install and start necessary packages, 2) bring a dataset into your work environment, 3) inspect your data to help you think about how it is structured, 4) convert your datatypes into useful data formats, 5) plot the data on a line graph. In this post, I’m going to introduce a few lines of code to get you started on your journey into R. You could also do this work in a business intelligence application such as Tableau or PowerBI, or conduct statistical analysis in STATA, but R and RStudio are free and open source. You could arguably do data analysis in almost any computer programming language, but R offers some of the most accessible statistical functions of any language available today. RStudio is an open source integrated development environment (IDE) for the R programming language, which focuses on programming for statistical analysis. This article is part 1 of 2, as we explore the basics of importing and analyzing data in RStudio.Īs a data scientist, I spend a lot of my time working in a programming language called R.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |