Ups... Thank you both. Indeed I must repeat lessons on regular expression... obviously forgotten...

Le 28/02/2020 à 18:32, Jeremie Juste a écrit :
Hello,

you need
dir(pattern="\\.r$",ignore.case=TRUE)
remember that the pattern is a regular expression.
so ".r" is [any single character]r. So basically it will give you any
file that contains r (but not that starts with r)


so you got what you expected with
  dir(pattern=".txt")
just by chance. as <rtxt.r> or <rtxt.pdf>  would have been printed as well

HTH,

Jeremie


I have this directory contain listed at the page bottom

Can somebody tell me why with

dir(pattern = ".txt")

dir(pattern = ".dbf")

etc.

I get exactly what I want (a vector with the file names correctly
suffixed), but with

dir(pattern = ".r")

I get this:

dir(pattern=".r") [1] "Article Predation" "BD Carto" [3] "broma1.txt"
"broma3.txt" [5] "BromaBusesMilanMicha.xlsx" "Bromadiolone" [7]
"BufferRenard.dbf" "BufferRenard.prj" [9] "BufferRenard.shp"
"BufferRenard.shx" [11] "clpboard" "DatesDiurnes.txt" [13]
"DatesDiurnes_plus.txt" "DatesDiurnes_plus.xlsx" [15]
"DatesDiurnesFREDON" "DatesDiurnesFREDON_plus.txt" [17]
"DatesDiurnesFREDON_plus.xlsx" "DatesDiurnesRegis.txt" [19]
"DatesDiurnesRegis_plus.txt" "DatesDiurnesRegis_plus.xlsx" [21]
"DatesNocturnes.txt" "DatesNocturnes_plus.txt" [23]
"DatesNocturnes_plus.xlsx" "DatesNocturnesFREDON" [25]
"DatesNocturnesFREDON_plus.txt" "DatesNocturnesFREDON_plus.xlsx" [27]
"DatesNocturnesRegis.txt" "DatesNocturnesRegis_plus.txt" [29]
"DatesNocturnesRegis_plus.xlsx" "Figures" [31] "ParcBuf300n.dbf"
"ParcBuf300n.prj" [33] "ParcBuf300n.shp" "ParcBuf300n.shx" [35]
"ParcBuf350n.dbf" "ParcBuf350n.prj" [37] "ParcBuf350n.shp"
"ParcBuf350n.shx" [39] "Script_190517_preparation.r"
"Script_190518_scores_AT.r" [41] "Script_190519_1430_cinetiques_IKA.r"
"Script_190519_1622_transects_camp.r" [43]
"Script_190530_1700_preparation2.r"
"Script_190530_1903_cinetiques_IKA2.r" [45]
"Script_190531_0922_scores_AT2.r" "Script_190531_1729_prey_resource.r"
[47] "Script_190601_1509_graphIKAd.r"
"Script_190601_1509_graphIKAd_old.r" [49]
"Script_190601_1509_graphIKAn.r" "Script_190601_1509_graphIKAn_old.r"
[51] "Script_190601_1955_spatial.r" "Script_190708_0930_distance.r" [53]
"Script_190709_0930_impact renard.r"
"Script_200117_cinetiques_article.r" [55]
"Script_200119_source_stats_explore_diurne.r" "Script_200119_stats.r"
[57] "Script_200122_spatial_distribution.r" "Script_200124_distance.r"
[59] "Script_200124_distance_source_d.r"
"Script_200124_distance_source_n.r" [61]
"Script_200201_impacts_on_prey.R" "ScriptCompteLignes.r" [63]
"Scripts_avant_200112.zip" "shinyPred" [65] "StudyArea.dbf"
"StudyArea.prj" [67] "StudyArea.shp" "StudyArea.shx" [69]
"SurfaceZoneEtude.dbf" "SurfaceZoneEtude.prj" [71]
"SurfaceZoneEtude.shp" "SurfaceZoneEtude.shx" [73] "transects_camp.Rdata"

How can I get all the files, only these files, suffixed with ".r" ?

Thanks in advance,

------------------------------------------------------------------------

dir() [1] "Analyse_190523_baseline_190523_1506.docx"
"Analyse_190523_baseline_190531_2110.docx" [3]
"Analyse_190523_baseline_190531_2110.Rmd" "Analyse_190531_baseline.docx"
[5] "Analyse_190531_baseline.Rmd" "Analyse_190531_baseline_cache" [7]
"Analyse_190531_baseline_files" "Analyse_190603_spatial.docx" [9]
"Analyse_190603_spatial.Rmd" "Analyse_190603_spatial_cache" [11]
"Analyse_190603_spatial_files" "Article Predation" [13] "BD Carto"
"Biblio" [15] "broma1.txt" "broma3.txt" [17] "BromaBusesMilanMicha.xlsx"
"Bromadiolone" [19] "BufferRenard.dbf" "BufferRenard.prj" [21]
"BufferRenard.shp" "BufferRenard.shx" [23] "clpboard" "DatesDiurnes.txt"
[25] "DatesDiurnes_plus.txt" "DatesDiurnes_plus.xlsx" [27]
"DatesDiurnesFREDON" "DatesDiurnesFREDON_plus.txt" [29]
"DatesDiurnesFREDON_plus.xlsx" "DatesDiurnesRegis.txt" [31]
"DatesDiurnesRegis_plus.txt" "DatesDiurnesRegis_plus.xlsx" [33]
"DatesNocturnes.txt" "DatesNocturnes_plus.txt" [35]
"DatesNocturnes_plus.xlsx" "DatesNocturnesFREDON" [37]
"DatesNocturnesFREDON_plus.txt" "DatesNocturnesFREDON_plus.xlsx" [39]
"DatesNocturnesRegis.txt" "DatesNocturnesRegis_plus.txt" [41]
"DatesNocturnesRegis_plus.xlsx" "Figures" [43] "IKAZ_old.zip"
"IKAZ1999.txt" [45] "IKAZ2000.txt" "IKAZ2007.txt" [47] "IKAZ2008.txt"
"IKAZ2009.txt" [49] "IKAZ2010.txt" "IKAZ2011.txt" [51] "IKAZ2012.txt"
"IKAZ2013.txt" [53] "IKAZ2014.txt" "IKAZ2015.txt" [55] "IKAZ2016.txt"
"IKAZ2017.txt" [57] "IKAZ2018.txt" "ParcBuf300n.dbf" [59]
"ParcBuf300n.prj" "ParcBuf300n.shp" [61] "ParcBuf300n.shx"
"ParcBuf350n.dbf" [63] "ParcBuf350n.prj" "ParcBuf350n.shp" [65]
"ParcBuf350n.shx" "Photos ZELAC" [67] "plot.ds.R" "plot.dsmodel.R" [69]
"RData" "Script_190517_preparation.r" [71] "Script_190518_scores_AT.r"
"Script_190519_1430_cinetiques_IKA.r" [73]
"Script_190519_1622_transects_camp.r"
"Script_190530_1700_preparation2.r" [75]
"Script_190530_1903_cinetiques_IKA2.r" "Script_190531_0922_scores_AT2.r"
[77] "Script_190531_1729_prey_resource.r"
"Script_190601_1509_graphIKAd.r" [79]
"Script_190601_1509_graphIKAd_old.r" "Script_190601_1509_graphIKAn.r"
[81] "Script_190601_1509_graphIKAn_old.r" "Script_190601_1955_spatial.r"
[83] "Script_190708_0930_distance.r" "Script_190709_0930_impact
renard.r" [85] "Script_200117_cinetiques_article.r"
"Script_200119_source_stats_explore_diurne.r" [87]
"Script_200119_stats.r" "Script_200122_spatial_distribution.r" [89]
"Script_200124_distance.r" "Script_200124_distance_source_d.r" [91]
"Script_200124_distance_source_n.r" "Script_200201_impacts_on_prey.R"
[93] "ScriptCompteLignes.r" "Scripts_avant_200112.zip" [95] "shinyChim"
"ShinyConnect.R" [97] "shinyPred" "StudyArea.dbf" [99] "StudyArea.prj"
"StudyArea.shp" [101] "StudyArea.shx" "SurfaceZoneEtude.dbf" [103]
"SurfaceZoneEtude.prj" "SurfaceZoneEtude.shp" [105]
"SurfaceZoneEtude.shx" "transects_camp.Rdata"

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to