[Traminer-users] loop for plotting quality statistics from wcKMedRange

thomas collas thomas.collas at gmail.com
Sat Oct 8 08:09:50 CEST 2016


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 <reyno113 at purdue.edu>:

> 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: <http://lists.r-forge.r-project.org/pipermail/traminer-users/attachments/20161008/79ba2a3c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 168 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/traminer-users/attachments/20161008/79ba2a3c/attachment.png>


More information about the Traminer-users mailing list