[R] unwanted as.integer

Jack Tanner
Thu, 29 Jul 2004 21:54:48 -0000

> a <- sqlQuery(irrdb, "select count(field) from mytable where field
= 1")
 > print(a)
  count(field)
1            8
 > paste(a)
[1] "as.integer(8)"

Why the as.integer() representation? I later pass the result into this
write.html.table(), and what I get is rows of as.integer()... when all I
want is the integer itself.

as.integer(31) 	as.integer(21) 	as.integer(34) 	as.integer(86)
as.integer(7) 	as.integer(6) 	as.integer(15) 	as.integer(28)


write.html.table <- function(t, file= "", capt= "The Default
Title",
                            append = FALSE) {
head <- paste(" \n ", capt,
" \n")
  cat(head, file= file, append= append)
  if (is.null(rownames(t))) {
    rownames(t) <- rep("", nrow(t))
  }
tp <- rbind(c(" ", colnames(t)),
              cbind(unlist(lapply(rownames(t), function(x) {
paste(" ", x)})), t))
write.table(tp, sep= " ", file= file, , eol=
" \n",
              row.names=FALSE,
              col.names=FALSE,
              append=TRUE, quote=FALSE)
cat(" \n \n", file= file, append= TRUE)
}