how to obtain the character vector from dir_ls of fs package?

Hi! I would like to know how to get the "character" vector of the output of dir_ls from fs package.

nomb <- dir_ls(glob = "*.xlsx")

nomb %>% class()

The result of the last part is "fs_path" "character". Until this time, I haven't found the way of how to extract the latest part. Please any comment and help with this will be highly appreciate.
Thank you.

You can use as.character


dir_ls() %>% class()
#> [1] "fs_path"   "character"
dir_ls() %>% as.character() %>% class()
#> [1] "character"

unname(dir_ls() == as.character(dir_ls()))

Created on 2020-01-05 by the reprex package (v0.2.1)

The fs_path is just an additional class added to the character vector by the fs package. It is likely used for s3 methods within the package itself. If you pass the nomb object to any function that takes a character vector then it should still work the same way as it still inherits the character class.


Thanks a lot for your support. It fixed what I wanted to do.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.