matrix row/column displayed as a list
3
0
Entering edit mode
Daniel Brewer ★ 1.9k
@daniel-brewer-1791
Last seen 10.2 years ago
Hi, This is a silly little question, but I can't find the answer. I have a matrix of expression values e.g. expression. When I display either one column or one row it displays a list e.g. expression[1,] or expression[,1]. Is there a way to change this behaviour? When I constructed a test matrix, the matrix worked as desired i.e. > togo <- matrix(c(1,2,3,4),ncol=2, nrow=2) > togo[,1] [1] 1 2 Why is the behaviour different? Many thanks Dan -- ************************************************************** Daniel Brewer, Ph.D. Institute of Cancer Research United Kingdom ************************************************************** The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the addre...{{dropped}}
Cancer Cancer • 1.4k views
ADD COMMENT
0
Entering edit mode
Seth Falcon ★ 7.4k
@seth-falcon-992
Last seen 10.2 years ago
Daniel Brewer <daniel.brewer at="" icr.ac.uk=""> writes: > Hi, > > This is a silly little question, but I can't find the answer. I have a > matrix of expression values e.g. expression. When I display either one > column or one row it displays a list e.g. expression[1,] or > expression[,1]. Is there a way to change this behaviour? I think you mean that it displays a vector. I think you will find help by reading help("[") and looking at the 'drop' argument. togo <- matrix(c(1,2,3,4),ncol=2, nrow=2) > togo[1, ] [1] 1 3 > togo[1, , drop=FALSE] [,1] [,2] [1,] 1 3 + seth -- Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center http://bioconductor.org
ADD COMMENT
0
Entering edit mode
Seth Falcon ★ 7.4k
@seth-falcon-992
Last seen 10.2 years ago
Daniel Brewer <daniel.brewer at="" icr.ac.uk=""> writes: > Yes I have already tried that, class(expression) is matrix. But > class(expression[1,]) is list as is class(expression[,1]). Whereas the > class of my simple constructed matrix when looking at a single row or > column is numeric i.e. class(togo[,2]). > > Thanks for the suggestion anyway. Then you need to provide a lot more detailed information / reproducible example. + seth -- Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center http://bioconductor.org
ADD COMMENT
0
Entering edit mode
Hi Duncan and others, I have a problem with saveXML. I'm trying to to this: > saveXML(toGXL(test), file="test.gxl") where 'test' is an object of class graphNEL. This works fine on a linux and PC, but not on mac, which is my standard machine for running R (sessionInfo below). > saveXML(toGXL(test), file="test.gxl") Error in NextMethod("saveXML", object = doc$value()) : no method to invoke > methods(saveXML) [1] saveXML.XMLInternalDOM* saveXML.XMLInternalDocument* saveXML.XMLNode* saveXML.XMLOutputStream* Non-visible functions are asterisked Any ideas? Thanks \Heidi ## MAC ## > sessionInfo() R version 2.4.1 (2006-12-18) i386-apple-darwin8.8.1 locale: en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] "splines" "tools" "stats" "graphics" "grDevices" "utils" "datasets" "methods" "base" other attached packages: geneplotter GOstats Category genefilter survival KEGG RBGL annotate Biobase "1.12.0" "2.0.4" "2.0.3" "1.12.0" "2.30" "1.14.1" "1.10.0" "1.12.1" "1.12.2" GO graph XML "1.14.1" "1.12.1" "1.6-0" ## LINUX ## > sessionInfo() R version 2.5.0 alpha (2007-03-30 r40957) i686-pc-linux-gnu locale: LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB .UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB. UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8 ;LC_IDENTIFICATION=C attached base packages: [1] "splines" "tools" "stats" "graphics" "grDevices" "utils" [7] "datasets" "methods" "base" other attached packages: XML GOstats Category AnnotationDbi RSQLite "1.6-2" "2.1.13" "2.1.28" "0.0.56" "0.5-3" DBI Matrix lattice genefilter survival "0.2-1" "0.9975-11" "0.15-1" "1.13.12" "2.31" KEGG RBGL annotate Biobase GO "1.15.13" "1.11.4" "1.13.8" "1.13.44" "1.15.13" graph "1.13.9" ## PC## Don't have the sessionInfo here, but it's back with R2.0 ------------<<>>------------ Heidi Dvinge European Bioinformatics Institute Wellcome Trust Genome Campus Hinxton, Cambridge CB10 1SD Mail: heidi at ebi.ac.uk Phone: +44 (0) 1223 492 550 ------------<<>>------------
ADD REPLY
0
Entering edit mode
Hi Heidi This is one is reasonably easy, I hope. You need version 1.6-1 or higher on your Mac. You have it on your Linux machine, but not on your Mac. That may be because you are getting a binary version from a repository and that is not up to date with the releases from the Omegahat site. If you have the compilers installed on your Mac, the R command install.packages("XML", repos = "http://www.omegahat.org/R", type = "source") will get the latest version (1.6-3) and build it. D. hdvi at well.ox.ac.uk wrote: > Hi Duncan and others, > > I have a problem with saveXML. I'm trying to to this: > >> saveXML(toGXL(test), file="test.gxl") > > where 'test' is an object of class graphNEL. This works fine on a linux > and PC, but not on mac, which is my standard machine for running R > (sessionInfo below). > >> saveXML(toGXL(test), file="test.gxl") > Error in NextMethod("saveXML", object = doc$value()) : > no method to invoke >> methods(saveXML) > [1] saveXML.XMLInternalDOM* saveXML.XMLInternalDocument* > saveXML.XMLNode* saveXML.XMLOutputStream* > Non-visible functions are asterisked > > Any ideas? > > Thanks > \Heidi > > ## MAC ## >> sessionInfo() > R version 2.4.1 (2006-12-18) > i386-apple-darwin8.8.1 > > locale: > en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 > > attached base packages: > [1] "splines" "tools" "stats" "graphics" "grDevices" "utils" > "datasets" "methods" "base" > > other attached packages: > geneplotter GOstats Category genefilter survival KEGG > RBGL annotate Biobase > "1.12.0" "2.0.4" "2.0.3" "1.12.0" "2.30" "1.14.1" > "1.10.0" "1.12.1" "1.12.2" > GO graph XML > "1.14.1" "1.12.1" "1.6-0" > > ## LINUX ## >> sessionInfo() > R version 2.5.0 alpha (2007-03-30 r40957) > i686-pc-linux-gnu > > locale: > LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_ GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_G B.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF -8;LC_IDENTIFICATION=C > > attached base packages: > [1] "splines" "tools" "stats" "graphics" "grDevices" "utils" > [7] "datasets" "methods" "base" > > other attached packages: > XML GOstats Category AnnotationDbi RSQLite > "1.6-2" "2.1.13" "2.1.28" "0.0.56" "0.5-3" > DBI Matrix lattice genefilter survival > "0.2-1" "0.9975-11" "0.15-1" "1.13.12" "2.31" > KEGG RBGL annotate Biobase GO > "1.15.13" "1.11.4" "1.13.8" "1.13.44" "1.15.13" > graph > "1.13.9" > > ## PC## > > Don't have the sessionInfo here, but it's back with R2.0 > > ------------<<>>------------ > Heidi Dvinge > > European Bioinformatics Institute > Wellcome Trust Genome Campus > Hinxton, Cambridge > CB10 1SD > Mail: heidi at ebi.ac.uk > Phone: +44 (0) 1223 492 550 > ------------<<>>------------ >
ADD REPLY
0
Entering edit mode
Hi Duncan, I ran the XML as you specified below, and got version 1.6-2, instead of 1.6-0 which is the CRAN version. When trying the run saveXML the error message persists though. I think it might be a problem with my R installation (R version 2.4.1 (2006-12-18) built from binary), since the function seems to work on another mac (built from source). Also, it worked on a PC, which has an XML version older than the 1.6-0. Haven't had any other problems with R on this mac though. Cheers \Heidi > > Hi Heidi > > This is one is reasonably easy, I hope. > You need version 1.6-1 or higher on your Mac. > You have it on your Linux machine, but not on your Mac. > That may be because you are getting a binary version > from a repository and that is not up to date > with the releases from the Omegahat site. > If you have the compilers installed on your Mac, > the R command > > install.packages("XML", repos = "http://www.omegahat.org/R", > type = "source") > > will get the latest version (1.6-3) and build it. > > D. > > hdvi at well.ox.ac.uk wrote: >> Hi Duncan and others, >> >> I have a problem with saveXML. I'm trying to to this: >> >>> saveXML(toGXL(test), file="test.gxl") >> >> where 'test' is an object of class graphNEL. This works fine on a linux >> and PC, but not on mac, which is my standard machine for running R >> (sessionInfo below). >> >>> saveXML(toGXL(test), file="test.gxl") >> Error in NextMethod("saveXML", object = doc$value()) : >> no method to invoke >>> methods(saveXML) >> [1] saveXML.XMLInternalDOM* saveXML.XMLInternalDocument* >> saveXML.XMLNode* saveXML.XMLOutputStream* >> Non-visible functions are asterisked >> >> Any ideas? >> >> Thanks >> \Heidi >> >> ## MAC ## >>> sessionInfo() >> R version 2.4.1 (2006-12-18) >> i386-apple-darwin8.8.1 >> >> locale: >> en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 >> >> attached base packages: >> [1] "splines" "tools" "stats" "graphics" "grDevices" "utils" >> "datasets" "methods" "base" >> >> other attached packages: >> geneplotter GOstats Category genefilter survival KEGG >> RBGL annotate Biobase >> "1.12.0" "2.0.4" "2.0.3" "1.12.0" "2.30" "1.14.1" >> "1.10.0" "1.12.1" "1.12.2" >> GO graph XML >> "1.14.1" "1.12.1" "1.6-0" >> >> ## LINUX ## >>> sessionInfo() >> R version 2.5.0 alpha (2007-03-30 r40957) >> i686-pc-linux-gnu >> >> locale: >> LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en _GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_ GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UT F-8;LC_IDENTIFICATION=C >> >> attached base packages: >> [1] "splines" "tools" "stats" "graphics" "grDevices" "utils" >> [7] "datasets" "methods" "base" >> >> other attached packages: >> XML GOstats Category AnnotationDbi RSQLite >> "1.6-2" "2.1.13" "2.1.28" "0.0.56" "0.5-3" >> DBI Matrix lattice genefilter survival >> "0.2-1" "0.9975-11" "0.15-1" "1.13.12" "2.31" >> KEGG RBGL annotate Biobase GO >> "1.15.13" "1.11.4" "1.13.8" "1.13.44" "1.15.13" >> graph >> "1.13.9" >> >> ## PC## >> >> Don't have the sessionInfo here, but it's back with R2.0 >> >> ------------<<>>------------ >> Heidi Dvinge >> >> European Bioinformatics Institute >> Wellcome Trust Genome Campus >> Hinxton, Cambridge >> CB10 1SD >> Mail: heidi at ebi.ac.uk >> Phone: +44 (0) 1223 492 550 >> ------------<<>>------------ >> >
ADD REPLY
0
Entering edit mode
Daniel Brewer ★ 1.9k
@daniel-brewer-1791
Last seen 10.2 years ago
Yes I have already tried that, class(expression) is matrix. But class(expression[1,]) is list as is class(expression[,1]). Whereas the class of my simple constructed matrix when looking at a single row or column is numeric i.e. class(togo[,2]). Thanks for the suggestion anyway. Stephen Henderson wrote: > Are you sure expression is a matrix? > What do you get when you type? > >> class(expression) > > have you tried: > >> expression<- as.matrix(expression) > > > Stephen Henderson > Wolfson Inst. for Biomedical Research > Cruciform Bldg., Gower Street > University College London > United Kingdom, WC1E 6BT > +44 (0)207 679 6827 > > > -----Original Message----- > From: bioconductor-bounces at stat.math.ethz.ch > [mailto:bioconductor-bounces at stat.math.ethz.ch] On Behalf Of Daniel > Brewer > Sent: 30 March 2007 14:42 > To: bioconductor at stat.math.ethz.ch > Subject: [BioC] matrix row/column displayed as a list > > Hi, > > This is a silly little question, but I can't find the answer. I have a > matrix of expression values e.g. expression. When I display either one > column or one row it displays a list e.g. expression[1,] or > expression[,1]. Is there a way to change this behaviour? > > When I constructed a test matrix, the matrix worked as desired i.e. >> togo <- matrix(c(1,2,3,4),ncol=2, nrow=2) >> togo[,1] > [1] 1 2 > Why is the behaviour different? > > Many thanks > > Dan The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the addre...{{dropped}}
ADD COMMENT

Login before adding your answer.

Traffic: 755 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6