[R] create a vector from several data frames

Stefano Sofia stefano.sofia at regione.marche.it
Thu May 14 16:22:48 CEST 2015


Dear r-users,
suppose that I have 20 data frames df1, df2, ..., df20 (one for each different location) with the same column names and column types (the first column contains a date, the others are numeric) like

day tmax tmin
2015-05-10 20 10
2015-05-11 21 12
2015-05-12 17 9
2015-05-13 24 13
2015-05-14 25 18

I need to create a vector "tmax_all" of length 20 with the tmax referred to a particular day (let's say 2015-05-14).
I would first build a new data frame

tmax_df <- Reduce(function(x, y) merge(x, y, by="day"), list(df1[ , c("day", "tmax")], df2[ , c("day", "tmax")], ..., df20[ , c("day", "tmax")]))

and then select the row of tmax_df where day is the day I want to.
Is there an easiest way? Is it possible to create straightforward this vector without passing through the merge of all the data frames?

Thank you for your help
Stefano

________________________________

AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere informazioni confidenziali, pertanto è destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si è il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed urgenza, la risposta al presente messaggio di posta elettronica può essere visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.


More information about the R-help mailing list