lundi 11 juillet 2016

Can ls() have a pattern > 1?

Say I have 10 data.frames that contain dates in their names from 01-01-00 to 10-01-00 with other letters and symbols added to the end in the format ddmmyy

E.g. 010100/sgh/d_3and 020100/aff/d_1

If I wanted to create a vector of the above data.frame, is there a way to select them without writing them out individually?

I tried creating a vector of a sequence of dates and putting this in to pattern = but came up with error (code below):

Dates <- seq(as.Date("2000-01-01"),as.Date("2000-01-02"),1)
Dates <- format(Dates,"%d%m%y")
ls(pattern=Dates)

In grep(pattern, all.names, value = TRUE) :
  argument 'pattern' has length > 1 and only the first element will be used

I'm assuming that pattern can only be one value?

Aucun commentaire:

Enregistrer un commentaire