I have a folder with different files. What I'm trying to do is to extract file names without extensions of csv files only.
for example: if i have a folder with files
cp1.csv 
cp2.csv 
sd.exe 
I'd like to get a vector:
"cp1" "cp2" 
                You could use a list.files() gsub() combo
basenames<-gsub("\\.csv$","", list.files(pattern="\\.csv$"))
                        An alternative to gsub would be file_path_sans_extension from "tools". Try:
library(tools)
file_path_sans_ext(list.files(pattern = "*.csv"))
Not much added here, but it's still a fun function to know about :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With