Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (5.3k points)

I'm very new to R and am working on updating an R script to iterate through a series of .dbf tables created using ArcGIS and produce a series of graphs.

I have a directory, C:\Scratch, that will contain all of my .dbf files. However, when ArcGIS creates these tables, it also includes a .dbf.xml file. I want to remove these .dbf.xml files from my file list and thus my iteration. I've tried searching and experimenting with regular expressions to no avail. This is the basic expression I'm using (Excluding all of the various experimentation):

files <- list.files(pattern = "dbf")

Can anyone give me some direction?

1 Answer

0 votes
by

To list all files with a specific extension using list.file function, you can do the following:

files <- list.files(pattern = "\\.dbf$")

The $ sign signifies the end of the string in the file name.

For example:

setwd("C:/Users/intellipaat/Desktop/BLOG/practice")

files <- list.files(pattern = "\\.r$", ignore.case = TRUE)

 files

[1] "p01.R"   "p1.R"    "p2.R"    "p3.R"    "p4.R"    "p5.R"    "prac1.R" "prac2.R"

[9] "prac3.R"

Browse Categories

...