[Traminer-users] how to sort a sequence plot (seqIplot) by more than one variable
Joel Schwartz
joel at joelschwartz.com
Mon Jul 16 19:30:18 CEST 2012
Thanks Alexis.
I tried your suggestion and for some reason it's not working, even when I create a sorting variable using a single variable to sort on. Here's what I did:
# Original version, which works fine. See first attached file below, which shows plot is clearly sorted by f09as.
seqIplot(df.seq09, border = NA, withlegend = "right", sortv=df09$f09as)
# Create sorting variable
term.sort = order(df09$f09as)
# Create plot again, using sorting variable. This version of the plot is unsorted. See second attached file.
seqIplot(df.seq09, border = NA, withlegend = "right", sortv=term.sort)
I checked the sorting variable by looking at what it does to the data file with the following command and it looked exactly like it should, so the sorting variable doesn't seem to have a problem:
df09[order(df09$f09as), ]
Any idea what could be going wrong?
Thanks again,
Joel
On Jul 16, 2012, at 12:10 AM, Alexis gabadinho wrote:
> Hi Joel,
>
> Use first the order function to create one single sorting variable, and then pass this variable to the seqIplot function. Here is an example with the biofam data frame where sequences are sorted by gender and birthyr
>
> data(biofam)
> biofam.seq <- seqdef(biofam, 10:25)
> csort <- order(biofam$sex, biofam$birthyr)
> seqIplot(biofam.seq, sortv=csort)
>
> All the best,
> Alexis
>
>
> Le 16. 07. 12 08:12, Joel Schwartz a écrit :
>>
>> I'm a new TraMineR user and just ran into a problem while using the seqIplot function. I'm making a plot of hundreds of sequences. To make it possible to see patterns, I'm trying to sort the sequences by more than one variable. It works as expected when I sort by one variable. But when I try to sort by more than one, I get the exact same result as when I sort by one variable.
>>
>> Here are the two commands I'm using
>>
>> # Sort by one variable
>> seqIplot(df.seq, border=NA, withlegend="right", sortv=df$s09as)
>>
>> # Sort by two variables
>> seqIplot(df.seq, border = NA, withlegend="right", sortv=c(df$s09as, df$f09as))
>>
>> I get the exact same plot either way, and no warnings or errors.
>>
>> Is there a way to sort by more than one variable?
>>
>> Thanks for your help.
>>
>> Best Wishes,
>> Joel Schwartz
>>
>>
>>
>>
>> _______________________________________________
>> 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: <http://lists.r-forge.r-project.org/pipermail/traminer-users/attachments/20120716/d2a3753a/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-2.tiff
Type: image/tiff
Size: 1175522 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/traminer-users/attachments/20120716/d2a3753a/attachment-0002.tiff>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/traminer-users/attachments/20120716/d2a3753a/attachment-0004.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-3.tiff
Type: image/tiff
Size: 1175522 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/traminer-users/attachments/20120716/d2a3753a/attachment-0003.tiff>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/traminer-users/attachments/20120716/d2a3753a/attachment-0005.html>
More information about the Traminer-users
mailing list