# [R] argument is of length zero

Wed May 12 00:00:35 CEST 2010

```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

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 =
names(foo) = c("trialnum","stim","RT","y","x")
foo_trialnums =

# CHECK THAT SUB/STIM COMBINATION IS LEGIT -- at least 90% categorical
if (
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!