TimStats commited on
Commit
96f39dd
·
verified ·
1 Parent(s): afef8a9

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +19 -1
app.R CHANGED
@@ -6,7 +6,25 @@ library(shinyauthr)
6
  #library(gtExtras)
7
  library(bslib)
8
 
9
- Beam <- read.csv('Beam.csv')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  test <- Beam %>%
12
  select(Date,PitchofPA,Pitcher,PitcherId,PitcherThrows,PitcherTeam,Batter,BatterId,
 
6
  #library(gtExtras)
7
  library(bslib)
8
 
9
+ #Beam <- read.csv('Beam.csv')
10
+
11
+ download_private_csv <- function(repo_id, filename) {
12
+ url <- paste0("https://huggingface.co/datasets/", repo_id, "/resolve/main/", filename)
13
+ response <- GET(url, add_headers(Authorization = paste("Bearer", Sys.getenv("HF_TOKEN"))))
14
+
15
+ if (status_code(response) == 200) {
16
+ content <- content(response, "text")
17
+ con <- textConnection(content)
18
+ data <- read.csv(con, header = TRUE) # Explicitly set header = TRUE
19
+ close(con)
20
+ return(data)
21
+ } else {
22
+ stop("Failed to download dataset")
23
+ }
24
+ }
25
+
26
+ # Usage
27
+ Beam <- download_private_csv("TimStats/CollegePriv", "Beam.csv")
28
 
29
  test <- Beam %>%
30
  select(Date,PitchofPA,Pitcher,PitcherId,PitcherThrows,PitcherTeam,Batter,BatterId,