[R] replace a value in a vector
OK, so this is a really stupid question and should be incredibly simple to do but I can't figure it out. So maybe someone would be so kind as to tell me. I have a vector of zeros and ones. I want to replace all of the zeros with "black" and all of the ones with "gray". That's it. Any help would be appreciated. Thanks, Paul `-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. `=`,'=/ `=`,'=/ `=`,'=/ `=`,'=/ `=`,'=/ `=` >==/>==/>==/>==/>==/ ,=,-<=`.,=,-<=`.,=,-<=`. ,=,-<=`.,=,-<=`.,=, ,-'-' `-=_,-'-' `-=_,-'-' `-=_,-'-' `-=_,-'-' `-=_,-'-' Paul Lepp, Ph.D. Stanford School of Medicine VAPAHCS, 154T Dept. of Microbiology & Immunology 3801 Miranda Ave Stanford University Palo Alto, CA 94304 Stanford, CA (650) 493-5000 x66762 fax: (650) 852-3291 http://cmgm.stanford.edu/~pwlepp [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] heatmap2
Can anybody tell me where to find a copy of heatmap2? I've seen it in my travels across the web but didn't bookmark it and can't find it again. Thanks in advance. Paul `-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. `=`,'=/ `=`,'=/ `=`,'=/ `=`,'=/ `=`,'=/ `=` >==/>==/>==/>==/>==/ ,=,-<=`.,=,-<=`.,=,-<=`.,=,-<=`. ,=,-<=`.,=, ,-'-' `-=_,-'-' `-=_,-'-' `-=_,-'-' `-=_,-'-' `-=_,-'-' Paul Lepp, Ph.D. Stanford School of Medicine VAPAHCS, 154T Dept. of Microbiology & Immunology 3801 Miranda Ave Stanford University Palo Alto, CA 94304 Stanford, CA (650) 493-5000 x66762 fax: (650) 852-3291 http://cmgm.stanford.edu/~pwlepp [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] heatmap help
Thanks Marta (and Andy). Between the two of you I think I got the result I was looking for. I ended up doing the following: heatmap(x, distfun=function(x) as.dist(x)) Thanks again. > -Original Message- > From: Marta Rufino [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 08, 2004 2:22 AM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: Re: [R] heatmap help > > > Hello, > > > I was just doing heatmaps myself ;-) and I had the same problem. > It would be > nice to have such an example in the help file because it is not > clear (thank > you). > you use (for example... this is my case, which I am doing the distance > matrix using vegdist function with Bray curtis similarity): > > heatmap(matrix, scale="none", distfun=function(m) vegdist(m, > method="bray"), > hclustfun=function(m) hclust(m, method="average"), col= > grey(seq(0.8,0,l=5))) > > or you can put directly the distance matrix that you may want, but I found > it worst. To have the right labels on I found that the best way > would be to > have them in the matrix directely, because if we put it after it does not > work well... > > I have been having difficulties in producing the scale that I > want and doing > the correct legend... > I found an email with a function (image.scale()), but it does not work > entirely well. > How can I define the values I want in the scale, for example, use > red for 1 > g, blue for 2 g, etc... > Is there a simpler way of doing the legend? > > thank you very much, > Marta > > > > Dear R wizards, > > Hopeful someone can help me with what I believe is a pretty simple task. > I > > pretty new to R so some (much) of the obvious escapes me. How do I get a > > distance matrix into heatmap? What do I tell distfun if what I'm trying > to > > map is already an ordered distance matrix? I tried >heatmap(x, > > distfun=as.dist(x)) where x is the distance matrix but R gave > me an error. > > Thanks in advance for any help. > > > > Paul Lepp > > > > `-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. > > `=`,'=/ `=`,'=/ `=`,'=/ `=`,'=/ `=`,'=/ `=` > > >==/>==/>==/>==/>==/ > >,=,-<=`.,=,-<=`.,=,-<=`.,=,-<=`.,=,-<=`.,=, > > ,-'-' `-=_,-'-' `-=_,-'-' `-=_,-'-' `-=_,-'-' `-=_,-'-' > > Paul Lepp, Ph.D. Stanford School of Medicine > > > > VAPAHCS, 154T Dept. of Microbiology & Immunology > > 3801 Miranda Ave Stanford University > > Palo Alto, CA 94304 Stanford, CA > > (650) 493-5000 x66762fax: (650) 852-3291 > > http://cmgm.stanford.edu/~pwlepp [EMAIL PROTECTED] > > > > __ > > [EMAIL PROTECTED] mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] heatmap help
Dear R wizards, Hopeful someone can help me with what I believe is a pretty simple task. I pretty new to R so some (much) of the obvious escapes me. How do I get a distance matrix into heatmap? What do I tell distfun if what I'm trying to map is already an ordered distance matrix? I tried >heatmap(x, distfun=as.dist(x)) where x is the distance matrix but R gave me an error. Thanks in advance for any help. Paul Lepp `-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. `=`,'=/ `=`,'=/ `=`,'=/ `=`,'=/ `=`,'=/ `=` >==/>==/>==/>==/>==/ ,=,-<=`.,=,-<=`.,=,-<=`.,=,-<=`. ,=,-<=`.,=, ,-'-' `-=_,-'-' `-=_,-'-' `-=_,-'-' `-=_,-'-' `-=_,-'-' Paul Lepp, Ph.D. Stanford School of Medicine VAPAHCS, 154T Dept. of Microbiology & Immunology 3801 Miranda Ave Stanford University Palo Alto, CA 94304 Stanford, CA (650) 493-5000 x66762 fax: (650) 852-3291 http://cmgm.stanford.edu/~pwlepp [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html