There are two issues here. The specifics of the error message are because you declared a data.frame with 0 columns and then attempted to change two columns.
> data.frame() data frame with 0 columns and 0 rows > q <- data.frame() > q[1,] <- data.frame(a=3, b=6) Warning in `[<-.data.frame`(`*tmp*`, 1, , value = list(a = 3, b = 6)) : provided 2 variables to replace 0 variables > The second issue is that you need to read about logical subscripting. ?`[` Assuming your function is.prime is vectorized, meaning > is.prime(1:10) ## 2 3 5 7 [1] FALSE TRUE TRUE FALSE TRUE FALSE TRUE FALSE FALSE FALSE then this single statement will do what you want qq <- d[is.prime(d[,1]),] I recommend you not use "q" as a variable name. It will cause you trouble later when you confuse it with q() for quitting an R session. Rich ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.