Data frame Data cleaning

You can use regular expresions (regex), see this example:

library(tidyverse)

sample_df <- data.frame(
    URL = c("football.html", "Athletics.html")
)

sample_df %>% 
    mutate(games = str_remove(URL, "\\.html$"))
#>              URL     games
#> 1  football.html  football
#> 2 Athletics.html Athletics

Created on 2021-05-18 by the reprex package (v2.0.0)

Note: Next time please provide a proper REPRoducible EXample (reprex) illustrating your issue.

1 Like