Dear R-Users, I store my data in an Postgres-table. I can connect with Rdbi.PgSQL, that is no the problem. The problem is the NA-Values. No-data-values are coded as -9999 in the table. But when I extrct them with any SELECT-statement, the -9999-values are treated as normal vectors. How can I tell R not to fetch the datasets containig -9999-values? thanks for your help stephan -- Linux: the operating system with a CLUE... Command Line User Environment. -------------------------------------- Stephan Holl GnuPG Key-ID: 11946A09 ICQ# 117277975 -------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-help/attachments/20020729/38c7605f/attachment.bin
On Mon, Jul 29, 2002 at 03:50:02PM +0200, Stephan Holl wrote:> The problem is the NA-Values. No-data-values are coded as -9999 in the > table. > But when I extrct them with any SELECT-statement, the -9999-values are > treated as normal vectors. > How can I tell R not to fetch the datasets containig -9999-values?Two ways: 1) If you *do* want to see how many NA cases you have (this can also be interesting sometimes), use R's usual indexing ...{get data with your select, store in a vector named foo} ... foo[foo==-9999] <- NA 2) If you aren't interested in which cases were NA values, do it from the SQL SELECT statement: SELECT foo FROM bar WHERE foo <> -9999 Cheers Jason -- Indigo Industrial Controls Ltd. 64-21-343-545 jasont at indigoindustrial.co.nz -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello, Stephan Holl wrote:> Dear R-Users, > I store my data in an Postgres-table. > I can connect with Rdbi.PgSQL, that is no the problem. > The problem is the NA-Values. No-data-values are coded as -9999 in the > table. > But when I extrct them with any SELECT-statement, the -9999-values are > treated as normal vectors. > How can I tell R not to fetch the datasets containig -9999-values? > > thanks for your help > > stephan > > > -- > Linux: the operating system with a CLUE... > Command Line User Environment. > -------------------------------------- > Stephan Holl > GnuPG Key-ID: 11946A09 > ICQ# 117277975 > --------------------------------------The convention of encoding NA's as -9999 is particular to your application (not SQL nor R), so your code (SQL and/or R) will have to account for them. I'm not sure how you are extracting your data (via a query or support function in the RPgSQL package), but I'll suggest modifying your SQL query to include a where clause explicitly specifying that your variable be different from -9999, select * from foo_table where foo_var != -9999; Alternatively, in R you can delete those rows that have the -9999 as foo <- foo[foo$var != -9999, ] You may want to consider using the SQL value NULL instead of -9999 to denote missing data. Regards, -- David A. James Statistics Research, Room 2C-253 Phone: (908) 582-3082 Bell Labs, Lucent Technologies Fax: (908) 582-3340 Murray Hill, NJ 09794-0636 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._