Dear Anonymous/Lindsey Nielsen(?): While it would not be hard to answer your questions, given your admitted lack of programming or R experience, approaching your ignorance piecemeal in this fashion does not seem to be a sensible way to learn either. Instead, please start by reading the "Introduction to R" tutorial that comes with the software and working through its examples carefully. More than likely, this will get you well on your way and also allow you gain access to many more or R's capabilities. If you analyze data as part of your career, you won't regret this investment. You will also be able to use R's native Help system and search capabilities, which much of the time will provide you the information you need to solve your difficulties.
After you have done this, you should also be able to seek the help of this list more effectively when you are stumped (as most of us are from time to time), thus wasting both less of both your time and ours. Cheers, Bert On Wed, May 11, 2011 at 7:23 PM, nielsen4897 <lindseynielse...@gmail.com> wrote: > Hi all - > I am NEW to R and NEW to any type of programming. I am making heatmaps > using the heatmap.2 function within gplots package. At present, when the > heatmap is plotted it uses the row identifiers as 1,2,3,4...etc. However, I > much rather use my own labels. I was told my another well-versed R > programmer to use the follow script: > x<-as.matrix(test1[,-1]) ## skip column 1 > rownames(x)<- test[1,] > heatmap(x, scale="none") > > This was for data set up in 4 columns such as when you read the data in R it > looks like: > Loci Cont NaCl Peg > 1 0231 2.1 4.2 4.1 > 2 1253 4.1 2.3 2.3 > 3 8167 5.7 1.1 3.4 > > Using the script above and this dataset it worked well - the Loci was used > as the row labels rather than the numbers assigned by R. > Looking at the data after this script it looks like: > Loci Cont NaCl Peg > 0231 0231 2.1 4.2 4.1 > 1253 1253 4.1 2.3 2.3 > 8167 8167 5.7 1.1 3.4 > > > Now, I want to do the same thing BUT my dataset looks like this: > Loci NaCl Peg > 1 0231 23.2 34.1 > 2 1253 25.3 21.3 > 3 8167 21.1 38.4 > > When I put in the script > x<-as.matrix(test1[,-1]) ## skip column 1 > rownames(x)<- test[1,] > heatmap(x, scale="none") > > This is what follows (after looking at the dataset change) > NaCl Peg > [1,] 23.2 34.1 > [2,] 25.3 21.3 > [3,] 21.1 38.4 > > If I alter the -1 in the x<-as.matrix(test1[,-1]) line it will 'skip' other > columns but not the first one. > > What do I need to enter to make the dataset look like ? > Loci NaCl Peg > 0231 0231 23.2 34.1 > 1253 1253 25.3 21.3 > 8167 8167 21.1 38.4 > > Please explain the answer and WHAT the #'s inside the [] mean! > > Thanks > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Row-names-and-matrixs-tp3516372p3516372.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > -- "Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions." -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics ______________________________________________ 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.