Hello,
I would suggest something like `tools::file_path_sans_ext` instead of `strsplit` to remove the file extension. This is also vectorized, so you won't have to use a `sapply` or `vapply` on it. I hope this helps! On Wed, Jul 7, 2021 at 9:28 PM Kai Yang via R-help <r-help@r-project.org> wrote: > Hello List, > I have a one column data frame to store file name with extension. I want > to create new column to keep file name only without extension. > I tried to use strsplit("name1.csv", "\\.")[[1]] to do that, but it just > retain the first row only and it is a vector. how can do this for all of > rows and put it into a new column? > thank you, > Kai > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.