Re: [R] reading files with name columns and row columns

2015-09-02 Thread shawin
dear William , I have an issue with R code which is : FCP<-as.matrix(sapply(FCPval,as.numeric)) for (i in 1:rowN){if (FCP$FC[i] >= 1.5 & FCP$FC[i]<=-1.5 & FCP$p[i]<=0.05){ dfrmPFC=data.frame(matrix(Fc=FC,p=p))} } the error is :Error in FCP$FC : $ operator is invalid for atomic vectors could you

Re: [R] reading files with name columns and row columns

2015-09-02 Thread shawin
also the header =0 On Wed, Sep 2, 2015 at 11:52 PM, Shawin Karim wrote: > make row.name=0 instead to 1 > > On Wed, Sep 2, 2015 at 11:07 PM, Bogdan Tanasa [via R] < > ml-node+s789695n4711774...@n4.nabble.com> wrote: > >> Dear all, >> >> would appreciate a piece of help with a simple question: I a

Re: [R] reading files with name columns and row columns

2015-09-02 Thread Bogdan Tanasa
that is great, thank you Bill for time and help ;) ! On Wed, Sep 2, 2015 at 4:36 PM, William Dunlap wrote: > y <- as.matrix(read.table("FILE_NAME",header=T,row.names=1)) > colnames(y) <- gsub("X","", colnames(y)) > > Use read.table's check.names=FALSE argument so it won't mangle > the column

Re: [R] reading files with name columns and row columns

2015-09-02 Thread William Dunlap
y <- as.matrix(read.table("FILE_NAME",header=T,row.names=1)) colnames(y) <- gsub("X","", colnames(y)) Use read.table's check.names=FALSE argument so it won't mangle the column names instead of trying to demangle them with gsub() afterwards. E.g., txt <- " 50% 100%\nA 5 8\nB 13

Re: [R] reading files with name columns and row columns

2015-09-02 Thread Bogdan Tanasa
Thanks, Bert ! I solved the situation in the meanwhile, by using : y <- as.matrix(read.table("FILE_NAME",header=T,row.names=1)) colnames(y) <- gsub("X","", colnames(y)) On Wed, Sep 2, 2015 at 3:59 PM, Bert Gunter wrote: > Please read the Help file carefully before posting: > > "read.table is

Re: [R] reading files with name columns and row columns

2015-09-02 Thread Bert Gunter
Please read the Help file carefully before posting: "read.table is not the right tool for reading large matrices, especially those with many columns: it is designed to read data frames which may have columns of very different classes. Use scan instead for matrices." But the answer to your questio

[R] reading files with name columns and row columns

2015-09-02 Thread Bogdan Tanasa
Dear all, would appreciate a piece of help with a simple question: I am reading in R a file that is formatted as a matrix (an example is shown below, although it is more complex, a matrix of 1000 * 1000 ): the names of the columns are 0, 1, 4, 8, etc the names of the rows are 0, 1