rmv.ext: Remove the file extension from a file-name.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/reader.R

Description

Default is to only remove from a known list of file types, this is to protect files with '.' which may not have an extension This option can be changed, and more types can be specified too.

Usage

1
2
rmv.ext(fn = NULL, only.known = TRUE, more.known = NULL,
  print.known = FALSE)

Arguments

fn

filename(s) (with full path is ok too)

only.known

logical, only remove extension if in the 'known' list

more.known

character vector, add to the list of known extensions

print.known

return the list of 'known' file extensions

Value

returns the file name/path without the file extension

Author(s)

Nicholas Cooper nick.cooper@cimr.cam.ac.uk

See Also

get.ext

Examples

1
2
3
4
5
6
7
rmv.ext(print.known=TRUE)
rmv.ext("/documents/nick/mydoc.xlsx")
rmv.ext(c("temp.cnv","temp.txt","temp.epi"))
# remove anything that looks like an extension
rmv.ext(c("temp.cnv","temp.txt","temp.epi"),only.known=FALSE) 
# add to list of known extensions
rmv.ext(c("temp.cnv","temp.txt","temp.epi"),more.known="epi") 

Example output

Loading required package: NCmisc

Attaching package: 'reader'

The following objects are masked from 'package:NCmisc':

    cat.path, get.ext, rmv.ext

 [1] "TXT"   "RDATA" "TAB"   "DAT"   "CSV"   "VCF"   "GCM"   "BIM"   "MAP"  
[10] "FAM"   "PFB"   "SH"    "R"     "CPP"   "H"     "DOC"   "DOCX"  "XLS"  
[19] "XLSX"  "PDF"   "JPG"   "BMP"   "PNG"   "TAR"   "GZ"    "CNV"   "PL"   
[28] "PY"    "ZIP"   "ORG"   "RDA"   "DSC"   "BCK"   "ABW"   "HTM"   "HTML" 
/documents/nick/mydoc.xlsx 
   "/documents/nick/mydoc" 
  temp.cnv   temp.txt   temp.epi 
    "temp"     "temp" "temp.epi" 
temp.cnv temp.txt temp.epi 
  "temp"   "temp"   "temp" 
temp.cnv temp.txt temp.epi 
  "temp"   "temp"   "temp" 

reader documentation built on May 2, 2019, 9:27 a.m.