The data shows NA for some points but the information is right below it. It is the same UPC, Store, and Week. How do I group my data to avoid redundancy and the NA data?
This is my code so far:
`library(tidyverse)
RD <- read.csv("Raw Soft Drinks Sales Data.csv")
U <- read.csv("UPC Soft Drinks.csv") %>%
mutate(UPC = as.factor(UPC),
BRAND = as.factor(BRAND),
CLASS = as.factor(CLASS))
RDX <- RD %>%
filter(UPC != "Total") %>%
select (-c(Total.Q1,Total.Q2,Total.Q3,Total.Q4))
RDXL <- RDX %>%
pivot_longer(
cols = starts_with("Week"),
# cols = X1:X52,
# cols = !c("STORE","UPC"),
names_to = "WEEK",
names_prefix = "Week",
values_to = "UNITS",
values_drop_na = TRUE)
RDW <- pivot_wider(RDXL, names_from = "ITEM", values_from = "UNITS")%>%
select(-TOTAL)
`
This is what the original data set looks like: original data
I need Store, UPC, Dollars, Units, Feat, Deal, and Week to be their own columns.