library(readr)
library(tidyr)

stock_df <- read_csv("stock_df.csv")
## Rows: 5 Columns: 106
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr   (1): company
## dbl (105): 2019_week1, 2019_week2, 2019_week3, 2019_week4, 2019_week5, 2019_...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
stock_df_long <- pivot_longer(stock_df, 
                              cols = -company, 
                              names_to = "week", 
                              values_to = "price",
                              names_prefix = "2019_week")

stock_df_long$year <- 2019

head(stock_df_long)
## # A tibble: 6 × 4
##   company week  price  year
##   <chr>   <chr> <dbl> <dbl>
## 1 Amazon  1     1848.  2019
## 2 Amazon  2     1641.  2019
## 3 Amazon  3     1696.  2019
## 4 Amazon  4     1671.  2019
## 5 Amazon  5     1626.  2019
## 6 Amazon  6     1588.  2019

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.