Hi,
I have this dataset which has three columns,. For the first column, I want to remove the digits that are between the underscores (i.e., 1281, 1299, 1409, 1435, etc.). Note that in the first two rows, _3-_
is not part of the numbers I want to remove, just the numbers between _...._
, that have no other character at all- only numbers.
stim kurt kurtval
1 abdul_mohd_1281_3-_su3uud.wav kurtosis01 131.60382
2 abdul_mohd_1299_3-_su3uud2.wavkurtosis01 151.46565
3 abdul_mohd_1409_f_faatiH.wav kurtosis01 235.92852
4 abdul_mohd_1435_f_faatiH.wav kurtosis01 337.57584
5 abdul_mohd_1462_T_t-aamir.wav kurtosis01 77.71517
6 abdul_mohd_1487_T_t-aamir.wav kurtosis01 214.47318
7 abdul_mohd_1514_D_d-aabil.wav kurtosis01 82.94311
8 abdul_mohd_1542_D_d-aabil.wav kurtosis01 145.74446
Here is the data.
data <- structure(list(stim = c("abdul_mohd_1281_3-_su3uud.wav", "abdul_mohd_1299_3-_su3uud2.wav",
"abdul_mohd_1409_f_faatiH.wav", "abdul_mohd_1435_f_faatiH.wav",
"abdul_mohd_1462_T_t-aamir.wav", "abdul_mohd_1487_T_t-aamir.wav",
"abdul_mohd_1514_D_d-aabil.wav", "abdul_mohd_1542_D_d-aabil.wav"
), kurt = c("kurtosis01", "kurtosis01", "kurtosis01", "kurtosis01",
"kurtosis01", "kurtosis01", "kurtosis01", "kurtosis01"), kurtval = c(131.603817955143,
151.465653115077, 235.928519783803, 337.575842059023, 77.7151703927855,
214.473178497778, 82.9431075503998, 145.744458586239)), row.names = c(NA,
8L), class = "data.frame")
The output I am looing for is similar to this:
stim kurt kurtval
1 abdul_mohd_3-_su3uud.wav kurtosis01 131.60382
2 abdul_mohd_3-_su3uud2.wav kurtosis01 151.46565
3 abdul_mohd_f_faatiH.wav kurtosis01 235.92852
4 abdul_mohd_f_faatiH.wav kurtosis01 337.57584
5 abdul_mohd_T_t-aamir.wav kurtosis01 77.71517
6 abdul_mohd_T_t-aamir.wav kurtosis01 214.47318
7 abdul_mohd_D_d-aabil.wav kurtosis01 82.94311
8 abdul_mohd_D_d-aabil.wav kurtosis01 145.74446
I have tried the following but no success. Any thoughts?
Thank you in advance!
str_replace(data, "_\\d[0-9]_", "")
gsub('_[[:digit:]]_', '', data)