Я предполагаю, что ваши данные похожи на строки ниже.
library(stringr)
strings <- c('exp n=1', 'exp n=2 more information...')
# Returns a matrix. First column is complete match, second the first
# set of parentheses, third the second set of parentheses -- which is
# the one we want.
exp_numbers <- str_match(strings, '(n\\=)(\\d+)')[,3]
# [1] "1" "2"
paste0("Exp", exp_numbers)
# [1] "Exp1" "Exp2"
# Using the data string you provided
strings <- c(' D:Maj_stats_n1_pooled2019-0918_screen_n=3_T_Template.csv')
exp_numbers <- stringr::str_match(strings, '(n\\=)(\\d+)')[,3]
labels <- paste0("Exp", exp_numbers)
labels
#> [1] "Exp3"