Dear R gurus, We are working on a problem in R - the following script is getting a subset of values from a table that is read in and calculating the average of these values in the subset defined. the table looks like this: subject stim trial xmax ymax xmin ymin flag 1 4 dur1 1 -13 133 -403 547 true 2 4 dur1 2 15 450 -466 631 true 3 4 dur1 3 -8 179 -543 687 true 4 4 dur1 4 -6 129 -427 603 false ...... the script is: traj_lengths <- NULL # flag files dur_flags = data.frame(read.table("flagfile_dur")) spec_flags = data.frame(read.table("flagfile_spec")) for ( sub in c(4, 5, 7, 8, 9, 11, 12, 13, 14, 15 ,16 ,17, 19, 20, 81) ) { for ( stimnum in c(1, 2, 3, 4, 5, 6, 7) ) { for ( continuum in c("_dur","_spec")) { foo data.frame(read.table(paste("MT_sub",as.character(sub),"_dur",as.character(stimnum),"_time",sep=""))) names(foo) = c("trialnum","stim","RT","y","x") foo_trialnums data.frame(read.table(paste("MT_sub",as.character(sub),"_dur",as.character(stimnum),"_trialnums",sep=""))) # CHECK THAT SUB/STIM COMBINATION IS LEGIT -- at least 90% categorical if ( as.character(as.vector(subset(data.frame(read.table(paste("flagfile_",substr(continuum,2,nchar(continuum)),sep=""))), V1==sub & V2==stimnum)$V3)[1] == "true") ) { normalized_traj_y <- NULL normalized_traj_x <- NULL for ( copynum in c(1,2,3,4,5,6,7,8,9,10) ) { if ( as.vector(subset(bigframe, subject==sub & stim==paste(substr(continuum,2,nchar(continuum)),as.character(stimnum),sep="") & trial==copynum)$flag) == "true") { # INTERPOLATE TO MEAN LENGTH = 67 new_y <- as.integer( spline(subset(foo, trialnum =foo_trialnums[copynum,1])$y, n=67)$y ) new_x <- as.integer( spline(subset(foo, trialnum =foo_trialnums[copynum,1])$x, n=67)$y ) normalized_traj_y <- cbind(normalized_traj_y, new_y) normalized_traj_x <- cbind(normalized_traj_x, new_x) } } } It finds an error in: Error in if (as.vector(subset(bigframe, subject == sub & stim =paste(substr(continuum, : argument is of length zero -- We were wondering what is the reason for the error above.. Thank you in advance for any pointers! cobbler squad -- View this message in context: http://r.789695.n4.nabble.com/argument-is-of-length-zero-tp2193605p2193605.html Sent from the R help mailing list archive at Nabble.com.