quantile points on mt_plot
Hello,
I am currently drawing some trajectory plots with mt_plot_aggregate like this:
Traj <- mt_plot_aggregate(data = mt_data, use="tn_trajectories", color="condition", subject_id="subjID", size=1.0) + scale_color_manual(values=c("#00BFC4", "#F8766D", "grey"), labels = c("Phonological", "Semantic", "Unrelated")) + xlim(-1000, 300) + ylim(-100, 1100) + geom_point()
However, I don't want to have all the 'points' on my trajectory but only 10th, 20th,...100th points. I wonder if you know how to do this with MT data?
Wenting
Comments
Hi Wenting,
I don't know Mousetrap, but if mt_data is just a data frame, you can make a copy of that data frame where you remove all rows except the ones that you keep. If you want to keep every tenth trial, this procedure could work:
1) Copy mt_data
2) Get the indices from the mt_data, run the modulo operator on it, and compare which values are equal to 0. This will give you a list with indices corresponding to the rows you want to keep
3) Select only those rows whose index is in the list that you generated in (2).
Does that make sense?
Eduard
ps. maybe mt_plot_aggregate has a filter function for that purpose, in case you can probably open the documentation of it (?mt_plot_aggregate).
Hi Wenting,
thanks, @eduard, for comment. The documentation of mt_plot_aggregate and examples can also be found online at: http://pascalkieslich.github.io/mousetrap/reference/mt_plot.html
Eduard's general approach would work.
In terms if mousetrap: One approach would be to specify that you only want 11 points per trajectory in mt_time_normalize and then print them. Using the standard data in mousetrap as an example:
@Wenting: However, this means that the line is also only based on the 11 points per trajectory - not sure if this is what you desired.
If you want to plot the trajectory lines based on the standard 101 points per trajectory but only include points for every tenth position, you could use mt_aggregate (http://pascalkieslich.github.io/mousetrap/reference/mt_aggregate.html) to create a dataset that contains the aggreate time-normalized trajectories. These you can plot using ggplot2 (and then you only plot a subset of points). For the standard example above it could work like this:
Hope this helps.
Best,
Pascal
Thank you both for the prompt reply!
I tried Pascal's second suggestion and it works really well. Thank you so much!
Wenting