I have the name of a file like this: name1.csv and I would like to extract two substrings of this string. One that stores the name1 in one variable
name1.csv
name1
Use strsplit():
strsplit()
http://stat.ethz.ch/R-manual/R-devel/library/base/html/strsplit.html
Example:
> strsplit('name1.csv', '[.]')[[1]] [1] "name1" "csv"
Note that second argument is a regular expression, that's why you can't just pass single dot (it will be interpreted as "any character").