Howdy, Stranger!

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

Supported by

Save dataframe as a ".mt" file

I collected mt data using MouseTracker and mistakenly coded two participants with the same name.

I used the read_mt function in moustrap to change the subjID of one participant, but I couldn't save that dataframe as a ".mt" file after I made changes, as there is no write_mt function.

I also tried to create a ".mt" file using the write.table function, but it doesn't work.

Alternatively, I could read_bulk all the raw ".mt" files, but two participants have the same subjID and stimuli, so I don't know how to change one of their subjIDs properly.

Could somebody please help me to resolve this issue?

Comments

  • Hi there,

    the mousetrap R package does not provide a function for exporting .mt files.

    However, it is possible to import several .mt files, change the subjID and then perform analyses using mousetrap. The code could look something like this (see also http://pascalkieslich.github.io/mousetrap/reference/read_mt.html):

    Code to import data into mousetrap:

    # Use read_bulk to read all raw data files ending with ".mt" that are
    # stored in the folder "raw_data" (in the current working directory)
    library(readbulk)
    mt_data_raw <- read_bulk("raw_data", fun=read_mt, extension=".mt")
    
    

    The read_bulk function automatically creates a variable called File that contains the original file name (see http://pascalkieslich.github.io/readbulk/reference/read_bulk.html#value). This can be used to fix the incorrect subjID:

    # Fix incorrect subjID depending on file name
    mt_data_raw$subjID <- ifelse(
      mt_data_raw$File == "FILE_NAME_WITH_INCORRECT_SUBJID.mt",
      NEW_CORRECT_SUBJID,
      mt_data_raw$subjID
    )
    
    # Import the data into mousetrap
    mt_data <- mt_import_wide(mt_data_raw)
    

    Hope this helps.

    Best,

    Pascal

Sign In or Register to comment.