[R] Problem Subsetting Rows that Have NA's

2017-10-24 Thread BooBoo
This has every appearance of being a bug. If it is not a bug, can 
someone tell me what I am asking for when I ask for "x[x[,2]==0,]". Thanks.


> #here is the toy dataset
> x <- rbind(c(1,1),c(2,2),c(3,3),c(4,0),c(5,0),c(6,NA),
+   c(7,NA),c(8,NA),c(9,NA),c(10,NA)
+ )
> x
  [,1] [,2]
 [1,]11
 [2,]22
 [3,]33
 [4,]40
 [5,]50
 [6,]6   NA
 [7,]7   NA
 [8,]8   NA
 [9,]9   NA
[10,]   10   NA
>
> #it contains rows that have NA's
> x[is.na(x[,2]),]
 [,1] [,2]
[1,]6   NA
[2,]7   NA
[3,]8   NA
[4,]9   NA
[5,]   10   NA
>
> #seems like an unreasonable answer to a reasonable question
> x[x[,2]==0,]
 [,1] [,2]
[1,]40
[2,]50
[3,]   NA   NA
[4,]   NA   NA
[5,]   NA   NA
[6,]   NA   NA
[7,]   NA   NA
>
> #this is more what I was expecting
> x[which(x[,2]==0),]
 [,1] [,2]
[1,]40
[2,]50
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Problem Subsetting Rows that Have NA's

2017-10-25 Thread BooBoo

On 10/25/2017 4:38 AM, Ista Zahn wrote:

On Tue, Oct 24, 2017 at 3:05 PM, BooBoo  wrote:

This has every appearance of being a bug. If it is not a bug, can someone
tell me what I am asking for when I ask for "x[x[,2]==0,]". Thanks.

You are asking for elements of x where the second column is equal to zero.

help("==")

and

help("[")

explain what happens when missing values are involved. I agree that
the behavior is surprising, but your first instinct when you discover
something surprising should be to read the documentation, not to post
to this list. After having read the documentation you may post back
here if anything remains unclear.

Best,
Ista


#here is the toy dataset
x <- rbind(c(1,1),c(2,2),c(3,3),c(4,0),c(5,0),c(6,NA),

+   c(7,NA),c(8,NA),c(9,NA),c(10,NA)
+ )

x

   [,1] [,2]
  [1,]11
  [2,]22
  [3,]33
  [4,]40
  [5,]50
  [6,]6   NA
  [7,]7   NA
  [8,]8   NA
  [9,]9   NA
[10,]   10   NA

#it contains rows that have NA's
x[is.na(x[,2]),]

  [,1] [,2]
[1,]6   NA
[2,]7   NA
[3,]8   NA
[4,]9   NA
[5,]   10   NA

#seems like an unreasonable answer to a reasonable question
x[x[,2]==0,]

  [,1] [,2]
[1,]40
[2,]50
[3,]   NA   NA
[4,]   NA   NA
[5,]   NA   NA
[6,]   NA   NA
[7,]   NA   NA

#this is more what I was expecting
x[which(x[,2]==0),]

  [,1] [,2]
[1,]40
[2,]50
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


I wanted to know if this was a bug so that I could report it if so. You 
say it is not, so you answered my question. As far as me not reading the 
documentation, I challenge anyone to read the cited help pages and 
predict the observed behavior based on the information given in those 
pages.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] R 2.9.0 MASS package

2009-04-20 Thread BooBoo

I learned something good today (MASS is in R by default). Thanks.

Tom

Peter Dalgaard wrote:

Tom La Bone wrote:

In Windows Xp Pro:

R2.8.1 USA(CA1) repository

markerSearchPower
MASS(VR)
MasterBayes


R2.9.0 USA(CA1) repository

markerSearchPower
MasterBayes

MASS is not where it used to be. I checked a couple of other 
repositories in

the US and got similar results.

Tom



But it's in R, no?

Anyways, the VR bundle appears to be in the Windows binary area on one 
CA CRAN mirror but not the other (UCLA doesn't have it, UCB does).


-p



Peter Dalgaard wrote:

Tom La Bone wrote:

I can't seem to find MASS for the latest version of R. Is it coming or
has
the name of the package changed?

Tom

Where did you look?

It is in the sources (as part of VR), and also in my (SUSE) test builds.







__
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] Extracting Coefficients and Such from mle2 Output

2009-02-01 Thread BooBoo
I had asked this question once before about a function in the NADA 
package, and you provided this neat response:


[Begin quote]

An approach that may yield somewhat more self-documenting code would be 
to examine either the fit object or the summary object with str and then 
to access results by extracting named elements. Since I don't have the 
package in question, let me use the lm object on its help page as an 
example:


 ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
 trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
 group <- gl(2,10,20, labels=c("Ctl","Trt"))
 weight <- c(ctl, trt)
 lm.D9 <- lm(weight ~ group)

 str(lm.D9)
 str(summary(lm.D9))
 summary(lm.D9)$coefficients
 summary(lm.D9)$coefficients["groupTrt", "Pr(>|t|)"]

# to get the p-value
> summary(lm.D9)$coefficients["groupTrt","Pr(>|t|)"]
[1] 0.2490232

[End quote]

However, this does not seem to work with mle2, and the methods you 
suggested this time don't allow me access to the "etc" (the standard 
error and its probability for example). Is there a way to do this 
similar to what you suggested for lm, where I can at anything reported 
by mle2?


Tom


David Winsemius wrote:


On Jan 31, 2009, at 9:13 PM, Tom La Bone wrote:



The mle2 function (bbmle library) gives an example something like the
following in its help page. How do I access the coefficients, standard
errors, etc in the summary of "a"?


?coef
?vcov

eeep. Further comment on "etc" not possible at this time. Mind reading 
equipment malfunction.




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


[R] moving color key in heatmap

2009-08-18 Thread Booboo Qu
Dear list,

I have a question on moving color keys when side color bars are added to a 
heatmap.
The R code below produces the color key in the upper left corner. Notice I have 
added side bars to the heatmap, but how could I move the color key below the 
image? 

--
library(gplots) 
data(mtcars) 
x <- as.matrix(mtcars) 
rc <- rainbow(nrow(x), start=0, end=.3) 
cc <- rainbow(ncol(x), start=0, end=.3) res=heatmap.2(x, RowSideColors=rc, 
ColSideColors=cc)
 
Thank you very much,
 
Pingping Qu
-
Cancer Research And Biostatistics (CRAB)
Seattle, WA 98101
 ---


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