Randomizing Experimental Material

Sometimes we need to randomize our experimental material for every speaker and repetition. To this purpose, I wrote a quick script in R,  which you can modify to fit your own purposes. The script saves the experimental material of each speaker in a different file in the path you should define at the top of the code.

setwd("/Users/")   # Export Path
a <- c(
"distractor1",
"distractor2",
"distractor3",
"distractor4",
"distractor5",
"distractor6",
"Phrase1",
"Phrase2",
"Phrase3",
"Phrase4",
"Phrase5",
"Phrase6",
"Phrase7",
"Phrase8",
"Phrase9",
"Phrase10",
)
for (num in 1:10) # Number of Speakers.
{
  sink(paste("SPEAKER ",num,".txt", sep=""))
  cat(paste("SPEAKER", num),sep="\n")
for(i in 1:6) # Number of Repetitions per Speaker. 
{
  b <- sample(a)
  cat(paste("Repedition ",i),sep="\n")
  cat(b,sep="\n")
}
sink()
}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s