Dear R-helpers,
I wonder if I could impose upon you for forther assistance, this
time with dataframes: hopefully this will be of general interest,
as I personally have found them hard to get to grips with.
I was trying to transpose rows and cols and move col1 to the names.
Then all sorts of things go wrong. Although the end result looks
the same, page() shows the structure to be quite different compared
to building it by hand.
What is going on? And how am I supposed to do this. (And no,
I didn't expect that the output of plot() would be sensible!)
Thanks again,
Michael
wk
authorisor count(*)
1 JMC 4
2 LCA 259
3 MCM 136
4 MDH 266
5 ML 27
6 SA 1
structure(list(JMC = 4, LCA = 259, MCM = 136, MDH = 266, ML = 27,
SA = 1), .Names = c("JMC", "LCA", "MCM", "MDH", "ML", "SA"
), row.names = "1", class = "data.frame")
----------------------------------
E-Mail: Michael Lapsley <mlapsley at ndirect.co.uk>
Date: 13-Oct-99
Time: 01:12:23
This message was sent by XFMail
----------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Col1 Col2
1 one 1
2 two 2
3 three 3
# Pick out the second column and transpose into a new structure:
ttt<-data.frame(t(tt[,2]))
# Take the column names of ttt from the first column of tt:
colnames(ttt)<-tt[,1]
# Take rowname for ttt from second colname of tt
rownames(ttt)<-colnames(tt)[2]
# then:
ttt
one two three
Col2 1 2 3
# Then to plot, since plot assumes a column vector:
plot(t(ttt))
Isn't this what you want? Seems pretty intuitive here. Mind you, I always
have to check but less intuitive is to get rid of column titles etc when
you want to turn a numerical data frame into a matrix. The titles keep
following me around like a bad smell!!!
John
On Wed, 13 Oct 1999, Michael Lapsley wrote:
Dear R-helpers,
I wonder if I could impose upon you for forther assistance, this
time with dataframes: hopefully this will be of general interest,
as I personally have found them hard to get to grips with.
I was trying to transpose rows and cols and move col1 to the names.
Then all sorts of things go wrong. Although the end result looks
the same, page() shows the structure to be quite different compared
to building it by hand.
What is going on? And how am I supposed to do this. (And no,
I didn't expect that the output of plot() would be sensible!)
Thanks again,
Michael
wk
authorisor count(*)
1 JMC 4
2 LCA 259
3 MCM 136
4 MDH 266
5 ML 27
6 SA 1
structure(list(JMC = 4, LCA = 259, MCM = 136, MDH = 266, ML = 27,
SA = 1), .Names = c("JMC", "LCA", "MCM", "MDH", "ML", "SA"
), row.names = "1", class = "data.frame")
----------------------------------
E-Mail: Michael Lapsley <mlapsley at ndirect.co.uk>
Date: 13-Oct-99
Time: 01:12:23
This message was sent by XFMail
----------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._