Howdy, Stranger!

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

Supported by

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).

    Buy Me A Coffee

  • 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:

    library(mousetrap)
    
    # Time-normalize trajectories (only 11 points)
    KH2017 <- mt_time_normalize(KH2017, nsteps = 11)
    
    # Plot aggregated time-normalized trajectories per condition with points
    mt_plot_aggregate(
     KH2017, use="tn_trajectories",
     color="Condition",
     points = TRUE
    )
    

    @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:

    library(mousetrap)
    library(ggplot2)
    
    # Time-normalize trajectories
    KH2017 <- mt_time_normalize(KH2017)
    
    # Aggregate time-normalized trajectories per condition
    average_trajectories <-  mt_aggregate(
      KH2017, use="tn_trajectories",
      use2_variables="Condition"
    )
    
    # Plot trajectories
    ggplot(average_trajectories, aes(x = xpos, y = ypos, color = Condition, group = Condition)) +
      geom_path() +
      geom_point(data = subset(average_trajectories, steps %in% seq(1, 101, 10)))
    

    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

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games