Hi I have dataset that consists of two columns AB 0.102 AC -0.002 BA -0.102 BC 0.270 CA 0.002 CB -0.270 I wish to create a matrix so that I can eventually plot the data. A B C A 1 0.102 -0.002 B -0.102 1 0.27 C 0.002 -0.27 1 Any help or guidance would be greatly appreciated Dr Riyad Ismail GIS / Remote Sensing Analyst Sappi Forests (Reg No 1976/02426/07) Tel +27 (0)33 347 6650 Fax +27 (0)33 347 6790 E-mail: riyad.ismail@sappi.com The opinions contained in this message are those of the sender only and do not reflect those of Sappi Limited or any of its subsidiary or associated companies. "This message, including any attachment(s), may contain information which is private, privileged or confidential and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient of this message, please notify the sender thereof and destroy/delete the message. Neither the sender nor Sappi Limited (including its subsidiaries and associated companies, jointly referred to as 'Sappi') shall incur any liability resulting directly or indirectly from accessing any of the attached files which may contain a virus or the like. Any opinions, statements, conclusions and other information contained in this message and/or its attachment(s) that do not relate or refer to the official business of Sappi Limited or any of its subsidiary or associated companies shall be regarded as neither provided nor approved by any Sappi company. Views expressed in this message or its attachment(s) may not necessarily be those of Sappi and Sappi cannot be held liable for any direct or indirect loss or injury resulting from the contents of a message and/or its attachments." Directors names A list of Sappi companies and the names of their directors can be retrieved from http://www.sappi.com/SappiWeb/Investor+info/Corporate+governance/Board+resumes ##################################################################################### Scanned by MailMarshal - Marshal's comprehensive email content security solution. Download a free evaluation of MailMarshal at www.marshal.com ##################################################################################### [[alternative HTML version deleted]]
Split the first column into two columns. One with the first letter and one with the last letter. Then you cast() from the reshape-package to create the matrix you want. 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 Ismail, Riyad Verzonden: dinsdag 4 augustus 2009 13:36 Aan: r-help at r-project.org Onderwerp: [R] matrix Hi I have dataset that consists of two columns AB 0.102 AC -0.002 BA -0.102 BC 0.270 CA 0.002 CB -0.270 I wish to create a matrix so that I can eventually plot the data. A B C A 1 0.102 -0.002 B -0.102 1 0.27 C 0.002 -0.27 1 Any help or guidance would be greatly appreciated Dr Riyad Ismail GIS / Remote Sensing Analyst Sappi Forests (Reg No 1976/02426/07) Tel +27 (0)33 347 6650 Fax +27 (0)33 347 6790 E-mail: riyad.ismail at sappi.com The opinions contained in this message are those of the sender only and do not reflect those of Sappi Limited or any of its subsidiary or associated companies. "This message, including any attachment(s), may contain information which is private, privileged or confidential and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient of this message, please notify the sender thereof and destroy/delete the message. Neither the sender nor Sappi Limited (including its subsidiaries and associated companies, jointly referred to as 'Sappi') shall incur any liability resulting directly or indirectly from accessing any of the attached files which may contain a virus or the like. Any opinions, statements, conclusions and other information contained in this message and/or its attachment(s) that do not relate or refer to the official business of Sappi Limited or any of its subsidiary or associated companies shall be regarded as neither provided nor approved by any Sappi company. Views expressed in this message or its attachment(s) may not necessarily be those of Sappi and Sappi cann! ot be held liable for any direct or indirect loss or injury resulting from the contents of a message and/or its attachments." Directors names A list of Sappi companies and the names of their directors can be retrieved from http://www.sappi.com/SappiWeb/Investor+info/Corporate+governance/Board+r esumes ######################################################################## ############# Scanned by MailMarshal - Marshal's comprehensive email content security solution. Download a free evaluation of MailMarshal at www.marshal.com ######################################################################## ############# [[alternative HTML version deleted]] ______________________________________________ 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.
You can try something about like this: merge(transform(x, V1 = gsub("^[A-Z]", "", x$V1), V3 = gsub("[A-Z]$", "", x$V1)), data.frame(V1 = LETTERS[1:3], V3 = LETTERS[1:3], V2 = 1), by = c("V1", "V3"), all = TRUE) On Tue, Aug 4, 2009 at 8:35 AM, Ismail, Riyad <Riyad.Ismail@sappi.com>wrote:> Hi > > > > I have dataset that consists of two columns > > > > AB 0.102 > > > > AC -0.002 > > > > BA -0.102 > > > > BC 0.270 > > > > CA 0.002 > > > > CB -0.270 > > > > > > I wish to create a matrix so that I can eventually plot the data. > > > > > > > > A > > B > > C > > A > > 1 > > 0.102 > > -0.002 > > B > > -0.102 > > 1 > > 0.27 > > C > > 0.002 > > -0.27 > > 1 > > > > > > > > Any help or guidance would be greatly appreciated > > > > > > > > Dr Riyad Ismail > > GIS / Remote Sensing Analyst > > > Sappi Forests (Reg No 1976/02426/07) > > Tel +27 (0)33 347 6650 > > Fax +27 (0)33 347 6790 > > E-mail: riyad.ismail@sappi.com > > > > > The opinions contained in this message are those of the sender only and do > not reflect those of Sappi Limited or any of its subsidiary or associated > companies. > > "This message, including any attachment(s), may contain information which > is private, privileged or confidential and is intended solely for the use of > the individual or entity named in this message. If you are not the intended > recipient of this message, please notify the sender thereof and > destroy/delete the message. Neither the sender nor Sappi Limited (including > its subsidiaries and associated companies, jointly referred to as 'Sappi') > shall incur any liability resulting directly or indirectly from accessing > any of the attached files which may contain a virus or the like. Any > opinions, statements, conclusions and other information contained in this > message and/or its attachment(s) that do not relate or refer to the official > business of Sappi Limited or any of its subsidiary or associated companies > shall be regarded as neither provided nor approved by any Sappi company. > Views expressed in this message or its attachment(s) may not necessarily be > those of Sappi and Sappi cann! > ot be held liable for any direct or indirect loss or injury resulting from > the contents of a message and/or its attachments." > > > Directors names > > A list of Sappi companies and the names of their directors can be retrieved > from > http://www.sappi.com/SappiWeb/Investor+info/Corporate+governance/Board+resumes > > > > > ##################################################################################### > Scanned by MailMarshal - Marshal's comprehensive email content security > solution. > Download a free evaluation of MailMarshal at www.marshal.com > > ##################################################################################### > > [[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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
My apologies, to elaborate I carried out a correlation analysis and I want to plot the data (similar to the graphs available in the corrplot package. However, the results are as follows (I have many more combinations): AB 0.102 AC -0.002 BA -0.102 BC 0.270 CA 0.002 CB -0.270 I now want to create a matrix that uses the names from the first column as a "reference", so in the matrix the first row name will be "A" and the first column name will be "B" with a value of 0.102. I will be using the script available on http://www.phaget4.org/R/image_matrix.html to plot the data The opinions contained in this message are those of the sender only and do not reflect those of Sappi Limited or any of its subsidiary or associated companies. "This message, including any attachment(s), may contain information which is private, privileged or confidential and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient of this message, please notify the sender thereof and destroy/delete the message. Neither the sender nor Sappi Limited (including its subsidiaries and associated companies, jointly referred to as 'Sappi') shall incur any liability resulting directly or indirectly from accessing any of the attached files which may contain a virus or the like. Any opinions, statements, conclusions and other information contained in this message and/or its attachment(s) that do not relate or refer to the official business of Sappi Limited or any of its subsidiary or associated companies shall be regarded as neither provided nor approved by any Sappi company. Views expressed in this message or its attachment(s) may not necessarily be those of Sappi and Sappi cannot be held liable for any direct or indirect loss or injury resulting from the contents of a message and/or its attachments." Directors names A list of Sappi companies and the names of their directors can be retrieved from http://www.sappi.com/SappiWeb/Investor+info/Corporate+governance/Board+resumes ##################################################################################### Scanned by MailMarshal - Marshal's comprehensive email content security solution. Download a free evaluation of MailMarshal at www.marshal.com #####################################################################################