An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111216/ae28f827/attachment.pl>
kmeans and plot labels
3 messages · Meesters, Christian, Sarah Goslee
Hi, You include no context, and I only vaguely remember your original question. You also don't include a reproducible example. But perhaps this helps? testmat <- data.frame(x=c(1,1,2,3), y=c(2,1,3,2), names=letters[1:4], stringsAsFactors=FALSE) with(testmat, plot(x, y, pch=names)) or with(testmat, plot(x, y, type="n")) with(testmat, text(x, y, names)) Otherwise you'll have to actually follow the posting guide and pose a fully self-contained question. Sarah
On Fri, Dec 16, 2011 at 4:25 AM, Meesters, Christian <meesters at aesku.com> wrote:
Hi, Thanks Sarah. Unfortunately I did not get a step further. My question, perhaps a bit clearer, is how to display the case control status (or any other arbitrary point label) after clustering in a plot: With a bit of pseudo code, where dataset is a data.frame, parameters are those column names where we find numerical values (no NAs) and nclasses is the desired number of classes. fit <- kmeans(dataset[, parameters], nclasses) plot(dataset[, parameters], col = fit$cluster, dimen = nclasses) This gives us a nicely coloured plot where all points are circled. Yet, my desire is to see the case / control-Status encoded in a column "Status" with single characters, in place of those circled points. Any hints? I did not get pch() nor text() to work. Perhaps the solution lies there, but them I am sure that I do not see the wood for all those trees ... TIA Christian
Sarah Goslee http://www.functionaldiversity.org
Hi, You are right - I promise improvement of my way to ask. Anyhow, thanks to your comparisons I got much better insight in the way plotting environments can be altered - and have my solution. Thank you. Christian
From: Sarah Goslee [sarah.goslee at gmail.com]
Sent: Friday, December 16, 2011 3:29 PM
To: Meesters, Christian
Cc: r-help at r-project.org
Subject: Re: [R] kmeans and plot labels
Sent: Friday, December 16, 2011 3:29 PM
To: Meesters, Christian
Cc: r-help at r-project.org
Subject: Re: [R] kmeans and plot labels
Hi, You include no context, and I only vaguely remember your original question. You also don't include a reproducible example. But perhaps this helps? testmat <- data.frame(x=c(1,1,2,3), y=c(2,1,3,2), names=letters[1:4], stringsAsFactors=FALSE) with(testmat, plot(x, y, pch=names)) or with(testmat, plot(x, y, type="n")) with(testmat, text(x, y, names)) Otherwise you'll have to actually follow the posting guide and pose a fully self-contained question. Sarah On Fri, Dec 16, 2011 at 4:25 AM, Meesters, Christian <meesters at aesku.com> wrote: > Hi, > > Thanks Sarah. Unfortunately I did not get a step further. > > My question, perhaps a bit clearer, is how to display the case control status (or any other arbitrary point label) after clustering in a plot: > > With a bit of pseudo code, where dataset is a data.frame, parameters are those column names where we find numerical values (no NAs) and nclasses is the desired number of classes. > > fit <- kmeans(dataset[, parameters], nclasses) > plot(dataset[, parameters], col = fit$cluster, dimen = nclasses) > > This gives us a nicely coloured plot where all points are circled. Yet, my desire is to see the case / control-Status encoded in a column "Status" with single characters, in place of those circled points. > > Any hints? I did not get pch() nor text() to work. Perhaps the solution lies there, but them I am sure that I do not see the wood for all those trees ... > > TIA > Christian > -- Sarah Goslee http://www.functionaldiversity.org