Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Clustering the trajectories

Hello everybody,

I am trying to learn the new features in mousetrap (mt_cluster). My goal is to see if people who score high on a certain questionnaire have more trajecotories of cluster 1, while those who score low have more trajectories of cluster 2. My question is the following: how can I "mark" each trajectory (each trial), after clustering, as belonging to cluster 1,2 et cetera? So I can then calculate frequencies of trajectories per person. (i.e., subj. A has 5 trials of cluster 1, 6 trials of cluster B, and so on.)

thank you!


  • Hi!

    let's start with an example using the example dataset from mousetrap:

    mt_example <- mt_spatialize(mt_example)
    mt_example <- mt_cluster(mt_example)

    By default, mt_cluster stores the cluster of each trial in a new data.frame called "clustering" within mt_example. If you would like to merge it with the trial data, you could simply create a new data.frame that merges them:

    results <- merge(mt_example$data, mt_example$clustering, by="mt_id")

    Alternatively, you could directly specify that mt_cluster should store the data within mt_example$data via the save_as argument:

    mt_example <- mt_cluster(mt_example, save_as="data")

    See also the online documentation of mt_cluster for additional information.

    Hope this helps!



Sign In or Register to comment.