Comments (8)
The current version of this function on GitHub doesn't appear to return NA
s - 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.
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.
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.
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.
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.
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.
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.
Good idea for the function date check - I will implement that.
from engsoccerdata.
Related Issues (20)
- Add Brazilian league Data
- safrica deductions
- England_current() returns same column names but different column types HOT 2
- Champs_Update Needed HOT 2
- League position HOT 2
- England Tier 1 2016/2017 & 2017/2018 data missing? HOT 5
- Add domestic cup data HOT 1
- league cup
- div 3N and div 3S are messed up in england HOT 1
- england 2019/2020 double entries ? HOT 1
- R version 3.50 required? HOT 4
- France raw data is the same as Germany
- MUFC-Bournemouth game 2016
- 2021 england_current() HOT 1
- england_current() issue HOT 1
- belgium
- Greek Playoff Games
- NA in some team names in name_other column of teamnames.csv
- italy 2nd tier
- add England conference data - at least from 2006/7 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from engsoccerdata.