in shell ,to make a dir:
mkdir /home/test
then ,to create a file named “.test” in the “/home/test”
a=list.files(path = "/home/test",include.dirs = FALSE)
a
character(0)
a=list.files(path = "/home/test",include.dirs = TRUE)
a
character(0)
a=list.files(path = "/home/test/",include.dirs = TRUE)
a
character(0)
list.files(path = '/home/test', all.files=TRUE,inclued.dirs=FALSE)
[1] "." ".." ".test"
a=list.files(path = '/home/test', all.files=TRUE)
length(a)
[1] 3
how can i get length(a) = 1 using regular expression parameters pattern= in list.files to prune . and ..
Use
all.files=TRUEto show all file names including hidden files.To answer your edit, one way would be to use a negative number with
tailUsing only the
patternargument:The
patternsays “anything that starts with something other than a dot or anything that starts with a dot followed by anything other than a dot.”Although it breaks your requirement to use the
patternargument oflist.files, I would actually probably wrapgreparoundlist.statementsin this case.The above will find any file names that only contain dots, then return everything else.
invert=TRUEmeans “find the names that do not match”, andvalue=TRUEmeans “return the names instead of their location.”