Skip to content

Commit

Permalink
tweaking documentation and small bits of code to get rid of notes at …
Browse files Browse the repository at this point in the history
…r cmd check
  • Loading branch information
jtfeld committed May 21, 2024
1 parent 010fd7a commit c162c09
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 26 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: EloOptimized
Title: Optimized Elo Rating Method for Obtaining Dominance Ranks
Version: 0.3.1.9000
Date: 2023-05-08
Version: 0.3.1.9999
Date: 2024-05-21
Authors@R: c(
person("Joseph", "Feldblum", email = "jtf9@duke.edu", role = c("aut", "cre")),
person("Steffen", "Foerster", email = "sf2041@gmail.com", role = c("aut")),
Expand All @@ -13,11 +13,12 @@ Depends:
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Imports: dplyr,
reshape2,
BAMMtools,
magrittr,
methods,
lubridate,
rlang
URL: https://github.com/jtfeld/EloOptimized
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export(eloratingopt)
import(BAMMtools)
import(reshape2)
importFrom(magrittr,"%>%")
importFrom(methods,is)
importFrom(rlang,.data)
importFrom(stats,approx)
importFrom(stats,ave)
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# EloOptimized 0.3.1.9000 (unreleased)
# EloOptimized 0.3.1.9999

* Mostly a maintenance release to resubmit package to CRAN

* Added a step to check that agon_data are in chronological order, and throw a warning if not.

* Fixed checks for ubuntu and Mac

* Added new and improved informative errors to eloratingopt() that tell you which individuals are filtered out for not having >= 1 win and 1 loss, and which individuals have interactions outside of their presence window.

* Tweaked documentation formatting and code for converting date columns to comply with R CMD check

# EloOptimized 0.3.1

* Mostly a maintenance update
Expand Down
22 changes: 13 additions & 9 deletions R/eloratingfixed.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
#' this help file:
#'
#' @return Returns a list with six elements:
#' \itemize{
#' \describe{
#' \item{\strong{elo}}{ Data frame with all IDs and dates they were present, with the following columns:}
#' \itemize{
#' \describe{
#' \item{Date}{: Dates of study period}
#' \item{Individual}{: the names of each ranked individual, for each date they were present}
#' \item{Elo}{: fitted Elo scores for each individual on each day}
Expand Down Expand Up @@ -74,6 +74,7 @@
#' @importFrom stats approx ave optim reshape
#' @importFrom utils read.csv write.csv
#' @importFrom rlang .data
#' @importFrom methods is
#' @import reshape2
#' @import BAMMtools
#' @importFrom magrittr "%>%"
Expand Down Expand Up @@ -106,9 +107,10 @@ eloratingfixed <- function(agon_data, pres_data, k = 100, init_elo = 1000,
stop("can't have same ID win and lose in one interaction")
}

if(class(ago$Date) != "Date"){
ago$Date = lubridate::mdy(ago$Date)
}
# if(class(ago$Date) != "Date"){
# ago$Date = lubridate::mdy(ago$Date)
# }
if(!is(ago$Date, "Date")) ago$Date = lubridate::mdy(ago$Date)

if(any(ago$Date < dplyr::lag(x = ago$Date,
n = 1,
Expand Down Expand Up @@ -140,10 +142,12 @@ eloratingfixed <- function(agon_data, pres_data, k = 100, init_elo = 1000,
if(!all(names(presence) %in% c("id", "start_date", "end_date"))){
stop("colnames in presence data should be 'id', 'start_date', 'end_date' (not case sensitive)")
}
if(class(presence$start_date) != "Date"){
presence$start_date = lubridate::mdy(presence$start_date)}
if(class(presence$end_date) != "Date"){
presence$end_date = lubridate::mdy(presence$end_date)}
# if(class(presence$start_date) != "Date"){
# presence$start_date = lubridate::mdy(presence$start_date)}
if(!is(presence$start_date, "Date")) presence$start_date = lubridate::mdy(presence$start_date)
# if(class(presence$end_date) != "Date"){
# presence$end_date = lubridate::mdy(presence$end_date)}
if(!is(presence$end_date, "Date")) presence$end_date = lubridate::mdy(presence$end_date)

presence$id = as.character(presence$id)

Expand Down
22 changes: 13 additions & 9 deletions R/eloratingopt.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
#'
#'
#' @return Returns a list with five or six elements (depending on input):
#' \itemize{
#' \describe{
#' \item{\strong{elo}}{ Data frame with all IDs and dates they were present, with the following columns:}
#' \itemize{
#' \describe{
#' \item{Date}{: Dates of study period}
#' \item{Individual}{: the names of each ranked individual, for each date they were present}
#' \item{Elo}{: fitted Elo scores for each individual on each day}
Expand Down Expand Up @@ -76,6 +76,7 @@
#' @importFrom stats approx ave optim reshape
#' @importFrom utils read.csv write.csv
#' @importFrom rlang .data
#' @importFrom methods is
#' @import reshape2
#' @import BAMMtools
#' @importFrom magrittr "%>%"
Expand Down Expand Up @@ -107,9 +108,10 @@ eloratingopt <- function(agon_data, pres_data, fit_init_elo = FALSE, outputfile
stop("can't have same ID win and lose in one interaction")
}

if(class(ago$Date) != "Date"){
ago$Date = lubridate::mdy(ago$Date)
}
# if(class(ago$Date) != "Date"){
# ago$Date = lubridate::mdy(ago$Date)
# }
if(!is(ago$Date, "Date")) ago$Date = lubridate::mdy(ago$Date)

if(any(ago$Date < dplyr::lag(x = ago$Date,
n = 1,
Expand Down Expand Up @@ -141,10 +143,12 @@ eloratingopt <- function(agon_data, pres_data, fit_init_elo = FALSE, outputfile
if(!all(names(presence) %in% c("id", "start_date", "end_date"))){
stop("colnames in presence data should be 'id', 'start_date', 'end_date' (not case sensitive)")
}
if(class(presence$start_date) != "Date"){
presence$start_date = lubridate::mdy(presence$start_date)}
if(class(presence$end_date) != "Date"){
presence$end_date = lubridate::mdy(presence$end_date)}
# if(class(presence$start_date) != "Date"){
# presence$start_date = lubridate::mdy(presence$start_date)}
if(!is(presence$start_date, "Date")) presence$start_date = lubridate::mdy(presence$start_date)
# if(class(presence$end_date) != "Date"){
# presence$end_date = lubridate::mdy(presence$end_date)}
if(!is(presence$end_date, "Date")) presence$end_date = lubridate::mdy(presence$end_date)

presence$id = as.character(presence$id)

Expand Down
19 changes: 19 additions & 0 deletions man/EloOptimized.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/eloratingfixed.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/eloratingopt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c162c09

Please sign in to comment.