I would like to use the sub command to remove this X leaving only the numbers.
I would like to use the %>% pipe operator approach, as it avoids creating intermediate data.frames and makes the code much cleaner.
I tried using something like this, but to no avail:
df<-data.frame(x1=c(20,3,2),x2=c(19,4,2), x3=c(20,3,2))%>%
pivot_longer(cols=x1:x3, names_to = "name1", values_to = "value1")%>%
sub('X','','name1')