To find the name of a file in R, you can use the basename()
function from the base package. This function takes a file path as an argument and returns the file name and extension.
main.r94 chars4 lines
If you have a set of file paths that you want to extract the file names from, you can use a combination of lapply()
and basename()
to apply the function to all paths in a vector or list.
main.r163 chars4 lines
If the file names contain additional information that you want to extract, you can use regular expressions with the gsub()
function to remove unwanted characters.
main.r175 chars4 lines
gistlibby LogSnag