haotu : an open lab notebook


All Pairwise Combinations of Rownames from a Square Matrix

Filed under: R, R, R spatial, R Stats, Uncategorized — Tags: , , , — S @ 12:37
combn(rownames(my.square.matrix), m=2, FUN=paste, collapse = "-", simplify = T)


read file from parent folder of current working directory

Filed under: Manipulate Data in R, R, R, R Stats, Uncategorized — Tags: , — S @ 08:10

If  your working directory is C:Parent/Child

Then to read a file from Parent use ..




save rda data file with compression

Filed under: errors in R, R, R, R Stats — Tags: , , , , — S @ 06:36

find non-ascii in R

Filed under: errors in R, R, R, R Stats, Uncategorized — Tags: , , , , — S @ 06:34


check a phylo object

Filed under: Uncategorized — Tags: , , — S @ 09:07

See here:


or forked



new faster code for PGLMM

Filed under: Uncategorized — Tags: , , — S @ 11:50



aggregate more than one column in data.table

Filed under: R — Tags: , , , , — S @ 11:15
# Average ability by grade
agg1<- fm1[, j=list(mean(x0, na.rm = TRUE),mean(x1, na.rm = TRUE)),by = key]



BLAST from R

Filed under: Uncategorized — Tags: , , , , , , — S @ 08:16

There is a nice post here on the topic
The post takes code from the blastSequences function in the R package annotate

However, the code does give an object with enough info to then retrieve the sequences. I edited this code to be able to perform BLASTs in R for a given organism filter. The returned object gives gene ids and definitions.

You can find my cleaned and edited code is here

Error in write.table because data.frame contains a list

Filed under: Uncategorized — Tags: , , , — S @ 06:42

Error in .External2(C_writetable, x, file, nrow(x), p, rnames, sep, eol, :
unimplemented type 'list' in 'EncodeElement'

I got this error when trying to write a table write.table on an object. The object was a data.frame but one of the elements was a list (it is unclear why it was a list, just R magic). The simplest workaround is to convert the data.frame to a matrix as.matrix and save that object with write.table


fill in missing data in R

Filed under: Uncategorized — Tags: , — S @ 10:34


The impute package developed for microarrays can replace missing (NA) data in an R matrix by its nearest neighbor values.

Older Posts »

Blog at WordPress.com.