[R] melt on OSX ignores na.rm=T

2010-02-06 Thread Titus von der Malsburg
Hi list,

I run R on Linux and OSX.  On both systems I use R version 2.9.2 (2009-08-24)
and reshape version: 0.8.2 (2008-11-04).  When I do a melt with
na.rm=T on a data frame I get different results on these systems:

library(reshape)

x - read.table(textConnection(char trial wn
p E10I13D0  4
r E10I13D0  4
a E10I13D0  4
c E10I13D0  4
t E10I13D0  4
i E10I13D0  4
c E10I13D0  4
e E10I13D0  4
d E10I13D0  4
, E10I13D0 NA), head=T)

melt(x, measure.vars=char, na.rm=T)

On Linux I get:

  1 E10I13D0  4 char p
  2 E10I13D0  4 char r
  3 E10I13D0  4 char a
  4 E10I13D0  4 char c
  5 E10I13D0  4 char t
  6 E10I13D0  4 char i
  7 E10I13D0  4 char c
  8 E10I13D0  4 char e
  9 E10I13D0  4 char d

But on OSX I get:

  1  E10I13D0  4 char p
  2  E10I13D0  4 char r
  3  E10I13D0  4 char a
  4  E10I13D0  4 char c
  5  E10I13D0  4 char t
  6  E10I13D0  4 char i
  7  E10I13D0  4 char c
  8  E10I13D0  4 char e
  9  E10I13D0  4 char d
  10 E10I13D0 NA char ,


What's causing this glitch?  Is there a simple way to subset lines
that do not have any NAs?  I'm looking for a line that I can use for
all data.frames without modification.

As always: thanks a lot!

  Titus

__
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.


Re: [R] melt on OSX ignores na.rm=T

2010-02-06 Thread hadley wickham
Hi Titus,

The latest version of reshape is 0.8.3 - perhaps upgrading will fix
your problem.

Hadley

On Sat, Feb 6, 2010 at 4:51 AM, Titus von der Malsburg
malsb...@gmail.com wrote:
 Hi list,

 I run R on Linux and OSX.  On both systems I use R version 2.9.2 (2009-08-24)
 and reshape version: 0.8.2 (2008-11-04).  When I do a melt with
 na.rm=T on a data frame I get different results on these systems:

 library(reshape)

 x - read.table(textConnection(char trial wn
 p E10I13D0  4
 r E10I13D0  4
 a E10I13D0  4
 c E10I13D0  4
 t E10I13D0  4
 i E10I13D0  4
 c E10I13D0  4
 e E10I13D0  4
 d E10I13D0  4
 , E10I13D0 NA), head=T)

 melt(x, measure.vars=char, na.rm=T)

 On Linux I get:

  1 E10I13D0  4     char     p
  2 E10I13D0  4     char     r
  3 E10I13D0  4     char     a
  4 E10I13D0  4     char     c
  5 E10I13D0  4     char     t
  6 E10I13D0  4     char     i
  7 E10I13D0  4     char     c
  8 E10I13D0  4     char     e
  9 E10I13D0  4     char     d

 But on OSX I get:

  1  E10I13D0  4     char     p
  2  E10I13D0  4     char     r
  3  E10I13D0  4     char     a
  4  E10I13D0  4     char     c
  5  E10I13D0  4     char     t
  6  E10I13D0  4     char     i
  7  E10I13D0  4     char     c
  8  E10I13D0  4     char     e
  9  E10I13D0  4     char     d
  10 E10I13D0 NA     char     ,


 What's causing this glitch?  Is there a simple way to subset lines
 that do not have any NAs?  I'm looking for a line that I can use for
 all data.frames without modification.

 As always: thanks a lot!

  Titus

 __
 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.




-- 
http://had.co.nz/

__
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.


Re: [R] melt on OSX ignores na.rm=T

2010-02-06 Thread Titus von der Malsburg
On Sat, Feb 6, 2010 at 8:23 PM, hadley wickham h.wick...@gmail.com wrote:
 The latest version of reshape is 0.8.3 - perhaps upgrading will fix
 your problem.

Thanks for your response, Hadley!

I just did the upgrade on the Linux system.  On OSX I was already at
0.8.3.  Now, I get the same result on both systems.  However, the
result includes the NAs although I said na.rm=T:

library(reshape)

x - read.table(textConnection(char trial wn
p E10I13D0  4
r E10I13D0  4
a E10I13D0  4
c E10I13D0  4
t E10I13D0  4
i E10I13D0  4
c E10I13D0  4
e E10I13D0  4
d E10I13D0  4
, E10I13D0 NA), head=T)

melt(x, measure.vars=char, na.rm=T)
  trial wn variable value
1  E10I13D0  4 char p
2  E10I13D0  4 char r
3  E10I13D0  4 char a
4  E10I13D0  4 char c
5  E10I13D0  4 char t
6  E10I13D0  4 char i
7  E10I13D0  4 char c
8  E10I13D0  4 char e
9  E10I13D0  4 char d
10 E10I13D0 NA char ,

The documentation says na.rm: Should NA values be removed from the
data set?.  Do I get something wrong?

  Titus

__
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.


Re: [R] melt on OSX ignores na.rm=T

2010-02-06 Thread Titus von der Malsburg
Ok, I studied the source code of melt.data.frame.  With na.rm=T melt
operates normally except that it deletes rows from the molten
data.frame that have NAs in the value column.  NAs in the id.vars are
not touched.  This could be clearer in the documentation especially as
it seems that earlier versions of reshape behaved differently.

Best,

  Titus

__
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.