Statement 9 using sapply does not seem to give the correct answer (or at least to me). Yet I do what I think is the same thing with statement 11 and I get the answer I'm looking for.
9 : s <-sapply(unlist(v[c(1:length(v))]), max) 11: for(i in 1 :length(v)) v1[i] <- max(unlist(v[i])) Shouldn't I get the same answer ? library(XML) rm(list=ls()) url <- "http://webapp.montcopa.org/sherreal/salelist.asp?saledate=05/25/2011" tbl <-data.frame(readHTMLTable(url))[2:404, c(3,5,6,8,9)] names(tbl) <- c("Address", "Township", "Parcel", "SaleDate", "Costs"); rownames(tbl) <- c(1:length(tbl[,1])) x <-tbl v <- gregexpr("( aka )|( AKA )",x$Address) s <-sapply(unlist(v[c(1:length(v))]), max) v1 <-numeric(length(v)) for(i in 1 :length(v)) v1[i] <- max(unlist(v[i])) -- View this message in context: http://r.789695.n4.nabble.com/What-am-I-doing-wrong-with-sapply-tp3551598p3551598.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.