Stefano,

How are you reading your data into R?  If you are using a function like
read.table(), you may be able to inform R upon reading the data that -999
represents a missing value using an option like na.strings, for example:
     read.table(file, na.strings="-999")

Otherwise, you can change the -999 to NA after creating the object my_array
using this:
     my_array[my_array==-999] <- NA

Jean




On Tue, Apr 2, 2013 at 7:40 AM, Stefano Sofia <
stefano.so...@regione.marche.it> wrote:

> Dear R-users,
> suppose I have three dataframes like these
>
> df1:
> mydate min_temp
> 31032013  12
> 01042013 8
> 02042013 -999
>
> df2:
> mydate min_temp
> 31032013  10
> 01042013 11
> 02042013 14
>
> df3:
> mydate min_temp
> 31032013  4
> 01042013 3
> 02042013 5
>
> where -999 means that the temperature data is not available (at the moment
> I cannot change it to NA because I am not the db administrator);
> suppose also that oggi is 02042013.
>
> I need to create an array of all min_temp, having NA where min_temp is
> -999.
>
> my_array <- c(df1$min_temp[df1$mydate==oggi],
> df2$min_temp[df2$mydate==oggi], df3$min_temp[df3$mydate==oggi])
>
> creates
> (-999,14,5)
> while I need
> (NA,14,5)
>
> Can I do it directly while I create my_array, without using an external if
> statement?
>
> Thank you for your help
> Stefano Sofia
>
> 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.
> ______________________________________________
> R-help@r-project.org mailing list
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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