Print summary results or other outputs on the R plot
Use capture.output.
summary.text <- paste(capture.output(summary(avg.score.per.pos)), collapse="\n") mtext(summary.text)
Print summary results or other outputs on the R plot
Use capture.output.
summary.text <- paste(capture.output(summary(avg.score.per.pos)), collapse="\n") mtext(summary.text)
Differences between do.call and lapply
Consider this. If L is a list with n components then
– do.call(f, L) calls f once
– lapply(L, f) calls f n times
https://stat.ethz.ch/pipermail/r-help/2007-April/129252.html
list to matrix in R
matrix(unlist(list.data), nrow=num.row, byrow=TRUE)
To convert list of list to matrix,
do.call(rbind, sapply(list.data, unlist))
Use cex.main or cex.sub to change the size of the title or subtitle in R
title(main="Main title", cex.main=0.85)
Connecting PostgreSQL from R using RdbiPgSQL
library(RdbiPgSQL) conn <- dbConnect(PgSQL(), host="localhost", dbname="my_database", user="my_user", password="my_secret_password") res <- dbSendQuery(conn, "select * from prices where item_id = 29") mydata <- dbGetResult(res) ... dbDisconnect(conn)
Read text file into R as a character vector.
genome.sequence <- scan(file = sequence.file, what = "character")
R graph by examples
http://rgraphics.limnology.wisc.edu/index.php
functions depending on the data types in R
[table id=1 /]
Differences in single argument subscripting in matrix and data frame.
Even though the two variables look similar, the results are different depending on the data type.
The single argument scripting of data frame returns a column, while matrix returns an element according to its position as matrix is a vector.
> class(my2) [1] "data.frame" > my2 a1 b c a1.1 1 10 20 30 35 2 10 20 30 35 > my2[1] a1 1 10 2 10 > class(my2.matrix) [1] "matrix" > my2.matrix a1 b c a1.1 1 10 20 30 35 1 10 20 30 35 > my2.matrix[1] [1] 10