Arithmetic Test R Code (part 2)

new.condition
function (conditions.so.far = newmath$condition)
{# get new condition name
#
#             conditions.so.far        vector of conditions so far
#
cat(“current time”,as.character(Sys.time()),”\n”)
t=as.character(tail(conditions.so.far,1)) #malfunctions without as.character
cat(“most recent condition”,t,”\nthis condition”)
condition=scan(nlines=1,what=”character”,quiet=TRUE, sep=”!”)
condition
}

> newmath2.problems
problem answer
[1,] “2*7″   “4”
[2,] “1*7″   “7”
[3,] “4+4″   “8”
[4,] “8+5″   “3”
[5,] “11-2″  “9”
[6,] “4+6″   “0”
[7,] “0*8″   “0”
[8,] “0+4″   “4”
[9,] “9*3″   “7”
[10,] “16-9″  “7”
[11,] “6*8″   “8”
[12,] “7*6″   “2”
[13,] “0+0″   “0”
[14,] “10-9″  “1”
[15,] “1*1″   “1”
[16,] “8*8″   “4”
[17,] “14-7″  “7”
[18,] “5+5″   “0”
[19,] “7-3″   “4”
[20,] “3+5″   “8”
[21,] “0+7″   “7”
[22,] “4-4″   “0”
[23,] “1+8″   “9”
[24,] “4*1″   “4”
[25,] “3*1″   “3”
[26,] “3-2″   “1”
[27,] “7*9″   “3”
[28,] “0+8″   “8”
[29,] “1*2″   “2”
[30,] “9*1″   “9”
[31,] “0*0″   “0”
[32,] “7+1″   “8”
[33,] “2-2″   “0”
[34,] “4+5″   “9”
[35,] “11-4″  “7”
[36,] “4+3″   “7”
[37,] “1*0″   “0”
[38,] “1*4″   “4”
[39,] “12-8″  “4”
[40,] “7*1″   “7”
[41,] “2-1″   “1”
[42,] “4*6″   “4”
[43,] “9-6″   “3”
[44,] “12-3″  “9”
[45,] “4+9″   “3”
[46,] “9+4″   “3”
[47,] “9*7″   “3”
[48,] “15-7″  “8”
[49,] “3*3″   “9”
[50,] “8-0″   “8”
[51,] “8*9″   “2”
[52,] “11-8″  “3”
[53,] “2*2″   “4”
[54,] “10-2″  “8”
[55,] “9+8″   “7”
[56,] “8-4″   “4”
[57,] “2+1″   “3”
[58,] “8+3″   “1”
[59,] “7-6″   “1”
[60,] “3-3″   “0”
[61,] “9*9″   “1”
[62,] “8+1″   “9”
[63,] “6*4″   “4”
[64,] “9+9″   “8”
[65,] “4*2″   “8”
[66,] “6-5″   “1”
[67,] “7+5″   “2”
[68,] “9*0″   “0”
[69,] “3*7″   “1”
[70,] “8*1″   “8”
[71,] “2+8″   “0”
[72,] “0+2″   “2”
[73,] “8+0″   “8”
[74,] “5-4″   “1”
[75,] “6-3″   “3”
[76,] “2*0″   “0”
[77,] “15-6″  “9”
[78,] “1*9″   “9”
[79,] “7-0″   “7”
[80,] “12-9″  “3”
[81,] “9+3″   “2”
[82,] “4+7″   “1”
[83,] “1+7″   “8”
[84,] “6-4″   “2”
[85,] “6+7″   “3”
[86,] “0+3″   “3”
[87,] “6+3″   “9”
[88,] “13-5″  “8”
[89,] “6+1″   “7”
[90,] “16-8″  “8”
[91,] “6+5″   “1”
[92,] “8*6″   “8”
[93,] “4*0″   “0”
[94,] “5+4″   “9”
[95,] “6+4″   “0”
[96,] “3*9″   “7”
[97,] “4+8″   “2”
[98,] “5-3″   “2”
[99,] “7+0″   “7”
[100,] “15-8″  “7”
[101,] “7*3″   “1”
[102,] “3+7″   “0”
[103,] “6+2″   “8”
[104,] “4-3″   “1”
[105,] “11-3″  “8”
[106,] “9+2″   “1”
[107,] “5-5″   “0”
[108,] “7+6″   “3”
[109,] “9+1″   “0”
[110,] “1*3″   “3”
[111,] “1+2″   “3”
[112,] “2+0″   “2”
[113,] “6-2″   “4”
[114,] “13-9″  “4”
[115,] “2*1″   “2”
[116,] “9+0″   “9”
[117,] “9-1″   “8”
[118,] “3-0″   “3”
[119,] “12-4″  “8”
[120,] “2+9″   “1”
[121,] “10-6″  “4”
[122,] “1+0″   “1”
[123,] “4-0″   “4”
[124,] “0*2″   “0”
[125,] “9*2″   “8”
[126,] “14-5″  “9”
[127,] “5-1″   “4”
[128,] “9-5″   “4”
[129,] “3+0″   “3”
[130,] “17-8″  “9”
[131,] “2+7″   “9”
[132,] “5+6″   “1”
[133,] “8-1″   “7”
[134,] “7-5″   “2”
[135,] “3+6″   “9”
[136,] “6*0″   “0”
[137,] “0*4″   “0”
[138,] “1*8″   “8”
[139,] “7-4″   “3”
[140,] “7+2″   “9”
[141,] “6-6″   “0”
[142,] “9-9″   “0”
[143,] “10-7″  “3”
[144,] “3+1″   “4”
[145,] “2+5″   “7”
[146,] “5+9″   “4”
[147,] “5+3″   “8”
[148,] “8+6″   “4”
[149,] “0*5″   “0”
[150,] “0+9″   “9”
[151,] “1-1″   “0”
[152,] “3-1″   “2”
[153,] “7*2″   “4”
[154,] “7+4″   “1”
[155,] “7+3″   “0”
[156,] “1+1″   “2”
[157,] “6+6″   “2”
[158,] “9-7″   “2”
[159,] “9-8″   “1”
[160,] “9*8″   “2”
[161,] “2*4″   “8”
[162,] “8-5″   “3”
[163,] “14-6″  “8”
[164,] “9-2″   “7”
[165,] “7*4″   “8”
[166,] “6+8″   “4”
[167,] “16-7″  “9”
[168,] “4*3″   “2”
[169,] “8+4″   “2”
[170,] “8+2″   “0”
[171,] “0*9″   “0”
[172,] “6*2″   “2”
[173,] “10-1″  “9”
[174,] “4-2″   “2”
[175,] “3*8″   “4”
[176,] “4-1″   “3”
[177,] “7-7″   “0”
[178,] “9-0″   “9”
[179,] “2*6″   “2”
[180,] “12-5″  “7”
[181,] “0-0″   “0”
[182,] “0*7″   “0”
[183,] “2+6″   “8”
[184,] “0*6″   “0”
[185,] “11-7″  “4”
[186,] “0*3″   “0”
[187,] “18-9″  “9”
[188,] “5+2″   “7”
[189,] “4+0″   “4”
[190,] “8*4″   “2”
[191,] “8*3″   “4”
[192,] “8-8″   “0”
[193,] “0*1″   “0”
[194,] “7+7″   “4”
[195,] “2+2″   “4”
[196,] “13-6″  “7”
[197,] “8*0″   “0”
[198,] “5*0″   “0”
[199,] “8+9″   “7”
[200,] “3+8″   “1”
[201,] “1+3″   “4”
[202,] “2*9″   “8”
[203,] “5-2″   “3”
[204,] “10-3″  “7”
[205,] “4*7″   “8”
[206,] “8-6″   “2”
[207,] “11-9″  “2”
[208,] “1-0″   “1”
[209,] “9+5″   “4”
[210,] “6*7″   “2”
[211,] “3*0″   “0”
[212,] “10-8″  “2”
[213,] “3*4″   “2”
[214,] “1+6″   “7”
[215,] “13-4″  “9”
[216,] “3+9″   “2”
[217,] “5+8″   “3”
[218,] “17-9″  “8”
[219,] “0+1″   “1”
[220,] “8-7″   “1”
[221,] “7*0″   “0”
[222,] “5+7″   “2”
[223,] “2-0″   “2”
[224,] “4*8″   “2”
[225,] “3+4″   “7”
[226,] “1+9″   “0”

> newmath2.trial
function (trial = 1, total.trials = 5, problem=newmath2.problems[1,],condition= “testing”, wait.range=c(1500,2500), num.possible=9, note = “”)
{#give one trial. returns list with components wait, answer.msec, etc.
#(“okay” or “aborted”) and results.
#
#              trial             trial number
#              total.trials      trials per session
#              problem           problem, answer (characters)
#              condition
#              wait.range        range of wait times (msec)
#              num.possible      number of possible wait times
#              note
#
tn=paste(“trial”,trial,”of”,total.trials)
msg=press.space.to.start(below=tn, col = “brown”)
if(msg==”end session”) return(“end session”)
wait.msec=newmath2.foreperiod(wait.range=wait.range, num.possible = num.possible)
t=newmath2.problem(problem=problem)
newmath2.feedback(problem=problem[1],answer.msec=t$answer.msec,correct=t$correct,status=t$status)
list(wait.msec=wait.msec, answer.msec=t$answer.msec,actual.answer=t$actual.answer, correct=t$correct,include=t$include,status=t$status)
}

3 Replies to “Arithmetic Test R Code (part 2)”

  1. Seth,

    Why do you have these 226 hardcoded arithmetic problems and answers? Is there something special about how you’ve selected these problems? I know you did not want answers to be 5 or 6, but are there other criteria?

    Regards,
    Brian

  2. Brian, the main constraint is that each answer be equally likely. (Except that no answer is repeated — e.g., if the answer on trial 5 was 7, the answer on trial 6 will not be 7).

Comments are closed.