Git Product home page Git Product logo

Comments (8)

jalapic avatar jalapic commented on May 24, 2024

The current version of this function on GitHub doesn't appear to return NAs - as far as I can see all the improvements were already in that function except for ensuring that the Date is a Date class .. or did I miss something?

I think the issue of what to do with this function in the off-season is a puzzle. Probably best to just leave it as is and on the day of the new season change it??? Or maybe add a warning?

from engsoccerdata.

JoGall avatar JoGall commented on May 24, 2024

Ah something went wrong on my end, I didn't realise the current GitHub version had the call to the teamnames dataframe already.

I'm still getting NAs returned when I run the latest version though, I think because the function tries to convert the division and tiers to numeric directly ("division" = as.numeric(df$Div), "tier" = as.numeric(df$Div)) but the variable 'Div' also contains a character (i.e. E0, E1...). Think the numeric value has to be extracted first with strsplit, gsub, etc...

from engsoccerdata.

jalapic avatar jalapic commented on May 24, 2024

interesting - I can't repeat that error, but I will look into it. I'll be overhauling the other functions tonight also, so hopefully can track down that error.

from engsoccerdata.

jalapic avatar jalapic commented on May 24, 2024

ok the reason this should work is that E0,E1,E2,E3 are brought in as factors and then the as.numeric just reads the level of the factor as a number. To ensure it will work, I will just wrap the variable in factor - that ought to do it.

from engsoccerdata.

JoGall avatar JoGall commented on May 24, 2024

Ah I've just realised why then, I had options(stringsAsFactors = FALSE) in my .Rprofile! I'm going to remove the line from my .Rprofile to make sure my code is portable in future but it's probably a good idea to explicitly make it a factor in the function for others that might have the option set.

from engsoccerdata.

JoGall avatar JoGall commented on May 24, 2024

Also, I hadn't thought of what to do with this function during the off-season... Could we maybe check whether the england dataframe is already up-to-date before running? Something like:

england_current <- function(){
  
  df <- rbind(read.csv("http://www.football-data.co.uk/mmz4281/1617/E0.csv"),
              read.csv("http://www.football-data.co.uk/mmz4281/1617/E1.csv"),
              read.csv("http://www.football-data.co.uk/mmz4281/1617/E2.csv"),
              read.csv("http://www.football-data.co.uk/mmz4281/1617/E3.csv")
  )
  
  if(identical(max(as.Date(df$Date, "%d/%m/%y")), max(england$Date) )) {
    #message about being up to date
  }
  
  else {
    #rest of function
  }
  
}

from engsoccerdata.

jalapic avatar jalapic commented on May 24, 2024

I think lots have that in their .Rprofile - therefore it's a good job to make sure that the code is robust to that.

from engsoccerdata.

jalapic avatar jalapic commented on May 24, 2024

Good idea for the function date check - I will implement that.

from engsoccerdata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.