This code is directly from a Bioconductor vignette for creating an expressionSet (http://www.bioconductor.org/packages/2.12/bioc/vignettes/Biobase/inst/doc/ExpressionSetIntroduction.pdf).
> exprs <- as.matrix(read.table(exprsFile, header=TRUE, sep = "\t",
+ row.names = 1,
+ as.is=TRUE))
Can anyone tell why this code generates the following error message?
> exprs <- as.matrix(read.table(exprsFile, header=TRUE, sep = "\t",
+ row.names = 1,
Error: unexpected '=' in:
"exprs <- as.matrix(read.table(exprsFile, header=TRUE, sep = "\t",
+ row.names ="
> + as.is=TRUE))
Error: unexpected ')' in " + as.is=TRUE)"
Or, could you suggest an alternative method to read in the file exprsFile as a matrix with header?
Thank you very much for your time.
To convert a table into matrix in R, we can use apply function with as. matrix. noquote function.
To create a matrix, you start with a table and convert it to a matrix. On the Design tab > Switch Visualizations > Table > Matrix.
When creating matrices, we can pass the matrix function a vector containing the numbers to put in the matrix. If we want to specify the number of columns or rows, we can do that using the ncol and nrow arguments. By default, R takes the input vector and fills each column.
The biobase vignette is (almost certainly) produced using Sweave
. The >
and leading +
where single expressions have been split over multiple lines are an artefact of using Sweave
and how it displays code it processes. It reflects how the terminal / console (R session) would looked if you had entered the following (which should work)
exprs <- as.matrix(read.table(exprsFile, header=TRUE, sep = "\t",
row.names = 1,
as.is=TRUE))
knitr
(which is an alternative to Sweave
, and is now permitted for vignettes, by default has these prompts
removed, so code is more directly copy-and-pastable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With