cpsievert / pitchRx

Tools for scraping MLB Gameday data and Visualizing PITCHf/x
http://cpsievert.github.io/pitchRx/
Other
124 stars 33 forks source link

Error in names(value) <- sub("\\.", "_", names(value)) : attempt to set an attribute on NULL #30

Closed martinbel closed 9 years ago

martinbel commented 9 years ago

The vignette code isn't working in my laptop, for some reason.

Also if I don't set this: Sys.setenv(TZ='GMT') the makeUrls functions crashes, outputs this error: Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format

Here is the code and it's output in the console, the main error is in the end of the code:

db <- src_sqlite("pitchfx.sqlite3", create=TRUE) scrape(start="2015-06-08", end=Sys.Date(), connect=db$con) If file names don't print right away, please be patient. grabbing new game IDs http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_08/miniscoreboard.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/miniscoreboard.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/miniscoreboard.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_11/miniscoreboard.xml Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format Sys.setenv(TZ='GMT') library(data.table) data.table 1.9.4 For help type: ?data.table *\ NB: by=.EACHI is now explicit. See README to restore previous behaviour.

Attaching package: ‘data.table’

The following objects are masked from ‘package:dplyr’:

between, last

db <- src_sqlite("pitchfx.sqlite3", create=TRUE) scrape(start="2015-06-08", end=Sys.Date(), connect=db$con) If file names don't print right away, please be patient. grabbing new game IDs http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_08/miniscoreboard.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/miniscoreboard.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/miniscoreboard.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_11/miniscoreboard.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_08/gid_2015_06_08_milmlb_pitmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_08/gid_2015_06_08_miamlb_tormlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_08/gid_2015_06_08_phimlb_cinmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_08/gid_2015_06_08_sdnmlb_atlmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_08/gid_2015_06_08_houmlb_chamlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_08/gid_2015_06_08_kcamlb_minmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_08/gid_2015_06_08_slnmlb_colmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_08/gid_2015_06_08_arimlb_lanmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_bosmlb_balmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_milmlb_pitmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_wasmlb_nyamlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_miamlb_tormlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_chnmlb_detmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_anamlb_tbamlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_phimlb_cinmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_sdnmlb_atlmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_sfnmlb_nynmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_seamlb_clemlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_houmlb_chamlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_kcamlb_minmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_slnmlb_colmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_texmlb_oakmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_09/gid_2015_06_09_arimlb_lanmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_phimlb_cinmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_miamlb_tormlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_wasmlb_nyamlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_slnmlb_colmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_bosmlb_balmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_milmlb_pitmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_chnmlb_detmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_anamlb_tbamlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_sdnmlb_atlmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_sfnmlb_nynmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_seamlb_clemlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_houmlb_chamlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_kcamlb_minmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_texmlb_oakmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_10/gid_2015_06_10_arimlb_lanmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_11/gid_2015_06_11_sdnmlb_atlmlb_1/inning/inning_all.xml http://gd2.mlb.com/components/game/mlb/year_2015/month_06/day_11/gid_2015_06_11_seamlb_clemlb_1/inning/inning_all.xml Error in names(value) <- sub(".", "_", names(value)) : attempt to set an attribute on NULL

cpsievert commented 9 years ago

Thanks for the report! Could you also include your sessionInfo()?

cpsievert commented 9 years ago

Also, it might be nice to know what this gives you:

Sys.time()

martinbel commented 9 years ago

Sure! Thanks! Let me know if you need something else. Great package BTW.

sessionInfo() R version 3.1.2 (2014-10-31) Platform: x86_64-apple-darwin13.4.0 (64-bit)

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] reshape2_1.4.1 stringr_1.0.0 rCharts_0.4.2 data.table_1.9.4 RMySQL_0.10.3 DBI_0.3.1
[7] shiny_0.11.1.9005

loaded via a namespace (and not attached): [1] acepack_1.3-3.3 chron_2.3-45 cluster_2.0.1 colorspace_1.2-6 digest_0.6.8
[6] foreign_0.8-63 Formula_1.2-1 ggplot2_1.0.1 grid_3.1.2 gridExtra_0.9.1
[11] gtable_0.1.2 Hmisc_3.16-0 htmltools_0.2.6 httpuv_1.3.2 jsonlite_0.9.16
[16] lattice_0.20-31 latticeExtra_0.6-26 magrittr_1.5 MASS_7.3-40 mime_0.3
[21] munsell_0.4.2 nnet_7.3-9 plyr_1.8.2 proto_0.3-10 R6_2.0.1
[26] RColorBrewer_1.1-2 Rcpp_0.11.6 RJSONIO_1.3-0 rpart_4.1-9 rstudio_0.98.1091
[31] rstudioapi_0.3.1 scales_0.2.4 splines_3.1.2 stringi_0.4-1 survival_2.38-1
[36] tools_3.1.2 whisker_0.3-2 xtable_1.7-4 yaml_2.1.13

Sys.time() [1] "2015-06-11 15:38:37 ART"

cpsievert commented 9 years ago

@martinbel I think if you do

scrape(start = "2015-06-08", end = as.character(Sys.Date()))

instead of

scrape(start = "2015-06-08", end = Sys.Date())

it should work?

cpsievert commented 9 years ago

@martinbel please re-open if this doesn't fix the problem ^^^

efbbrown commented 9 years ago

I'm currently receiving this error when using scrape().

require(data.table)
require(pitchRx)
require(RSQLite)
require(dplyr)

startDate <- "2015-09-13"
endDate <- "2015-09-15"

test <- scrape(startDate, endDate) # this works fine

db <- src_sqlite("pitchfx.sqlite3", create=TRUE)

scrape(startDate, endDate, connect = db$con)
If file names don't print right away, please be patient.
grabbing new game IDs
http://gd2.mlb.com/components/game/mlb/year_2015/month_09/day_12/miniscoreboard.xml 
http://gd2.mlb.com/components/game/mlb/year_2015/month_09/day_13/miniscoreboard.xml 
http://gd2.mlb.com/components/game/mlb/year_2015/month_09/day_14/miniscoreboard.xml 
http://gd2.mlb.com/components/game/mlb/year_2015/month_09/day_13/gid_2015_09_13_tormlb_nyamlb_1/inning/inning_all.xml 
http://gd2.mlb.com/components/game/mlb/year_2015/month_09/day_13/gid_2015_09_13_bosmlb_tbamlb_1/inning/inning_all.xml 

... [truncated]

http://gd2.mlb.com/components/game/mlb/year_2015/month_09/day_14/gid_2015_09_14_anamlb_seamlb_1/inning/inning_all.xml 
http://gd2.mlb.com/components/game/mlb/year_2015/month_09/day_14/gid_2015_09_14_cinmlb_sfnmlb_1/inning/inning_all.xml 
Error in names(value) <- sub("\\.", "_", names(value)) : 
  attempt to set an attribute on NULL

This same error occurs if I use a MySQL() database instead of the sqllite one.

db = dbConnect(MySQL(), user=username, password=password, dbname=dbname, host=host)
scrape(startDate, endDate, connect = db$con)

I'm a bit stumped on this one, does anyone know what the issue could be?

Thanks for building this package Carson it's so awesome.

cpsievert commented 9 years ago

@efbbrown I think this is due to a different problem. Could you re-post this as a new issue and include output from devtools::session_info()?

efbbrown commented 9 years ago

Sorry Carson no problem, reposted now in its own issue # 33.

Cheers.