From reyno113 at purdue.edu Thu Oct 6 21:44:18 2016 From: reyno113 at purdue.edu (Reynolds, Jeremy E) Date: Thu, 6 Oct 2016 19:44:18 +0000 Subject: [Traminer-users] installing seqdist2 on a Windows server Message-ID: <62f9608e92ac48d79e6fa8a815cdc487@wppexc08.purdue.lcl> Dear TraMineR Users, I am having some difficulty installing seqdist2 on a server that I use to run R. Installing seqdist2 on my desktop computer is no problem. I am running R 3.3.1 with R Studio 0.99.903 on a windows machine and the command below works fine. install.packages("seqdist2", repos="http://R-Forge.R-project.org") Today, however, when I tried to install seqdist2 for the copy of R that is on a Windows 2012 R2 Terminal Server, the results suggested that the binary copy of seqdist2 at http://R-Forge.R-project.org is older than the source version (see code below). I find this message surprising because it did not appear when I installed seqdist2 on my desktop. > install.packages("seqdist2", repos="http://R-Forge.R-project.org") Installing package into 'C:/Users/reyno113/Documents/R/win-library/3.1' (as 'lib' is unspecified) There is a binary version available (and will be installed) but the source version is later: binary source seqdist2 0.9 0.9-1 trying URL 'http://R-Forge.R-project.org/bin/windows/contrib/3.1/seqdist2_0.9.zip' Content type 'application/zip' length 168620 bytes (164 KB) opened URL downloaded 164 KB package 'seqdist2' successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\reyno113\AppData\Local\Temp\5\Rtmp8U9d4F\downloaded_packages Eager to have the newer version of seqdist2, I tried to install from the source file (seqdist2_0.9-1.tar.gz). Unfortunately, this failed because the version of R installed on the server is too old (see code below). > install.packages("seqdist2_0.9-1.tar.gz", repos = "http://R-Forge.R-project.org", type="source") Installing package into 'C:/Users/reyno113/Documents/R/win-library/3.1' (as 'lib' is unspecified) Warning in install.packages : package 'seqdist2_0.9-1.tar.gz' is not available (for R version 3.1.3) I have asked my server administrators to update to a newer version of R, but I don't know how long that might take. Is there a way to use seqdist2 with R version 3.1.3? Perhaps using this older version of R is the explanation for both problems I encountered? Any tips would be appreciated. Thanks, Jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: From Matthias.Studer at unige.ch Fri Oct 7 08:16:59 2016 From: Matthias.Studer at unige.ch (Matthias Studer) Date: Fri, 7 Oct 2016 06:16:59 +0000 Subject: [Traminer-users] installing seqdist2 on a Windows server In-Reply-To: <62f9608e92ac48d79e6fa8a815cdc487@wppexc08.purdue.lcl> References: <62f9608e92ac48d79e6fa8a815cdc487@wppexc08.purdue.lcl> Message-ID: <4c262a97beb44b0db80e209f87bdb3b5@wuniex13-5.isis.unige.ch> Dear Jeremy, I tried to trigger a new rebuild of the package on the R-Forge server (no version change. This is the only thing that I can do on our side. Hence, if it doesn't work, you'll have to install the latest version on your server. Best, Matthias De : traminer-users-bounces at lists.r-forge.r-project.org [mailto:traminer-users-bounces at lists.r-forge.r-project.org] De la part de Reynolds, Jeremy E Envoy? : jeudi 6 octobre 2016 21:44 ? : traminer-users at lists.r-forge.r-project.org Objet : [Traminer-users] installing seqdist2 on a Windows server Dear TraMineR Users, I am having some difficulty installing seqdist2 on a server that I use to run R. Installing seqdist2 on my desktop computer is no problem. I am running R 3.3.1 with R Studio 0.99.903 on a windows machine and the command below works fine. install.packages("seqdist2", repos="http://R-Forge.R-project.org") Today, however, when I tried to install seqdist2 for the copy of R that is on a Windows 2012 R2 Terminal Server, the results suggested that the binary copy of seqdist2 at http://R-Forge.R-project.org is older than the source version (see code below). I find this message surprising because it did not appear when I installed seqdist2 on my desktop. > install.packages("seqdist2", repos="http://R-Forge.R-project.org") Installing package into 'C:/Users/reyno113/Documents/R/win-library/3.1' (as 'lib' is unspecified) There is a binary version available (and will be installed) but the source version is later: binary source seqdist2 0.9 0.9-1 trying URL 'http://R-Forge.R-project.org/bin/windows/contrib/3.1/seqdist2_0.9.zip' Content type 'application/zip' length 168620 bytes (164 KB) opened URL downloaded 164 KB package 'seqdist2' successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\reyno113\AppData\Local\Temp\5\Rtmp8U9d4F\downloaded_packages Eager to have the newer version of seqdist2, I tried to install from the source file (seqdist2_0.9-1.tar.gz). Unfortunately, this failed because the version of R installed on the server is too old (see code below). > install.packages("seqdist2_0.9-1.tar.gz", repos = "http://R-Forge.R-project.org", type="source") Installing package into 'C:/Users/reyno113/Documents/R/win-library/3.1' (as 'lib' is unspecified) Warning in install.packages : package 'seqdist2_0.9-1.tar.gz' is not available (for R version 3.1.3) I have asked my server administrators to update to a newer version of R, but I don't know how long that might take. Is there a way to use seqdist2 with R version 3.1.3? Perhaps using this older version of R is the explanation for both problems I encountered? Any tips would be appreciated. Thanks, Jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: From reyno113 at purdue.edu Fri Oct 7 15:21:34 2016 From: reyno113 at purdue.edu (Reynolds, Jeremy E) Date: Fri, 7 Oct 2016 13:21:34 +0000 Subject: [Traminer-users] installing seqdist2 on a Windows server In-Reply-To: <4c262a97beb44b0db80e209f87bdb3b5@wuniex13-5.isis.unige.ch> References: <62f9608e92ac48d79e6fa8a815cdc487@wppexc08.purdue.lcl> <4c262a97beb44b0db80e209f87bdb3b5@wuniex13-5.isis.unige.ch> Message-ID: <60659e34ea7f4d8ab500238c0bf79c4d@wppexc08.purdue.lcl> Thanks, Matthias. I am still having the same problems, but I guess the issue is on my end. Hopefully the server administrators will be able to install the updated version of R soon. Jeremy From: traminer-users-bounces at lists.r-forge.r-project.org [mailto:traminer-users-bounces at lists.r-forge.r-project.org] On Behalf Of Matthias Studer Sent: Friday, October 7, 2016 2:17 AM To: Users questions Subject: Re: [Traminer-users] installing seqdist2 on a Windows server Dear Jeremy, I tried to trigger a new rebuild of the package on the R-Forge server (no version change. This is the only thing that I can do on our side. Hence, if it doesn't work, you'll have to install the latest version on your server. Best, Matthias De : traminer-users-bounces at lists.r-forge.r-project.org [mailto:traminer-users-bounces at lists.r-forge.r-project.org] De la part de Reynolds, Jeremy E Envoy? : jeudi 6 octobre 2016 21:44 ? : traminer-users at lists.r-forge.r-project.org Objet : [Traminer-users] installing seqdist2 on a Windows server Dear TraMineR Users, I am having some difficulty installing seqdist2 on a server that I use to run R. Installing seqdist2 on my desktop computer is no problem. I am running R 3.3.1 with R Studio 0.99.903 on a windows machine and the command below works fine. install.packages("seqdist2", repos="http://R-Forge.R-project.org") Today, however, when I tried to install seqdist2 for the copy of R that is on a Windows 2012 R2 Terminal Server, the results suggested that the binary copy of seqdist2 at http://R-Forge.R-project.org is older than the source version (see code below). I find this message surprising because it did not appear when I installed seqdist2 on my desktop. > install.packages("seqdist2", repos="http://R-Forge.R-project.org") Installing package into 'C:/Users/reyno113/Documents/R/win-library/3.1' (as 'lib' is unspecified) There is a binary version available (and will be installed) but the source version is later: binary source seqdist2 0.9 0.9-1 trying URL 'http://R-Forge.R-project.org/bin/windows/contrib/3.1/seqdist2_0.9.zip' Content type 'application/zip' length 168620 bytes (164 KB) opened URL downloaded 164 KB package 'seqdist2' successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\reyno113\AppData\Local\Temp\5\Rtmp8U9d4F\downloaded_packages Eager to have the newer version of seqdist2, I tried to install from the source file (seqdist2_0.9-1.tar.gz). Unfortunately, this failed because the version of R installed on the server is too old (see code below). > install.packages("seqdist2_0.9-1.tar.gz", repos = "http://R-Forge.R-project.org", type="source") Installing package into 'C:/Users/reyno113/Documents/R/win-library/3.1' (as 'lib' is unspecified) Warning in install.packages : package 'seqdist2_0.9-1.tar.gz' is not available (for R version 3.1.3) I have asked my server administrators to update to a newer version of R, but I don't know how long that might take. Is there a way to use seqdist2 with R version 3.1.3? Perhaps using this older version of R is the explanation for both problems I encountered? Any tips would be appreciated. Thanks, Jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: From reyno113 at purdue.edu Sat Oct 8 04:41:00 2016 From: reyno113 at purdue.edu (Reynolds, Jeremy E) Date: Sat, 8 Oct 2016 02:41:00 +0000 Subject: [Traminer-users] loop for plotting quality statistics from wcKMedRange Message-ID: Dear TraMineR Users, I would like to loop through many sets of clustering results produced with wcKMedRange and produce a plot for each one. Without the loop, the code would look like this: plot(pamomf2i5q.w, stat=c("ASWw","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") plot(pamwardomf2i5q.w, stat=c("ASWw","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") When I try to put this in a loop, I get the error messages below suggesting that R is expecting a y value in the plot command. Is there something wrong with my loop that is causing this problem? Thanks, Jeremy > stats <- c("pamomf2i5q.w", "pamwardomf2i5q.w") > for (i in unique(stats)) { + plot(stats[i], stat=c("ASW","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") + } [data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAKUlEQVR42mNgQAKi65/9Z8AHQApgmKACrAqxKcBpIkHryFJEstsYiAUAKIxac8kmY3AAAAAASUVORK5CYII=] Show Traceback Rerun with Debug Error in plot.window(...) : need finite 'ylim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In plot.window(...) : "stat" is not a graphical parameter 4: In plot.window(...) : "legendpos" is not a graphical parameter 5: In plot.window(...) : "norm" is not a graphical parameter -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 168 bytes Desc: image001.png URL: From thomas.collas at gmail.com Sat Oct 8 08:09:50 2016 From: thomas.collas at gmail.com (thomas collas) Date: Sat, 8 Oct 2016 08:09:50 +0200 Subject: [Traminer-users] loop for plotting quality statistics from wcKMedRange In-Reply-To: References: Message-ID: Dear Jeremy, That should work if you change 3 things : - the first problem is your stats object, which is a character vector, not a list of objects, you can't plot a character string. - the second problem is the "x" in the plot function. If i is a component and not an attribute of stats, you can't index stats with i. - the third smaller problem is that you have to ask R to print two plots. If it is only for visualization, you can use the mfrow argument in the par() function. After having created the two objects you want to plot, this code should work : stats <- list(pamomf2i5q.w, pamwardomf2i5q.w) par(mfrow=c(1,2)) for (i in stats) { plot(i, stat=c("ASW","HC", "R2", "PBC", "HG"), legendpos="topright", norm= "zscore") } Best, thomas 2016-10-08 4:41 GMT+02:00 Reynolds, Jeremy E : > Dear TraMineR Users, > > > > I would like to loop through many sets of clustering results produced with > wcKMedRange and produce a plot for each one. Without the loop, the code > would look like this: > > > > plot(pamomf2i5q.w, stat=c("ASWw","HC", "R2", "PBC", "HG"), > legendpos="topright", norm="zscore") > > plot(pamwardomf2i5q.w, stat=c("ASWw","HC", "R2", "PBC", "HG"), > legendpos="topright", norm="zscore") > > > > When I try to put this in a loop, I get the error messages below > suggesting that R is expecting a y value in the plot command. Is there > something wrong with my loop that is causing this problem? > > > > Thanks, > > > > Jeremy > > > > > > > stats <- c("pamomf2i5q.w", "pamwardomf2i5q.w") > > > for (i in unique(stats)) { > > + plot(stats[i], stat=c("ASW","HC", "R2", "PBC", "HG"), > legendpos="topright", norm="zscore") > > + } > > [image: > data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAKUlEQVR42mNgQAKi65/9Z8AHQApgmKACrAqxKcBpIkHryFJEstsYiAUAKIxac8kmY3AAAAAASUVORK5CYII=] > Show Traceback > > Rerun with Debug > > Error in plot.window(...) : need finite 'ylim' values > > In addition: Warning messages: > > 1: In min(x) : no non-missing arguments to min; returning Inf > > 2: In max(x) : no non-missing arguments to max; returning -Inf > > 3: In plot.window(...) : "stat" is not a graphical parameter > > 4: In plot.window(...) : "legendpos" is not a graphical parameter > > 5: In plot.window(...) : "norm" is not a graphical parameter > > > > _______________________________________________ > Traminer-users mailing list > Traminer-users at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/ > listinfo/traminer-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 168 bytes Desc: not available URL: From reyno113 at purdue.edu Sat Oct 8 14:09:45 2016 From: reyno113 at purdue.edu (Reynolds, Jeremy E) Date: Sat, 8 Oct 2016 12:09:45 +0000 Subject: [Traminer-users] loop for plotting quality statistics from wcKMedRange In-Reply-To: References: , Message-ID: <4F6BED9E-AF40-41C5-9E2C-6426FD3781C2@purdue.edu> Thank you Thomas! It is amazing how many things a novice user can mess up in just a few lines. Loops and the apply functions seem to be a perenniaI source of confusion in R. I was hoping to save the plots in a single file (perhaps PDF?). Do you have any additional tips for that? Thanks Jeremy Sent from my iPhone On Oct 8, 2016, at 2:10 AM, thomas collas > wrote: Dear Jeremy, That should work if you change 3 things : - the first problem is your stats object, which is a character vector, not a list of objects, you can't plot a character string. - the second problem is the "x" in the plot function. If i is a component and not an attribute of stats, you can't index stats with i. - the third smaller problem is that you have to ask R to print two plots. If it is only for visualization, you can use the mfrow argument in the par() function. After having created the two objects you want to plot, this code should work : stats <- list(pamomf2i5q.w, pamwardomf2i5q.w) par(mfrow=c(1,2)) for (i in stats) { plot(i, stat=c("ASW","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") } Best, thomas 2016-10-08 4:41 GMT+02:00 Reynolds, Jeremy E >: Dear TraMineR Users, I would like to loop through many sets of clustering results produced with wcKMedRange and produce a plot for each one. Without the loop, the code would look like this: plot(pamomf2i5q.w, stat=c("ASWw","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") plot(pamwardomf2i5q.w, stat=c("ASWw","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") When I try to put this in a loop, I get the error messages below suggesting that R is expecting a y value in the plot command. Is there something wrong with my loop that is causing this problem? Thanks, Jeremy > stats <- c("pamomf2i5q.w", "pamwardomf2i5q.w") > for (i in unique(stats)) { + plot(stats[i], stat=c("ASW","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") + } Show Traceback Rerun with Debug Error in plot.window(...) : need finite 'ylim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In plot.window(...) : "stat" is not a graphical parameter 4: In plot.window(...) : "legendpos" is not a graphical parameter 5: In plot.window(...) : "norm" is not a graphical parameter _______________________________________________ Traminer-users mailing list Traminer-users at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/traminer-users _______________________________________________ Traminer-users mailing list Traminer-users at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/traminer-users -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 168 bytes Desc: image001.png URL: From thomas.collas at gmail.com Sat Oct 8 14:29:09 2016 From: thomas.collas at gmail.com (thomas collas) Date: Sat, 8 Oct 2016 14:29:09 +0200 Subject: [Traminer-users] loop for plotting quality statistics from wcKMedRange In-Reply-To: <4F6BED9E-AF40-41C5-9E2C-6426FD3781C2@purdue.edu> References: <4F6BED9E-AF40-41C5-9E2C-6426FD3781C2@purdue.edu> Message-ID: Sure, you can use the pdf() function before the par() one. As quartz(), pdf() allows to define the dimensions of the window. Instead of par(), the layout() function is great too to divide the window into several plots. The pdf() file is produced while R meets the dev.off() line after the commands generating the plots, the axes, and so on. pdf(file="working_directory/plots.pdf", height=, etc.) par(mfrow=c(1,2)) for (i in stats) { plot(i, stat=c("ASW","HC", "R2", "PBC", "HG"), legendpos="topright", norm= "zscore") } dev.off() Best, thomas 2016-10-08 14:09 GMT+02:00 Reynolds, Jeremy E : > Thank you Thomas! It is amazing how many things a novice user can mess up > in just a few lines. Loops and the apply functions seem to be a perenniaI > source of confusion in R. > > I was hoping to save the plots in a single file (perhaps PDF?). Do you > have any additional tips for that? > > Thanks > Jeremy > > Sent from my iPhone > > On Oct 8, 2016, at 2:10 AM, thomas collas wrote: > > Dear Jeremy, > That should work if you change 3 things : > - the first problem is your stats object, which is a character vector, not > a list of objects, you can't plot a character string. > - the second problem is the "x" in the plot function. If i is a component > and not an attribute of stats, you can't index stats with i. > - the third smaller problem is that you have to ask R to print two plots. > If it is only for visualization, you can use the mfrow argument in the > par() function. > > After having created the two objects you want to plot, this code should > work : > > stats <- list(pamomf2i5q.w, pamwardomf2i5q.w) > > par(mfrow=c(1,2)) > > for (i in stats) { > > plot(i, stat=c("ASW","HC", "R2", "PBC", "HG"), legendpos="topright", > norm="zscore") > > } > Best, > thomas > > 2016-10-08 4:41 GMT+02:00 Reynolds, Jeremy E : > >> Dear TraMineR Users, >> >> >> >> I would like to loop through many sets of clustering results produced >> with wcKMedRange and produce a plot for each one. Without the loop, the >> code would look like this: >> >> >> >> plot(pamomf2i5q.w, stat=c("ASWw","HC", "R2", "PBC", "HG"), >> legendpos="topright", norm="zscore") >> >> plot(pamwardomf2i5q.w, stat=c("ASWw","HC", "R2", "PBC", "HG"), >> legendpos="topright", norm="zscore") >> >> >> >> When I try to put this in a loop, I get the error messages below >> suggesting that R is expecting a y value in the plot command. Is there >> something wrong with my loop that is causing this problem? >> >> >> >> Thanks, >> >> >> >> Jeremy >> >> >> >> >> >> > stats <- c("pamomf2i5q.w", "pamwardomf2i5q.w") >> >> > for (i in unique(stats)) { >> >> + plot(stats[i], stat=c("ASW","HC", "R2", "PBC", "HG"), >> legendpos="topright", norm="zscore") >> >> + } >> >> Show Traceback >> >> Rerun with Debug >> >> Error in plot.window(...) : need finite 'ylim' values >> >> In addition: Warning messages: >> >> 1: In min(x) : no non-missing arguments to min; returning Inf >> >> 2: In max(x) : no non-missing arguments to max; returning -Inf >> >> 3: In plot.window(...) : "stat" is not a graphical parameter >> >> 4: In plot.window(...) : "legendpos" is not a graphical parameter >> >> 5: In plot.window(...) : "norm" is not a graphical parameter >> >> >> >> _______________________________________________ >> Traminer-users mailing list >> Traminer-users at lists.r-forge.r-project.org >> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo >> /traminer-users >> > > _______________________________________________ > Traminer-users mailing list > Traminer-users at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/ > listinfo/traminer-users > > > _______________________________________________ > Traminer-users mailing list > Traminer-users at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/ > listinfo/traminer-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From reyno113 at purdue.edu Fri Oct 14 23:14:43 2016 From: reyno113 at purdue.edu (Reynolds, Jeremy E) Date: Fri, 14 Oct 2016 21:14:43 +0000 Subject: [Traminer-users] reduce space between subplots in seqdplot Message-ID: <1e2cc3e6391c43a2be14ebacd2868ee8@wppexc08.purdue.lcl> Dear TraMineR Users, I would like to reduce the amount of space between the subplots created with seqdplot and the group option. Does anyone know how to do this? I have provided an example below that makes the plot and then save it as a .png file. The code works, but I would like the space between the title of each graph and the adjacent graph to be smaller. Thanks, Jeremy library(TraMineR) library(WeightedCluster) data(mvad) mvad.alphabet <- c("employment", "FE", "HE", "joblessness", "school", "training") mvad.labels <- c("Employment", "Further Education", "Higher Education", "Joblessness", "School", "Training") mvad.scodes <- c("EM", "FE", "HE", "JL", "SC", "TR") mvadseq <- seqdef(mvad[, 17:86], alphabet = mvad.alphabet, states = mvad.scodes, labels = mvad.labels, weights = mvad$weight, xtstep = 6) #Defining the custom cost matrix subm.custom <- matrix( c(0, 1, 1, 2, 1, 1, 1, 0, 1, 2, 1, 2, 1, 1, 0, 3, 1, 2, 2, 2, 3, 0, 3, 1, 1, 1, 1, 3, 0, 2, 1, 2, 2, 1, 2, 0), nrow = 6, ncol = 6, byrow = TRUE) mvaddist1.0 <- seqdist(mvadseq, method = "OM", indel = 1.0, sm = subm.custom) pamclust1.0 <- wcKMedRange(mvaddist1.0, kvals = 2:10, weights = mvad$weight) #save plot to file png(filename = "test.png", width = 1500, height = 3500, units = "px", pointsize=30) seqdplot(mvadseq, group = pamclust1.0$clustering$cluster4, border = NA, use.layout=TRUE, cols=1, axes="bottom", cex.legend=2,legend.prop=.05) dev.off() Dr. Jeremy Reynolds Professor 309 Stone Hall Department of Sociology 700 W. State Street Purdue University West Lafayette, IN 47907 Phone: (765) 496-3348 https://www.cla.purdue.edu/sociology/directory/index.aspx?p=Jeremy_Reynolds -------------- next part -------------- An HTML attachment was scrubbed... URL: From Matthias.Studer at unige.ch Mon Oct 17 10:00:11 2016 From: Matthias.Studer at unige.ch (Matthias Studer) Date: Mon, 17 Oct 2016 08:00:11 +0000 Subject: [Traminer-users] reduce space between subplots in seqdplot In-Reply-To: <1e2cc3e6391c43a2be14ebacd2868ee8@wppexc08.purdue.lcl> References: <1e2cc3e6391c43a2be14ebacd2868ee8@wppexc08.purdue.lcl> Message-ID: <4747022a721a4170abe5927955975467@wuniex13-5.isis.unige.ch> Dear Jeremy, You can do it by re-specifying the margins of your plot with the par(mar=c(...)) command. According to the par help page, the mar argument sets the margins using a "numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margins to be specified on the four sides of the plot. The default is c(5, 4, 4, 2) + 0.1" You typically want to reduce the top and bottom margins. You will probably need several tries to get the right settings. You can find more information on margin on the "par" help page. Hope this helps. Matthias De : traminer-users-bounces at lists.r-forge.r-project.org [mailto:traminer-users-bounces at lists.r-forge.r-project.org] De la part de Reynolds, Jeremy E Envoy? : vendredi 14 octobre 2016 23:15 ? : Users questions Objet : [Traminer-users] reduce space between subplots in seqdplot Dear TraMineR Users, I would like to reduce the amount of space between the subplots created with seqdplot and the group option. Does anyone know how to do this? I have provided an example below that makes the plot and then save it as a .png file. The code works, but I would like the space between the title of each graph and the adjacent graph to be smaller. Thanks, Jeremy library(TraMineR) library(WeightedCluster) data(mvad) mvad.alphabet <- c("employment", "FE", "HE", "joblessness", "school", "training") mvad.labels <- c("Employment", "Further Education", "Higher Education", "Joblessness", "School", "Training") mvad.scodes <- c("EM", "FE", "HE", "JL", "SC", "TR") mvadseq <- seqdef(mvad[, 17:86], alphabet = mvad.alphabet, states = mvad.scodes, labels = mvad.labels, weights = mvad$weight, xtstep = 6) #Defining the custom cost matrix subm.custom <- matrix( c(0, 1, 1, 2, 1, 1, 1, 0, 1, 2, 1, 2, 1, 1, 0, 3, 1, 2, 2, 2, 3, 0, 3, 1, 1, 1, 1, 3, 0, 2, 1, 2, 2, 1, 2, 0), nrow = 6, ncol = 6, byrow = TRUE) mvaddist1.0 <- seqdist(mvadseq, method = "OM", indel = 1.0, sm = subm.custom) pamclust1.0 <- wcKMedRange(mvaddist1.0, kvals = 2:10, weights = mvad$weight) #save plot to file png(filename = "test.png", width = 1500, height = 3500, units = "px", pointsize=30) seqdplot(mvadseq, group = pamclust1.0$clustering$cluster4, border = NA, use.layout=TRUE, cols=1, axes="bottom", cex.legend=2,legend.prop=.05) dev.off() Dr. Jeremy Reynolds Professor 309 Stone Hall Department of Sociology 700 W. State Street Purdue University West Lafayette, IN 47907 Phone: (765) 496-3348 https://www.cla.purdue.edu/sociology/directory/index.aspx?p=Jeremy_Reynolds -------------- next part -------------- An HTML attachment was scrubbed... URL: From reyno113 at purdue.edu Mon Oct 17 14:33:42 2016 From: reyno113 at purdue.edu (Reynolds, Jeremy E) Date: Mon, 17 Oct 2016 12:33:42 +0000 Subject: [Traminer-users] reduce space between subplots in seqdplot In-Reply-To: <4747022a721a4170abe5927955975467@wuniex13-5.isis.unige.ch> References: <1e2cc3e6391c43a2be14ebacd2868ee8@wppexc08.purdue.lcl> <4747022a721a4170abe5927955975467@wuniex13-5.isis.unige.ch> Message-ID: Thank you so much! Can you also tell me how to change the titles of the subplots and the titles of the Y axes? The Y-axes could all be the same (e.g., "Proportion" instead of the default "Freq.(weighted n = )", but I would probably want a unique title for each subgraph to replace the medoid ID numbers. Jeremy From: traminer-users-bounces at lists.r-forge.r-project.org [mailto:traminer-users-bounces at lists.r-forge.r-project.org] On Behalf Of Matthias Studer Sent: Monday, October 17, 2016 4:00 AM To: Users questions Subject: Re: [Traminer-users] reduce space between subplots in seqdplot Dear Jeremy, You can do it by re-specifying the margins of your plot with the par(mar=c(...)) command. According to the par help page, the mar argument sets the margins using a "numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margins to be specified on the four sides of the plot. The default is c(5, 4, 4, 2) + 0.1" You typically want to reduce the top and bottom margins. You will probably need several tries to get the right settings. You can find more information on margin on the "par" help page. Hope this helps. Matthias De : traminer-users-bounces at lists.r-forge.r-project.org [mailto:traminer-users-bounces at lists.r-forge.r-project.org] De la part de Reynolds, Jeremy E Envoy? : vendredi 14 octobre 2016 23:15 ? : Users questions > Objet : [Traminer-users] reduce space between subplots in seqdplot Dear TraMineR Users, I would like to reduce the amount of space between the subplots created with seqdplot and the group option. Does anyone know how to do this? I have provided an example below that makes the plot and then save it as a .png file. The code works, but I would like the space between the title of each graph and the adjacent graph to be smaller. Thanks, Jeremy library(TraMineR) library(WeightedCluster) data(mvad) mvad.alphabet <- c("employment", "FE", "HE", "joblessness", "school", "training") mvad.labels <- c("Employment", "Further Education", "Higher Education", "Joblessness", "School", "Training") mvad.scodes <- c("EM", "FE", "HE", "JL", "SC", "TR") mvadseq <- seqdef(mvad[, 17:86], alphabet = mvad.alphabet, states = mvad.scodes, labels = mvad.labels, weights = mvad$weight, xtstep = 6) #Defining the custom cost matrix subm.custom <- matrix( c(0, 1, 1, 2, 1, 1, 1, 0, 1, 2, 1, 2, 1, 1, 0, 3, 1, 2, 2, 2, 3, 0, 3, 1, 1, 1, 1, 3, 0, 2, 1, 2, 2, 1, 2, 0), nrow = 6, ncol = 6, byrow = TRUE) mvaddist1.0 <- seqdist(mvadseq, method = "OM", indel = 1.0, sm = subm.custom) pamclust1.0 <- wcKMedRange(mvaddist1.0, kvals = 2:10, weights = mvad$weight) #save plot to file png(filename = "test.png", width = 1500, height = 3500, units = "px", pointsize=30) seqdplot(mvadseq, group = pamclust1.0$clustering$cluster4, border = NA, use.layout=TRUE, cols=1, axes="bottom", cex.legend=2,legend.prop=.05) dev.off() Dr. Jeremy Reynolds Professor 309 Stone Hall Department of Sociology 700 W. State Street Purdue University West Lafayette, IN 47907 Phone: (765) 496-3348 https://www.cla.purdue.edu/sociology/directory/index.aspx?p=Jeremy_Reynolds -------------- next part -------------- An HTML attachment was scrubbed... URL: From reyno113 at purdue.edu Mon Oct 10 20:27:07 2016 From: reyno113 at purdue.edu (Reynolds, Jeremy E) Date: Mon, 10 Oct 2016 18:27:07 +0000 Subject: [Traminer-users] loop for plotting quality statistics from wcKMedRange In-Reply-To: References: <4F6BED9E-AF40-41C5-9E2C-6426FD3781C2@purdue.edu> Message-ID: <90cdab196b4b4b90a1bb9d56d084e18f@wppexc08.purdue.lcl> Hi Thomas, Thank you again for your help. It appears, however, that I am still stuck. When I got back to my computer to try your suggested solutions, I did not get the expected results. To help with the diagnosis of the problem, I have written an example below that can be run to reproduce the problems. My attempts at using loops are at the end of the code . Jeremy library(TraMineR) library(WeightedCluster) data(mvad) mvad.alphabet <- c("employment", "FE", "HE", "joblessness", "school", "training") mvad.labels <- c("Employment", "Further Education", "Higher Education", "Joblessness", "School", "Training") mvad.scodes <- c("EM", "FE", "HE", "JL", "SC", "TR") mvadseq <- seqdef(mvad[, 17:86], alphabet = mvad.alphabet, states = mvad.scodes, labels = mvad.labels, weights = mvad$weight, xtstep = 6) #Defining the custom cost matrix subm.custom <- matrix( c(0, 1, 1, 2, 1, 1, 1, 0, 1, 2, 1, 2, 1, 1, 0, 3, 1, 2, 2, 2, 3, 0, 3, 1, 1, 1, 1, 3, 0, 2, 1, 2, 2, 1, 2, 0), nrow = 6, ncol = 6, byrow = TRUE) #Compute the OM dissimilarities mvaddist1.0 <- seqdist(mvadseq, method = "OM", indel = 1.0, sm = subm.custom) mvaddist1.5 <- seqdist(mvadseq, method = "OM", indel = 1.5, sm = subm.custom) mvaddist2.0 <- seqdist(mvadseq, method = "OM", indel = 2.0, sm = subm.custom) #obtain a series of cluster solutions pamclust1.0 <- wcKMedRange(mvaddist1.0, kvals = 2:10, weights = mvad$weight) pamclust1.5 <- wcKMedRange(mvaddist1.5, kvals = 2:10, weights = mvad$weight) pamclust2.0 <- wcKMedRange(mvaddist2.0, kvals = 2:10, weights = mvad$weight) #print statistics for the various solutions round(pamclust1.0$stats[,c("ASW", "HC", "R2", "PBC", "HG")],3) round(pamclust1.5$stats[,c("ASW", "HC", "R2", "PBC", "HG")],3) round(pamclust2.0$stats[,c("ASW", "HC", "R2", "PBC", "HG")],3) #plot the statistics for the various solutions plot(pamclust1.0, stat=c("ASW","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") title(main="pamclust1.0") plot(pamclust1.5, stat=c("ASW","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") title(main="pamclust1.5") plot(pamclust2.0, stat=c("ASW","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") title(main="pamclust2.0") ############ #Many of the steps above involve a good bit of repetition. #I would rather do some of them with a loop, but all of my attempts below fail ############ #print statistics using a loop - attempt 1 indels1 <- list(pamclust1.0$stats, pamclust1.5$stats, pamclust2.0$stats) for (i in indels1){ round(i[,c("ASW", "HC", "R2", "PBC", "HG")],3) } #print statistics using a loop - attempt 2 indels2 <- list(1.0, 1.5, 2.0) for (i in indels2){ round(get(paste0("pamclust",i,"$stats"))[,c("ASW", "HC", "R2", "PBC", "HG")],3) } #plot statistics using a loop - attempt 1 indels3 <- list(pamclust1.0, pamclust1.5, pamclust2.0) for (i in indels3){ plot(i, stat=c("ASW","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") title(main=i) } From: traminer-users-bounces at lists.r-forge.r-project.org [mailto:traminer-users-bounces at lists.r-forge.r-project.org] On Behalf Of thomas collas Sent: Saturday, October 8, 2016 8:29 AM To: Users questions Subject: Re: [Traminer-users] loop for plotting quality statistics from wcKMedRange Sure, you can use the pdf() function before the par() one. As quartz(), pdf() allows to define the dimensions of the window. Instead of par(), the layout() function is great too to divide the window into several plots. The pdf() file is produced while R meets the dev.off() line after the commands generating the plots, the axes, and so on. pdf(file="working_directory/plots.pdf", height=, etc.) par(mfrow=c(1,2)) for (i in stats) { plot(i, stat=c("ASW","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") } dev.off() Best, thomas 2016-10-08 14:09 GMT+02:00 Reynolds, Jeremy E >: Thank you Thomas! It is amazing how many things a novice user can mess up in just a few lines. Loops and the apply functions seem to be a perenniaI source of confusion in R. I was hoping to save the plots in a single file (perhaps PDF?). Do you have any additional tips for that? Thanks Jeremy Sent from my iPhone On Oct 8, 2016, at 2:10 AM, thomas collas > wrote: Dear Jeremy, That should work if you change 3 things : - the first problem is your stats object, which is a character vector, not a list of objects, you can't plot a character string. - the second problem is the "x" in the plot function. If i is a component and not an attribute of stats, you can't index stats with i. - the third smaller problem is that you have to ask R to print two plots. If it is only for visualization, you can use the mfrow argument in the par() function. After having created the two objects you want to plot, this code should work : stats <- list(pamomf2i5q.w, pamwardomf2i5q.w) par(mfrow=c(1,2)) for (i in stats) { plot(i, stat=c("ASW","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") } Best, thomas 2016-10-08 4:41 GMT+02:00 Reynolds, Jeremy E >: Dear TraMineR Users, I would like to loop through many sets of clustering results produced with wcKMedRange and produce a plot for each one. Without the loop, the code would look like this: plot(pamomf2i5q.w, stat=c("ASWw","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") plot(pamwardomf2i5q.w, stat=c("ASWw","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") When I try to put this in a loop, I get the error messages below suggesting that R is expecting a y value in the plot command. Is there something wrong with my loop that is causing this problem? Thanks, Jeremy > stats <- c("pamomf2i5q.w", "pamwardomf2i5q.w") > for (i in unique(stats)) { + plot(stats[i], stat=c("ASW","HC", "R2", "PBC", "HG"), legendpos="topright", norm="zscore") + } Show Traceback Rerun with Debug Error in plot.window(...) : need finite 'ylim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In plot.window(...) : "stat" is not a graphical parameter 4: In plot.window(...) : "legendpos" is not a graphical parameter 5: In plot.window(...) : "norm" is not a graphical parameter _______________________________________________ Traminer-users mailing list Traminer-users at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/traminer-users _______________________________________________ Traminer-users mailing list Traminer-users at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/traminer-users _______________________________________________ Traminer-users mailing list Traminer-users at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/traminer-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomas.collas at gmail.com Wed Oct 19 10:07:02 2016 From: thomas.collas at gmail.com (thomas collas) Date: Wed, 19 Oct 2016 10:07:02 +0200 Subject: [Traminer-users] loop for plotting quality statistics from wcKMedRange In-Reply-To: <90cdab196b4b4b90a1bb9d56d084e18f@wppexc08.purdue.lcl> References: <4F6BED9E-AF40-41C5-9E2C-6426FD3781C2@purdue.edu> <90cdab196b4b4b90a1bb9d56d084e18f@wppexc08.purdue.lcl> Message-ID: Hi Jeremy, I am sorry to read that you are still stuck and I am sorry to answer so late but I have just received your message (probably because of its size). Loops can be tricky. If you want to print in the first two loops, you should ask R to do so with the print() function. If you want to handle the results, it can be more convenient to create a list to which you add a component at each iteration. In the second loop, you should build a character vector instead of a list of numbers and you can put the "$stats" part after the bracket, since you ask R to get an object which is within another object, the problem comes from the "$" which is an operator, not a part of the object name. Something like that should work : indels2 <- c("1.0", "1.5", "2.0") for (i in indels2){ print(round(get(paste0("pamclust",i))$stats[,c("ASW", "HC", "R2", "PBC", "HG")],3)) } Regarding the third loop, there are two different problems. First, you do not ask R to print several plots, with the layout() function, or the mfrow argument in the par() function or simply by saving a new pdf or jpg file at each iteration. Second, you ask R to name each plot by a matrix, what it does by converting it into a character string. You can create a character vector to index the indels3 list and to name each plot. But be sure first that the objects in your list are named, which is not the case here. Hope that still helps. best, thomas -------------- next part -------------- An HTML attachment was scrubbed... URL: From gernig at bigsss-bremen.de Wed Oct 19 10:22:45 2016 From: gernig at bigsss-bremen.de (=?UTF-8?Q?Bj=c3=b6rn_Gernig?=) Date: Wed, 19 Oct 2016 10:22:45 +0200 Subject: [Traminer-users] sorting variable label in indexplot on y-axis In-Reply-To: References: Message-ID: Dear all, when I plot a sequence index plot and I group and sort the sequences, I want to have a tick label on the y-axis to see where the next set of sequences sorted by the sorting variable begins. Example: library(TraMineR) ## biofam data set data(biofam) biofam.lab <- c("Parent", "Left", "Married", "Left+Marr", "Child", "Left+Child", "Left+Marr+Child", "Divorced") biofam.seq <- seqdef(biofam, 10:25, labels=biofam.lab) ## producing the plot, grouped by gender, sorted by spoken language (german, french, italian, NA) seqIplot(biofam.seq, group = biofam$sex, sortv = biofam$plingu02, border = NA) What I need now are four labels on the y-axis, indicating where in the two plots the sequences of German, Italian, French and NA are. I tried the ylab and and the ytlab arguments already without success. Thanks for any hints, Bj?rn Bj?rn Gernig Ph.D. Fellow BIGSSS Bremen International Graduate School of Social Sciences | University of Bremen UNICOM-Building | Mary-Somerville-Str. 9 | 28359 Bremen | Germany Tel.: +49(0) 421 218-66383 | Fax: +49(0) 421 218-66353 Room: 73320 E-mail: gernig at bigsss-bremen.de