first problem: the "blank" space in first position in the first line. Try removing it, so that the file looks like this:
"1","2","3","4" "1",484,43,67,54 "2",54,35,67,34 "3",69,76,78,55 "4",67,86,44,34 Second: your colnames and rownames are numeric; R recognizes it but puts an X (but it recognizes the rownames and puts them correctly!). To see it try: test.csv: "23","3","33","31" "25",484,43,67,54 "54",54,35,67,34 "43",69,76,78,55 "34",67,86,44,34 > test <- read.table("test.csv", sep=",", header=T) Then you can remove the X in the colnames: > colnames(test) <- gsub("X", "", colnames(test)) 2012/3/23 MSousa <ricardosousa2...@clix.pt> > Good morning, > > Good morning, > > I'm trying to read the file into an array, with the following code. > > A<- as.matrix(read.csv("~/Desktop/Results/Cfile.csv", header = FALSE, > sep=",")) > > The content of the file > " ","1","2","3","4" > "1", 484,43,67,54 > "2",54,35,67,34 > "3",69,76,78,55 > "4",67,86,44,34 > > What I needed is that the first line was the name of the columns and the > first column was the name of the lines. > > Thanks > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Read-File-for-Matrix-with-rownames-tp4498280p4498280.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.