The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

A simple use case

This vignette covers how to use some functions from the CSGo package in a use case format.

Data Extraction and Analysis

The first step to use the CSGo package is to have your own credentials (API key) to pull the CSGo data from the Steam API. For more information about how to get your own API Key run in your R vignette("auth", package = "CSGo").

Now that you already have your API Key you should be able to collect your own CSGo data as well as your friends’ data. I hope my friend Rodrigo doesn’t mind us playing with his data (he is the ‘76561198263364899’)!

First let’s pull his CSGo statistics:

library(CSGo)

# to get the statistics of the user 76561198263364899
rodrigo_stats <- get_stats_user(api_key = 'your_key', user_id = '76561198263364899')

Let’s just filter the obtained data frame by “kills” and “weapon” to create an analysis of kills by type of weapon.

library(dplyr)
library(stringr)

rodrigo_weapon_kill <- rodrigo_stats %>%
  filter(
    str_detect(name, 'kill'),
    type == ' weapon info'
  ) %>%
  arrange(desc(value))

Now let’s take a look at the graphic!

PS: To make the graphic even more beautiful I recommend getting the “Quantico” font from Google fonts using the showtext package!

library(ggplot2)
library(showtext)

## Loading Google fonts (https://fonts.google.com/)
font_add_google("Quantico", "quantico")

rodrigo_weapon_kill %>%
  top_n(n = 10, wt = value) %>%
  ggplot(aes(x = name_match, y = value, fill = name_match)) +
  geom_col() +
  ggtitle("KILLS BY WEAPON") +
  ylab("Number of Kills") +
  xlab("") +
  labs(fill = "Weapon Name") +
  theme_csgo(text = element_text(family = "quantico")) +
  scale_fill_csgo()

kills_weapon

So, these are the top 10 weapons by kills, but.. What about the efficiency? Is the ak47 the Rodrigo’s more efficient weapon? First, let’s define “efficiency”:


rodrigo_efficiency <- rodrigo_stats %>%
  filter(
    name_match %in% c("ak47", "aug", "awp", "fiveseven",
                      "hkp2000", "m4a1", "mp7", "p90",
                      "sg556", "xm1014")
  ) %>%
  mutate(
    stat_type = case_when(
      str_detect(name, "shots") ~ "shots",
      str_detect(name, "hits") ~ "hits",
      str_detect(name, "kills") ~ "kills"
    )
  ) %>% 
  pivot_wider(
    names_from = stat_type, 
    id_cols = name_match, 
    values_from = value
  ) %>%
  mutate(
    kills_efficiency = kills/shots*100,
    hits_efficiency = hits/shots*100,
    hits_to_kill = kills/hits*100
  )

kbl(rodrigo_efficiency) %>%
  kable_styling()
name_match kills shots hits kills_efficiency hits_efficiency hits_to_kill
fiveseven 1288 28187 5558 4.569482 19.71831 23.17380
xm1014 5611 205982 42541 2.724024 20.65278 13.18963
p90 3469 133273 20245 2.602928 15.19062 17.13510
awp 2051 6260 2235 32.763578 35.70288 91.76734
ak47 6969 154852 24823 4.500426 16.03014 28.07477
aug 2120 37949 8487 5.586445 22.36423 24.97938
hkp2000 1401 36975 6737 3.789047 18.22042 20.79561
sg556 1243 25091 4567 4.953968 18.20175 27.21699
mp7 1788 52657 10186 3.395560 19.34406 17.55350
m4a1 3526 81126 14687 4.346325 18.10394 24.00763
rodrigo_efficiency %>%
  top_n(n = 10, wt = kills) %>%
  ggplot(aes(x = name_match, size = shots)) +
  geom_point(aes(y = kills_efficiency, color = "Kills Efficiency")) +
  geom_point(aes(y = hits_efficiency, color = "Hits Efficiency")) +
  geom_point(aes(y = hits_to_kill, color = "Hits to Kill")) +
  ggtitle("WEAPON EFFICIENCY") +
  ylab("Efficiency (%)") +
  xlab("") +
  labs(color = "Efficiency Type", size = "Shots") +
  theme_csgo(
    text = element_text(family = "quantico"),
    panel.grid.major.x = element_line(size = .1, color = "black",linetype = 2)
  ) +
  scale_color_csgo()

weapon_effic

In conclusion, I would advise Rodrigo to use the awp in his next games, because this weapon presented the best efficiency in terms of shots to kill, shots to hit, and hits to kill. But we definitely need more shots with this weapon to see if this efficiency remains.. hahahaha

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.