Skip to content

file.stem?

5 messages · Jeff Newmiller, Rui Barradas, Witold E Wolski +1 more

#
Read the Posting Guide... use plain text email.

help.search("file")

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Witold E Wolski <wewolski at gmail.com> wrote:

            
#
Hello,

You can use ?basename to write a file.stem function:


basename("/the/path/to/afile.txt")

file.stem <- function(x){
	bn <- basename(x)
	gsub("\\..*$", "", bn)
}
file.stem("/the/path/to/afile.txt")



Hope this helps,

Rui Barradas

Em 15-07-2013 15:23, Witold E Wolski escreveu:
#
Rui, Thank you
On 15 July 2013 16:32, Rui Barradas <ruipbarradas at sapo.pt> wrote:

  
    
#
Hi,
May be this also works.
basename(file_path_sans_ext("/the/path/to/afile.txt"))
#[1] "afile"
A.K.




----- Original Message -----
From: Rui Barradas <ruipbarradas at sapo.pt>
To: Witold E Wolski <wewolski at gmail.com>
Cc: r-help at r-project.org
Sent: Monday, July 15, 2013 10:32 AM
Subject: Re: [R] file.stem?

Hello,

You can use ?basename to write a file.stem function:


basename("/the/path/to/afile.txt")

file.stem <- function(x){
??? bn <- basename(x)
??? gsub("\\..*$", "", bn)
}
file.stem("/the/path/to/afile.txt")



Hope this helps,

Rui Barradas

Em 15-07-2013 15:23, Witold E Wolski escreveu:
______________________________________________
R-help at r-project.org mailing list
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.