First blog post using Distill

I’m going to make my first blog post. Once I figure that out, I’ll try reading in some data.I am also experimenting with R Markdown text formatting such as bold text and italics

~
09-29-2021

First I need to load my packages by using the library command and this chunk:

{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) library(tidyverse) library(readr) library(readxl)

But oh no. I want this code to be displayed in 4 rows. This can be done by adding two spaces at the end of each line:

{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(readr)
library(readxl)
library(csv)

I’m going to in work with data from the set about cereal. I want to first establish my working directory. I can find the current working directory with the command getwd()

getwd()
[1] "C:/Users/advai/OneDrive/Desktop/DACSS/DACSS601Fall21/_posts/2021-09-29-first-blog-post-using-distill"

I’m going to set the directory just to be sure I’m working with the right folders and files.

#setwd("~/R/DACSS601Fall21/_posts/2021-09-29-first-blog-post-using-distill")

Now I’m going to read in a csv data set about cereal. This following chunk creates a new tab that contains a table with the cereal data

cereal <- read.csv("cereal.csv")
View(cereal)

If I need to figure out the dimensions of the data set, or get other information, I can use a number of commands. Using dim() returns info on the dimensions. In this case, there are 20 rows and 4 columns in the cereal.csv file.

dim(cereal)
[1] 20  4

I can use colnames() to get the name of each column. In this case, the column names are “Cereal”, “Sodium”, “Sugar” and “Type”

colnames(cereal)
[1] "Cereal" "Sodium" "Sugar"  "Type"  

Since I assigned the csv file to the variable cereal, I can retrieve the data by simply calling the function by writing “cereal”.

cereal
                  Cereal Sodium Sugar Type
1    Frosted Mini Wheats      0    11    A
2            Raisin Bran    340    18    A
3               All Bran     70     5    A
4            Apple Jacks    140    14    C
5         Captain Crunch    200    12    C
6               Cheerios    180     1    C
7  Cinnamon Toast Crunch    210    10    C
8     Crackling Oat Bran    150    16    A
9              Fiber One    100     0    A
10        Frosted Flakes    130    12    C
11           Froot Loops    140    14    C
12 Honey Bunches of Oats    180     7    A
13    Honey Nut Cheerios    190     9    C
14                  Life    160     6    C
15         Rice Krispies    290     3    C
16          Honey Smacks     50    15    A
17             Special K    220     4    A
18              Wheaties    180     4    A
19           Corn Flakes    200     3    A
20             Honeycomb    210    11    C

These are the very basics of reading in data. I am excited to keep learning how to use R and R Markdown, and how to manipulate and utilize data.

Distill is a publication format for scientific and technical writing, native to the web.

Learn more about using Distill at https://rstudio.github.io/distill.

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY-NC 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".