[R] unwanted as.integer
Jack Tanner
ihok at hotmail.com
Thu Jul 29 23:54:48 CEST 2004
> 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("<table>\n<caption>", capt, "</caption>\n")
cat(head, file= file, append= append)
if (is.null(rownames(t))) {
rownames(t) <- rep("", nrow(t))
}
tp <- rbind(c("<tr><td></td>", colnames(t)),
cbind(unlist(lapply(rownames(t), function(x) {
paste("<tr><td>", x)})), t))
write.table(tp, sep= "<td>", file= file, , eol= "</tr>\n",
row.names=FALSE,
col.names=FALSE,
append=TRUE, quote=FALSE)
cat("</tr>\n</table>\n", file= file, append= TRUE)
}
More information about the R-help
mailing list