# Load the tidyverse package
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
# Read the data
data <- read.table(text = "
  company  2019_week13  2019_week14  2019_week15  2019_week16  2019_week17  2019_week18  2019_week19  2019_week20  2019_week21  2019_week22
  Amazon   1847.839966  1640.560059  1696.199951  1670.569946  1626.22998   1588.219971  1607.949951  1631.560059  1671.72998   1620.800049
  Apple    73.412498   38.072498   39.205002   39.439999   41.630001   42.602501   42.605     43.2425     43.7425     43.227501
  Facebook 205.25       143.800003  150.039993  149.009995  165.710007  167.330002  162.5      161.889999  162.279999  169.600006
  Google   1337.02002   1057.189941 1098.26001  1090.98999  1110.75    1095.060059 1113.650024 1110.369995 1140.98999 1142.319946
  Microsoft 157.699997 102.800003 107.709999 107.169998 102.779999 105.669998 108.220001 110.970001 112.529999 110.510002
", header = TRUE)

# Reshape the data from wide to long format
data_long <- data %>%
  pivot_longer(cols = -company, names_to = "week", values_to = "price")

# Print the first few rows of the resulting tibble
head(data_long)
## # A tibble: 6 × 3
##   company week         price
##   <chr>   <chr>        <dbl>
## 1 Amazon  X2019_week13 1848.
## 2 Amazon  X2019_week14 1641.
## 3 Amazon  X2019_week15 1696.
## 4 Amazon  X2019_week16 1671.
## 5 Amazon  X2019_week17 1626.
## 6 Amazon  X2019_week18 1588.