get_similar_players {BAwiR}R Documentation

Similar players to archetypoids

Description

Similar players to the archetypoids computed with archetypoids according to a similarity threshold.

Usage

get_similar_players(atype, threshold, alphas, cases, data, variables, compet, season)

Arguments

atype

Number assigned to the archetypoid (1:length(cases)) from which searching the players who most resemble to it.

threshold

Similarity threshold.

alphas

Alpha values of all the players.

cases

Archetypoids.

data

Data frame with the statistics.

variables

Statistics used to compute the archetypoids.

compet

Competition.

season

Season.

Value

Data frame with the features of the similar players.

Author(s)

Guillermo Vinue

See Also

archetypoids

Examples

(s0 <- Sys.time())
# Turn off temporarily some negligible warnings from the 
# archetypes package to avoid missunderstandings. The code works well.
library(Anthropometry)
df <- do_join_games_bio("ACB", acb_games_1718, acb_players_1718)
df1 <- do_add_adv_stats(df)
df2 <- do_stats(df1, "Total", "2017-2018", "ACB", "Regular Season")
df3 <- df2[which(df2$Position == "Guard")[1:31], c("MP", "PTS", "Name")]
preproc <- preprocessing(df3[,1:2], stand = TRUE, percAccomm = 1)
set.seed(4321)
suppressWarnings(lass <- stepArchetypesRawData(preproc$data, 1:2, 
                numRep = 20, verbose = FALSE))
res <- archetypoids(2, preproc$data, huge = 200, step = FALSE, ArchObj = lass,
                    nearest = "cand_ns", sequ = TRUE)
# The S3 class of anthrCases from Anthropometry has been updated.
cases <- anthrCases(res) 
df3[cases,] # https://github.com/r-quantities/units/issues/225
alphas <- round(res$alphas, 4)
df3_aux <- df2[which(df2$Position == "Guard")[1:31], ]
get_similar_players(1, 0.99, alphas, cases, df3_aux, c("MP", "PTS"), 
                    unique(df3_aux$Compet), unique(df3_aux$Season))
s1 <- Sys.time() - s0
s1                    


[Package BAwiR version 1.3.2 Index]