Dear List,
I have this little problem:
I work with adiacency matrix like:
data me you
me 0 1
you 1 0
I store those matrix in a mysql database
actually I use RMySQL with:
res<-dbSendQuery(connection, "SELECT * FROM table")
myDataFrame<-fetch(res)
to retrive the table, and I have
data me you
1 io 0 1
2 tu 1 0
I would like the first column to be seen not as data, but as label,
like:
data me you
io 0 1
tu 1 0
should I change something in the table structure in mysql, or should I
tell R something particular like "the first column is not data"? If so,
how?
hope I have expressed well my intent
thanx in advance
simone
RMySQL question
3 messages · Simone Gabbriellini, Don MacQueen, David James
1 day later
Use the rownames() function to set the rownames equal to your first column, and then drop the first column. I don't know if there is a way to do it during retrieval from MySQL. -Don
At 11:10 PM +0200 4/2/05, simone gabbriellini wrote:
Dear List, I have this little problem: I work with adiacency matrix like: data me you me 0 1 you 1 0 I store those matrix in a mysql database actually I use RMySQL with: res<-dbSendQuery(connection, "SELECT * FROM table") myDataFrame<-fetch(res) to retrive the table, and I have data me you 1 io 0 1 2 tu 1 0 I would like the first column to be seen not as data, but as label, like: data me you io 0 1 tu 1 0 should I change something in the table structure in mysql, or should I tell R something particular like "the first column is not data"? If so, how? hope I have expressed well my intent thanx in advance simone
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
-------------------------------------- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA
simone gabbriellini wrote:
Dear List,
I have this little problem:
I work with adiacency matrix like:
data me you
me 0 1
you 1 0
I store those matrix in a mysql database
actually I use RMySQL with:
res<-dbSendQuery(connection, "SELECT * FROM table")
myDataFrame<-fetch(res)
to retrive the table, and I have
data me you
1 io 0 1
2 tu 1 0
I would like the first column to be seen not as data, but as label,
like:
data me you
io 0 1
tu 1 0
should I change something in the table structure in mysql, or should I
tell R something particular like "the first column is not data"? If so,
how?
hope I have expressed well my intent
thanx in advance
simone
Hi, In this case, since you are extracting all the rows you could simply try > dbReadTable(connection, "table", row.names = 1) See help(dbReadTable) for more details. Hope this helps, -- David