Package 'soccercolleagues'

Title: Find Common Team Mates For Soccer Players
Description: Identify a football player's current and former team mates. Find common team-mates for a set of named footballers. Data fetched from <transfermarkt.com>.
Authors: Matt Dray [aut, cre]
Maintainer: Matt Dray <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9001
Built: 2024-11-15 04:52:40 UTC
Source: https://github.com/matt-dray/soccercolleagues

Help Index


Get Common Team Mates For Named Players

Description

Get Common Team Mates For Named Players

Usage

get_colleagues(all_players, players)

Arguments

all_players

Data.frame. Data fetched from Transfermarkt with get_players.

players

Character vector. One or more player names for whom to return common team mates from the all_players data.frame. See details.

Details

Pass one player name to the players argument to fetch all of their team mates in the dataset. Pass multiple players to return common team mates and they seasons they played together.

Value

A data.frame with a row per player and season.

Examples

## Not run: 
# Fetch player data from Transfermarkt
epl_players <- get_players(1992:2020, "England")

# Return all team mate data for one named player
get_colleagues(epl_players, "James Milner")

# Return data for all team mates in common for named players
get_colleagues(
  epl_players,
  c("Mark Viduka", "Kevin Phillips", "Nicky Butt")
)

## End(Not run)

Fetch Player Data From Transfermarkt

Description

Fetch Player Data From Transfermarkt

Usage

get_players(seasons = 1992:2021, country = "England")

Arguments

seasons

Numeric. One of more season starting-years for which to fetch data from Transfermarkt. Defaults to seasons where the English Premier League has existed (since 1992).

country

Character. Country from which to fetch data from Transfermarkt. Defaults to "England" for the English Premier League.

Value

A data.frame/tibble with a row per player/season and columns for name, position, age, team, year, etc.

Examples

## Not run: epl_players <- get_players(1992:2021, "England")

Open 'Guess The Player' Quiz App

Description

Open 'Guess The Player' Quiz App

Usage

open_colleagues_quiz(all_players)

Arguments

all_players

Data.frame. Data fetched from Transfermarkt with get_players.

Value

Opens a Shiny app.

Examples

## Not run: 
# Fetch player data from Transfermarkt
epl_players <- get_players(1992:2020, "England")

# Open Shiny App
open_colleagues_quiz(epl_players)

## End(Not run)

Sample From Named Players' Common Team Mates

Description

Sample From Named Players' Common Team Mates

Usage

sample_colleagues(all_players, players, n = NULL)

Arguments

all_players

Data.frame. Data fetched from Transfermarkt with get_players.

players

Character vector. One or more player names for whom to return common team mates from the all_players data.frame. See details.

n

Numeric. Number of team-mates' names to return. See details.

Details

Pass one player name to the players argument to sample from all of their team mates in the dataset. Pass multiple players to sample from common team mates.

The default number of player names returned, n, by will depend on the number of players supplied to the players argument: one input name will result in n = 5; multiple input names will result in n = 1.

Value

A character vector of player names.

Examples

## Not run: 
# Fetch player data from Transfermarkt
epl_players <- get_players(1992:2020, "England")

# Return several team mates for one named player
sample_colleagues(epl_players, "James Milner", n = 5)

# Return one team mate in common for named players
sample_colleagues(
  epl_players,
  c("Mark Viduka", "Kevin Phillips", "Nicky Butt"),
  n = 1
)

## End(Not run)