pfc_ivan
2009-Feb-04 05:55 UTC
[R] Using color and plotting characters in a scatterplot matrix [Newbie Help]
Hello guys, I have this data set that I imported into R using a line: This data set consists of 7 columns. The two important columns are the first one called 'thrust' and the last one called 'amtemp'. jet<-read.table("jetthrust.txt", fill=T, head=T) I am making a scatterplot matrix simply using the line "pairs(jet)" The problem is that in the last column of this file which has a header name 'amtemp' I want to sort out the values. I want values: Under 90: To be called low values In between 90 and 100: To be called medium values Larger than 100: To be called high values Then I want those groups of values to be in different colors and different characters on the scatterplot! I tried many ways, And I think I am stuck. I first tried it on a normal plot using the line. plot(thrust~amtemp,jet, subset=(jet$amtemp<90), col=1, pch=11) plot(thrust~amtemp,jet, subset=(jet$amtemp<100), col=2, pch=12) plot(thrust~amtemp,jet, subset=(jet$amtemp>100), col=3, pch=13) It didnt work because it just took the last plot and overwrite it over the last one :( Someone help please. Thanks in advance. -- View this message in context: http://www.nabble.com/Using-color-and-plotting-characters-in-a-scatterplot-matrix--Newbie-Help--tp21824880p21824880.html Sent from the R help mailing list archive at Nabble.com.
pfc_ivan
2009-Feb-04 07:58 UTC
[R] Using color and plotting characters in a scatterplot matrix [Newbie Help]
I figured out how to do the rest, the only thing I need to do now is to somehow change the numbers which are < 90 to a character string "low" . The values which are between 100 - 90 to convert to character string "medium". And the values larger than 100 to convert to character string "high". Then I would use this line. plot(thrust~amtemp, jet, col=as.numeric(jet$amtemp), pch=as.numeric(jet$amtemp)) The thing is that I dont know how to convert those numerical values into "low" "medium" and "high" Hmm, but then when I think about it better if its changed to the strings above, it wont remember the exact numerical value. Basically what I want to do is make a scatterplot and then just change the color and the symbol of those 3 groups so they can be distinguished on the graph. -- View this message in context: http://www.nabble.com/Using-color-and-plotting-characters-in-a-scatterplot-matrix--Newbie-Help--tp21824880p21825882.html Sent from the R help mailing list archive at Nabble.com.
ONKELINX, Thierry
2009-Feb-04 09:40 UTC
[R] Using color and plotting characters in a scatterplot matrix [Newbie Help]
First make a factor with the levels. jet$Classes <- factor(ifelse(jet$amtemp < 90, "low", ifelse(jet$amtemp < 100, "medium", "high"))) Then make life easier and use ggplot install.packages("ggplot2") library("ggplot2") ggplot(jet, aes(x = amtemp, y = thrust, colour = Classes)) + geom_point() HTH, Thierry ------------------------------------------------------------------------ ---- ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 Thierry.Onkelinx at inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -----Oorspronkelijk bericht----- Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Namens pfc_ivan Verzonden: woensdag 4 februari 2009 8:59 Aan: r-help at r-project.org Onderwerp: Re: [R] Using color and plotting characters in a scatterplot matrix [Newbie Help] I figured out how to do the rest, the only thing I need to do now is to somehow change the numbers which are < 90 to a character string "low" . The values which are between 100 - 90 to convert to character string "medium". And the values larger than 100 to convert to character string "high". Then I would use this line. plot(thrust~amtemp, jet, col=as.numeric(jet$amtemp), pch=as.numeric(jet$amtemp)) The thing is that I dont know how to convert those numerical values into "low" "medium" and "high" Hmm, but then when I think about it better if its changed to the strings above, it wont remember the exact numerical value. Basically what I want to do is make a scatterplot and then just change the color and the symbol of those 3 groups so they can be distinguished on the graph. -- View this message in context: http://www.nabble.com/Using-color-and-plotting-characters-in-a-scatterpl ot-matrix--Newbie-Help--tp21824880p21825882.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at 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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.