User:Timothee Flutre/Notebook/Postdoc/2011/11/09: Difference between revisions
From OpenWetWare
m (→Entry title: mention R "replace") |
(→Entry title: visualize NA in matrix) |
||
Line 17: | Line 17: | ||
Or it's maybe easier with the built-in [http://stat.ethz.ch/R-manual/R-patched/library/base/html/replace.html replace] function. | Or it's maybe easier with the built-in [http://stat.ethz.ch/R-manual/R-patched/library/base/html/replace.html replace] function. | ||
* in R, visualize the missing values (encoded as "NA") in a matrix: | |||
image(1:nrow(mat), 1:ncol(mat), is.na(mat), col=c("white","black"), | |||
main="Missing values", xlab="Genes", ylab="Samples") | |||
[[Image:Visualize_missing_values_in_matrix.png|400px]] | |||
<!-- ##### DO NOT edit below this line unless you know what you are doing. ##### --> | <!-- ##### DO NOT edit below this line unless you know what you are doing. ##### --> |
Revision as of 16:49, 9 November 2011
Project name | <html><img src="/images/9/94/Report.png" border="0" /></html> Main project page <html><img src="/images/c/c3/Resultset_previous.png" border="0" /></html>Previous entry<html> </html>Next entry<html><img src="/images/5/5c/Resultset_next.png" border="0" /></html> |
Entry title
links <- data.frame(id1=c("a","b","c"), id2=c("1","2","3"), stringsAsFactors=FALSE) mat <- matrix(runif(3*10), nrow=3) rownames(mat) <- c("b","c","a") new.rownames <- unlist(lapply(rownames(mat), function(i){links$id2[which(links$id1 == i)]})) rownames(mat) <- new.rownames Or it's maybe easier with the built-in replace function.
image(1:nrow(mat), 1:ncol(mat), is.na(mat), col=c("white","black"), main="Missing values", xlab="Genes", ylab="Samples") |