Hands-On Lab - Importing Data in R
Hands-On Lab - Importing Data in R
cloud-object-
storage.appdomain.cloud/IBMDeveloperSkillsNetwork-RP0101EN-Coursera/v2/dataset/movies-db.xls",
destfile="movies-db.xls") download.file("https://cf-courses-data.s3.us.cloud-object-
storage.appdomain.cloud/IBMDeveloperSkillsNetwork-RP0101EN-Coursera/v2/dataset/movies-db.csv",
destfile="movies-db.csv")
A data.frame: 30 × 8
name year length_min genre average_rating cost_millions foreign age_restriction
The Shawshank
1994 142 Crime 9.3 25.0 0 16
Redemption
In [3]:
In [7]: head(my_data)
A data.frame: 6 × 8
name year length_min genre average_rating cost_millions foreign age_restriction
In [8]: str(my_data)
In [9]: library(readxl)
In [11]: str(my_excel_data)
In [12]: my_data['name']
A data.frame: 30 × 1
name
<fct>
Toy Story
Akira
The Artist
Modern Times
Fight Club
City of God
The Untouchables
American Beauty
Room
Dr. Strangelove
The Ring
Taxi Driver
Interstellar
Casino
The Goodfellas
Black Swan
The Wave
Whiplash
Jumanji
Chicago
In [13]: my_data$name
Toy Story · Akira · The Breakfast Club · The Artist · Modern Times · Fight Club · City of God ·
The Untouchables · Star Wars Episode IV · American Beauty · Room · Dr. Strangelove · The Ring ·
Monty Python and the Holy Grail · High School Musical · Shaun of the Dead · Taxi Driver ·
The Shawshank Redemption · Interstellar · Casino · The Goodfellas · Blue is the Warmest Colour ·
Black Swan · Back to the Future · The Wave · Whiplash · The Grand Hotel Budapest · Jumanji ·
The Eternal Sunshine of the Spotless Mind · Chicago
Levels:
In [14]: my_data[["name"]]
Toy Story · Akira · The Breakfast Club · The Artist · Modern Times · Fight Club · City of God ·
The Untouchables · Star Wars Episode IV · American Beauty · Room · Dr. Strangelove · The Ring ·
Monty Python and the Holy Grail · High School Musical · Shaun of the Dead · Taxi Driver ·
The Shawshank Redemption · Interstellar · Casino · The Goodfellas · Blue is the Warmest Colour ·
Black Swan · Back to the Future · The Wave · Whiplash · The Grand Hotel Budapest · Jumanji ·
The Eternal Sunshine of the Spotless Mind · Chicago
Levels:
A data.frame: 1 × 2
name length_min
<fct> <int>
1 Toy Story 81
In [16]: data()
Data sets
A data.frame: 104 × 3
Package Item Title
datasets EuStockMarkets Daily Closing Prices of Major European Stock Indices, 1991-1998
datasets trees Girth, Height and Volume for Black Cherry Trees
Use ‘data(package = .packages(all.available = TRUE))’ to list the data sets in all *available* packages.
In [17]: help(women)
Usage
women
Format
A data frame with 15 observations on 2 variables.
Details
The data set appears to have been taken from the American Society of Actuaries Build and Blood Pressure
Study for some (unknown to us) earlier year.
The World Almanac notes: “The figures represent weights in ordinary indoor clothing and shoes, and heights
with shoes”.
Source
The World Almanac and Book of Facts, 1975.
References
McNeil, D. R. (1977) Interactive Data Analysis. Wiley.
Examples
require(graphics)
plot(women, xlab = "Height (in)", ylab = "Weight (lb)",
main = "women data: American women aged 30-39")
In [18]: women
A data.frame: 15
×2
height weight
<dbl> <dbl>
58 115
59 117
60 120
61 123
62 126
63 129
64 132
65 135
66 139
67 142
68 146
69 150
70 154
71 159
72 164
In [20]: summary(my_data)
In [ ]: