Project One Intro

Project one is learning how to take data from a web site and turning turing into data we can use for analysis. We take the same data and loaded it three different ways.

  • Through using a data frame.

  • Using a csv file.

  • And web scraping.

Creating a data frame

Make a data frame for the lifespans of some animals given in the first table of the webpage. The data frame should have two columns: Animal and AverageLifespan. Use the kable function to print the data.

animalname <- c("Antelope (Blackbuck)", "Antelope (Pronghorn)", "Badger",   "Bat (Guano)",  "Bear (Grizzly)",   "Beaver",   "Boa Constrictor",  "Buffalo",  "Bullfrog", "Carp", "Cat (Domestic)",   "Chameleon",    "Chickadee",    "Chimpanzee",   "Condor",   "Cottonmouth",  "Crappie",  "Crocodile",    "Deer (Fallow)",    "Deer (Mule)",  "Deer (Whitetail)", "Dog (Domestic)",   "Donkey",   "Dove", "Eagle (Golden)",   "Elephant (Indian)",    "Flounder", "Fox",  "Frog (Leopard)",   "Garter Snake", "Gila Monster", "Giraffe",  "Goat", "Goose (Canada)",   "Guinea Pig",   "Heron",    "Herring Gull", "Horse",    "Javelina", "Jay (Blue)",   "King Snake",   "Lion", "Lizard (Anole)",   "Mole", "Mountain Lion",    "Mule", "Nutria",   "Opossum",  "Ostrick (African)",    "Owl (Snowy)",  "Penguin (King)",   "Perch",    "Pigeon",   "Pike", "Porcupine",    "Porpoise", "Python",   "Quail",    "Rabbit",   "Raccoon",  "Rattlesnake",  "Raven",    "Reindeer", "Rhinoceros",   "Robin",    "Salamander (Spotted)", "Seahorse", "Seal (Common)",    "Sheep (Mouflon)",  "Shrew",    "Skunk",    "Skylark",  "Sparrow",  "Squirrel (Fox)",   "Squirrel (Gray)",  "Starling", "Sturgeon", "Trout (Rainbow)",  "Turkey",   "Turtle (Box)", "Water Snake",  "Whale (Blue)", "Wolf", "Zebra")

animallife <- c(15, 15, 15, 15, 34, 20, 23, 45, 15.5,   50, 30, 3.5,    7,  50, 52, 21, 6,  13.5,   25, 20, 23, 20, 50, 12, 80, 70, 10, 14, 6,  6,  20, 28, 10, 32, 5,  24, 50, 35, 20, 4,  14.5,   35, 6,  3,  18, 37, 12, 8,  50, 24, 26, 11, 35, 24, 20, 15, 20, 10, 10, 13, 18.5,   69, 15, 40, 12, 25, 6,  30, 19, 2,  12, 24, 20, 10, 18, 15, 50, 4,  15, 123,    7,  35, 16, 30)

animal <- tibble(
  'Animal' =animalname,
  'Life Span' =animallife) 

knitr::kable(animal,
             format = 'pandoc',
             align = 'lr')
Animal Life Span
Antelope (Blackbuck) 15.0
Antelope (Pronghorn) 15.0
Badger 15.0
Bat (Guano) 15.0
Bear (Grizzly) 34.0
Beaver 20.0
Boa Constrictor 23.0
Buffalo 45.0
Bullfrog 15.5
Carp 50.0
Cat (Domestic) 30.0
Chameleon 3.5
Chickadee 7.0
Chimpanzee 50.0
Condor 52.0
Cottonmouth 21.0
Crappie 6.0
Crocodile 13.5
Deer (Fallow) 25.0
Deer (Mule) 20.0
Deer (Whitetail) 23.0
Dog (Domestic) 20.0
Donkey 50.0
Dove 12.0
Eagle (Golden) 80.0
Elephant (Indian) 70.0
Flounder 10.0
Fox 14.0
Frog (Leopard) 6.0
Garter Snake 6.0
Gila Monster 20.0
Giraffe 28.0
Goat 10.0
Goose (Canada) 32.0
Guinea Pig 5.0
Heron 24.0
Herring Gull 50.0
Horse 35.0
Javelina 20.0
Jay (Blue) 4.0
King Snake 14.5
Lion 35.0
Lizard (Anole) 6.0
Mole 3.0
Mountain Lion 18.0
Mule 37.0
Nutria 12.0
Opossum 8.0
Ostrick (African) 50.0
Owl (Snowy) 24.0
Penguin (King) 26.0
Perch 11.0
Pigeon 35.0
Pike 24.0
Porcupine 20.0
Porpoise 15.0
Python 20.0
Quail 10.0
Rabbit 10.0
Raccoon 13.0
Rattlesnake 18.5
Raven 69.0
Reindeer 15.0
Rhinoceros 40.0
Robin 12.0
Salamander (Spotted) 25.0
Seahorse 6.0
Seal (Common) 30.0
Sheep (Mouflon) 19.0
Shrew 2.0
Skunk 12.0
Skylark 24.0
Sparrow 20.0
Squirrel (Fox) 10.0
Squirrel (Gray) 18.0
Starling 15.0
Sturgeon 50.0
Trout (Rainbow) 4.0
Turkey 15.0
Turtle (Box) 123.0
Water Snake 7.0
Whale (Blue) 35.0
Wolf 16.0
Zebra 30.0

Using a csv file

Create an Excel spreadsheet for the data with the same column names as in (a). Upload the data to rstudio.cloud. Use the an R function to print the data nicely.

Average Life Span of an Animal in Years
Animal Average Life Span
Antelope (Blackbuck) 15
Antelope (Pronghorn) 15
Badger 15
Bat (Guano) 15
Bear (Grizzly) 34
Beaver 20
Boa Constrictor 23
Buffalo 45
Bullfrog 16
Carp 50
Cat (Domestic) 30
Chameleon 4
Chickadee 7
Chimpanzee 50
Condor 52
Cottonmouth 21
Crappie 6
Crocodile 14
Deer (Fallow) 25
Deer (Mule) 20
Deer (Whitetail) 23
Dog (Domestic) 20
Donkey 50
Dove 12
Eagle (Golden) 80
Elephant (Indian) 70
Flounder 10
Fox 14
Frog (Leopard) 6
Garter Snake 6
Gila Monster 20
Giraffe 28
Goat 10
Goose (Canada) 32
Guinea Pig 5
Heron 24
Herring Gull 50
Horse 35
Javelina 20
Jay (Blue) 4
King Snake 14
Lion 35
Lizard (Anole) 6
Mole 3
Mountain Lion 18
Mule 37
Nutria 12
Opossum 8
Ostrick (African) 50
Owl (Snowy) 24
Penguin (King) 26
Perch 11
Pigeon 35
Pike 24
Porcupine 20
Porpoise 15
Python 20
Quail 10
Rabbit 10
Raccoon 13
Rattlesnake 18
Raven 69
Reindeer 15
Rhinoceros 40
Robin 12
Salamander (Spotted) 25
Seahorse 6
Seal (Common) 30
Sheep (Mouflon) 19
Shrew 2
Skunk 12
Skylark 24
Sparrow 20
Squirrel (Fox) 10
Squirrel (Gray) 18
Starling 15
Sturgeon 50
Trout (Rainbow) 4
Turkey 15
Turtle (Box) 123
Water Snake 7
Whale (Blue) 35
Wolf 16
Zebra 30

Web scraping

Use a web scraping tool to collect the data. Use the kable function to print the data.

Average Animal Life Span
Animal Life Span
Antelope (Blackbuck) 15.0
Antelope (Pronghorn) 15.0
Badger 15.0
Bat (Guano) 15.0
Bear (Grizzly) 34.0
Beaver 20.0
Boa Constrictor 23.0
Buffalo 45.0
Bullfrog 15.5
Carp 50.0
Cat (Domestic) 30.0
Chameleon 3.5
Chickadee 7.0
Chimpanzee 50.0
Condor 52.0
Cottonmouth 21.0
Crappie 6.0
Crocodile 13.5
Deer (Fallow) 25.0
Deer (Mule) 20.0
Deer (Whitetail) 23.0
Dog (Domestic) 20.0
Donkey 50.0
Dove 12.0
Eagle (Golden) 80.0
Elephant (Indian) 70.0
Flounder 10.0
Fox 14.0
Frog (Leopard) 6.0
Garter Snake 6.0
Gila Monster 20.0
Giraffe 28.0
Goat 10.0
Goose (Canada) 32.0
Guinea Pig 5.0
Heron 24.0
Herring Gull 50.0
Horse 35.0
Javelina 20.0
Jay (Blue) 4.0
King Snake 14.5
Lion 35.0
Lizard (Anole) 6.0
Mole 3.0
Mountain Lion 18.0
Mule 37.0
Nutria 12.0
Opossum 8.0
Ostrick (African) 50.0
Owl (Snowy) 24.0
Penguin (King) 26.0
Perch 11.0
Pigeon 35.0
Pike 24.0
Porcupine 20.0
Porpoise 15.0
Python 20.0
Quail 10.0
Rabbit 10.0
Raccoon 13.0
Rattlesnake 18.5
Raven 69.0
Reindeer 15.0
Rhinoceros 40.0
Robin 12.0
Salamander (Spotted) 25.0
Seahorse 6.0
Seal (Common) 30.0
Sheep (Mouflon) 19.0
Shrew 2.0
Skunk 12.0
Skylark 24.0
Sparrow 20.0
Squirrel (Fox) 10.0
Squirrel (Gray) 18.0
Starling 15.0
Sturgeon 50.0
Trout (Rainbow) 4.0
Turkey 15.0
Turtle (Box) 123.0
Water Snake 7.0
Whale (Blue) 35.0
Wolf 16.0
Zebra 30.0
Animal Life Span
Antelope (Blackbuck) 15.0
Antelope (Pronghorn) 15.0
Badger 15.0
Bat (Guano) 15.0
Bear (Grizzly) 34.0
Beaver 20.0
Boa Constrictor 23.0
Buffalo 45.0
Bullfrog 15.5
Carp 50.0
Cat (Domestic) 30.0
Chameleon 3.5
Chickadee 7.0
Chimpanzee 50.0
Condor 52.0
Cottonmouth 21.0
Crappie 6.0
Crocodile 13.5
Deer (Fallow) 25.0
Deer (Mule) 20.0
Deer (Whitetail) 23.0
Dog (Domestic) 20.0
Donkey 50.0
Dove 12.0
Eagle (Golden) 80.0
Elephant (Indian) 70.0
Flounder 10.0
Fox 14.0
Frog (Leopard) 6.0
Garter Snake 6.0
Gila Monster 20.0
Giraffe 28.0
Goat 10.0
Goose (Canada) 32.0
Guinea Pig 5.0
Heron 24.0
Herring Gull 50.0
Horse 35.0
Javelina 20.0
Jay (Blue) 4.0
King Snake 14.5
Lion 35.0
Lizard (Anole) 6.0
Mole 3.0
Mountain Lion 18.0
Mule 37.0
Nutria 12.0
Opossum 8.0
Ostrick (African) 50.0
Owl (Snowy) 24.0
Penguin (King) 26.0
Perch 11.0
Pigeon 35.0
Pike 24.0
Porcupine 20.0
Porpoise 15.0
Python 20.0
Quail 10.0
Rabbit 10.0
Raccoon 13.0
Rattlesnake 18.5
Raven 69.0
Reindeer 15.0
Rhinoceros 40.0
Robin 12.0
Salamander (Spotted) 25.0
Seahorse 6.0
Seal (Common) 30.0
Sheep (Mouflon) 19.0
Shrew 2.0
Skunk 12.0
Skylark 24.0
Sparrow 20.0
Squirrel (Fox) 10.0
Squirrel (Gray) 18.0
Starling 15.0
Sturgeon 50.0
Trout (Rainbow) 4.0
Turkey 15.0
Turtle (Box) 123.0
Water Snake 7.0
Whale (Blue) 35.0
Wolf 16.0
Zebra 30.0