Creating a scatter plot for multiple rows in R
Here is a solution with ggplot2
:
The data:
dat <- read.table(text="Samp1 Samp2 Samp3 Samp4 Samp5
Gene1 84.1 45.2 34.3 54.6 76.2
Gene2 94.2 12.4 68.0 75.3 24.8
Gene3 29.5 10.5 43.2 39.5 45.5", header = TRUE)
The plot:
library(ggplot2)
ggplot(stack(dat), aes(x = ind, y = values, colour = rownames(dat))) +
geom_point()