Hello,
I am an absolutely beginner with regards to R, so forgive me for my potentially very stupid questions. I have been attempting to create recurrence plots using R. The data I am using is based on a mutually exclusive and exhaustive coding scheme with over 40 individual codes which can be assigned to 6 higher order categories. When I carry out the usual rqa command, my plot is pretty much black - no surprises there really considering the exhaustive nature of my coding scheme and the fact that there are only 6 different categories. What i would like to do is colour-code my categories in order to arrive at a plot that shows the colour of the reccurence of the specific category. Eventually that would mean a plot with six different colours (next to white, which means no recurrence), rather than the plain black and white plot which does not reflect the nature of the recurrence. I hope that my explanation is clear enough. My procedure up until now has been: 1) perform a recurrence quantification analysis: testplot <- rqa(time.series = test$Code, embedding.dim = 1, time.lag = 1, radius = 0.1,lmin =2, vmin =2, distanceToBorder = 2, save.RM = TRUE, do.plot = TRUE) This plot is based on a TRUE FALSE sparse matrix. 2) Accordingly the next step was to transform this TRUE FALSE matrix to one that contains the values for the codes for TRUE and 0 for false: RP1 <- testplot$recurrence.matrix RP2 <- as.matrix(RP1)*1 TS <- test$Code for (i in seq(1,dim(RP2)[1])) { for (j in seq(1,dim(RP2)[1])) { if (RP2[i,j] == 1) { RP2[i,j] <- TS[i] } } } This results in a matrix of this type: 1 0 3 1 0 4 0 0 1 0 5 6 Now I am missing step 3 --> how can plot this matrix by previously assigning different colours to the numbers? Thank you in advance for your help! Best, Lisa -- M.Sc. Lisa Handke Technische Universit�t Braunschweig Institut f�r Psychologie Lehrstuhl f�r Arbeits-, Organisations- und Sozialpsychologie Spielmannstrasse 19, Raum 103 D-38106 Braunschweig Phone: +49 (0)531-391-2539 Fax: +49 (0)531-391-8173 Mail: <mailto:[hidden email]> [hidden email] <http://www.tu-braunschweig.de/psychologie/abt/aos> www.tu-braunschweig.de/psychologie/abt/aos [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
Hi Lisa,
I'm not sure exactly what sort of plot you want, but this may help: rcol<-matrix(c(1,0,3,1,0,4,0,0,1,0,5,6),ncol=4,byrow=TRUE) # replace zeros with NAs as there is no numeric color for zero rcol[rcol==0]<-NA library(plotrix) color2D.matplot(rcol,cellcolors=rcol,yat=1:3) Jim On Fri, Oct 13, 2017 at 12:18 AM, <[hidden email]> wrote: > Hello, > > I am an absolutely beginner with regards to R, so forgive me for my > potentially very stupid questions. > > I have been attempting to create recurrence plots using R. The data I am > using is based on a mutually exclusive and exhaustive coding scheme with > over 40 individual codes which can be assigned to 6 higher order categories. > When I carry out the usual rqa command, my plot is pretty much black - no > surprises there really considering the exhaustive nature of my coding scheme > and the fact that there are only 6 different categories. > > What i would like to do is colour-code my categories in order to arrive at a > plot that shows the colour of the reccurence of the specific category. > Eventually that would mean a plot with six different colours (next to white, > which means no recurrence), rather than the plain black and white plot which > does not reflect the nature of the recurrence. I hope that my explanation is > clear enough. > > My procedure up until now has been: > > 1) perform a recurrence quantification analysis: > > testplot <- rqa(time.series = test$Code, embedding.dim = 1, time.lag = 1, > > radius = 0.1,lmin =2, vmin =2, distanceToBorder = 2, save.RM > = TRUE, do.plot = TRUE) > > > > This plot is based on a TRUE FALSE sparse matrix. > > 2) Accordingly the next step was to transform this TRUE FALSE matrix to one > that contains the values for the codes for TRUE and 0 for false: > > RP1 <- testplot$recurrence.matrix > RP2 <- as.matrix(RP1)*1 > TS <- test$Code > > for (i in seq(1,dim(RP2)[1])) { > for (j in seq(1,dim(RP2)[1])) { > if (RP2[i,j] == 1) { > RP2[i,j] <- TS[i] > } > } > } > > This results in a matrix of this type: > > 1 0 3 1 > 0 4 0 0 > 1 0 5 6 > > > > Now I am missing step 3 --> how can plot this matrix by previously assigning > different colours to the numbers? > > Thank you in advance for your help! > > Best, Lisa > > > > > > -- > > M.Sc. Lisa Handke > > Technische Universität Braunschweig > > Institut für Psychologie > > Lehrstuhl für Arbeits-, Organisations- und Sozialpsychologie > > Spielmannstrasse 19, Raum 103 > > D-38106 Braunschweig > > > > Phone: +49 (0)531-391-2539 > > Fax: +49 (0)531-391-8173 > > Mail: <mailto:[hidden email]> [hidden email] > > <http://www.tu-braunschweig.de/psychologie/abt/aos> > www.tu-braunschweig.de/psychologie/abt/aos > > > > > [[alternative HTML version deleted]] > > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > 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. ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
Free forum by Nabble | Edit this page |