May I please have help sorting the tibble by date, when I attempt to sort using Days, I get the error message shown below.
library(readr)
library(tidyverse)
library(lubridate)
library(gt)
Lotto_winnings_2002to2022 <- read.csv("https://data.ny.gov/api/views/5xaw-6ayf/rows.csv?accessType=DOWNLOAD")
# Winning_Numbers is the string converted to array
# Needs more explanation of array, and unlist
Winning_Numbers <- list()
x = 1
while (x < nrow(Lotto_winnings_2002to2022)) {
Winning_Numbers[[x]] <- as.numeric(array(unlist(strsplit(Lotto_winnings_2002to2022[x,2]," "))))
x <- x + 1
}
# Using mdy() from lubridate package to convert
# 1st column of type string to type Date
Days = list()
y = 1
while (y< nrow(Lotto_winnings_2002to2022)) {
Days[[y]] <- mdy(Lotto_winnings_2002to2022[y,1])
y <- y + 1
}
MegaBall = list()
z = 1
while (z< nrow(Lotto_winnings_2002to2022)) {
MegaBall[z] <- Lotto_winnings_2002to2022[z,3]
z <- z + 1
}
Multiplier = list()
f = 1
while (f< nrow(Lotto_winnings_2002to2022)) {
Multiplier[f] <- Lotto_winnings_2002to2022[f,4]
f <- f + 1
}
# Create new Dataframe using converted columns
Lotto_Converted <- tibble(Days, Winning_Numbers, MegaBall, Multiplier)
Lotto_Converted_sorted <- arrange(Lotto_Converted, Lotto_Converted[1])
# summary of lottery rules needs to be added
ERROR MESSAGE as image and typed
Error in (function (..., na.last = TRUE, decreasing = FALSE, method = c("auto", :
unimplemented type 'list' in 'orderVector1'
Error: VECTOR_ELT() can only be applied to a 'list', not a 'closure'
> View(Lotto_Converted)
Error in (function (..., na.last = TRUE, decreasing = FALSE, method = c("auto", :
unimplemented type 'list' in 'orderVector1'
Error: VECTOR_ELT() can only be applied to a 'list', not a 'closure'
Error in .rs.findDataFrame("", "Lotto_Converted", "CB5482C2", "C:/Users/IanAK/AppData/Local/RStudio/viewer-cache") :
R_Reprotect: only 4 protected items, can't reprotect index -1
Error in .rs.findDataFrame("", "Lotto_Converted", "CB5482C2", "C:/Users/IanAK/AppData/Local/RStudio/viewer-cache") :
R_Reprotect: only 4 protected items, can't reprotect index -1