Challenge 1 Solution

challenge_1
railroads
faostat
wildbirds
Reading in data and creating a post
Author

Shuqi Hong

Published

June 2, 2023

Code
library(tidyverse)
knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE)
library(readxl)

Challenge Overview

Today’s challenge is to

  1. read in a dataset, and

  2. describe the dataset using both words and any supporting information (e.g., tables, etc)

Read in the Data

I’ve already tried to read all of such files and just show wild_bird_data.xlsx in challenge 1 cuz I believe it is representative.

Code
wild_bird_from_xlsx <- read_excel("../posts/_data/wild_bird_data.xlsx", skip = 1)
head(wild_bird_from_xlsx)
# A tibble: 6 × 2
  `Wet body weight [g]` `Population size`
                  <dbl>             <dbl>
1                  5.46           532194.
2                  7.76          3165107.
3                  8.64          2592997.
4                 10.7           3524193.
5                  7.42           389806.
6                  9.12           604766.

Describe the data

There are 146 rows and 2 columns in this file. From this table we can see the left column is describing the wild birds’ weight and the right one is the population of such weights. The type of both columns are double and no character.

Code
glimpse(wild_bird_from_xlsx)
Rows: 146
Columns: 2
$ `Wet body weight [g]` <dbl> 5.458872, 7.764568, 8.638587, 10.689735, 7.41722…
$ `Population size`     <dbl> 532194.3951, 3165107.4454, 2592996.8678, 3524193…
Code
spec(wild_bird_from_xlsx)
NULL
Code
typeof(wild_bird_from_xlsx$`Population size`)
[1] "double"
Code
typeof(wild_bird_from_xlsx$`Wet body weight [g]`)
[1] "double"

I’m trying to calculate the average weight of all the birds, but I didn’t succeed cuz I don’t know how to write the code. I used “summary” to do that but it just gave the average of each column but not the whole table.