Import a local file
In this part of the chapter you'll learn how to import .xls files using the gdata package. Similar to the readxl package, you can import single Excel sheets from Excel sheets to start your analysis in R.
You'll be working with the urbanpop.xls dataset, the .xls version of the Excel file you've been working with before. It's available in your current working directory.
This exercise is part of the course
Importing Data in R (Part 1)
Exercise instructions
- Load the
gdatapackage withlibrary().gdataand Perl are already installed on DataCamp's Servers. - Import the second sheet, named
"1967-1974", of"urbanpop.xls"withread.xls(). Store the resulting data frame asurban_pop. - Print the first 11 observations of
urban_popwithhead().
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Load the gdata package
# Import the second sheet of urbanpop.xls: urban_pop
# Print the first 11 observations using head()