On Tue, 30 Apr 2002, hkimscil wrote:> Hello all - > > I am sorry if this simple question is addressed in somewhere else. But, I couldn't find it. It's been for about a week using R. . . > > My problem is: > > Reading matrix data with "scan" does not seem to allow me to incorporate matrix labels (columns, and rows). > > If I use read.table, I can import the lables. But, the problem is, I don't know how I make this data as matrix.Use as.matrix or data.matrix. You need to consider if you want a character or numeric matrix, but if all your input is numbers (apart from row and column names) either will do. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Try ?as.matrix -roger _______________________________ UCLA Department of Statistics rpeng at stat.ucla.edu http://www.stat.ucla.edu/~rpeng On Tue, 30 Apr 2002, hkimscil wrote:> Hello all - > > I am sorry if this simple question is addressed in somewhere else. But, I couldn't find it. It's been for about a week using R. . . > > My problem is: > > Reading matrix data with "scan" does not seem to allow me to incorporate matrix labels (columns, and rows). > > If I use read.table, I can import the lables. But, the problem is, I don't know how I make this data as matrix. > > I'd really appreciate any help, and will keep diggin the manual for more information. > > Regrads, > > -hyo > Hyo Kim, student > Communicaiton Department > Rutgers, New Jersey, US > hkimscil at scils.rutgers.edu > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello all - I am sorry if this simple question is addressed in somewhere else. But, I couldn't find it. It's been for about a week using R. . . My problem is: Reading matrix data with "scan" does not seem to allow me to incorporate matrix labels (columns, and rows). If I use read.table, I can import the lables. But, the problem is, I don't know how I make this data as matrix. I'd really appreciate any help, and will keep diggin the manual for more information. Regrads, -hyo Hyo Kim, student Communicaiton Department Rutgers, New Jersey, US hkimscil at scils.rutgers.edu -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi, I could use some help figuring out how to make some more useful tickmark labels in a set of box and whisker plots I've made. I'm really happy with the bwplot code I'm using (borrowed heavily from examples) as it gives me three sets of boxplots for each group (sourcedx) across seven variables (X.NAME) all on the same page. The problem is, I'd like to label the sets of tickmarks with something less cumbersome than the original variable labels (X.LABEL). I've been playing around with strsplit: lab1<-unlist(strsplit(milk$X.LABEL, "-")) to try to get the label to pull off the part of X.LABEL before the "- times/month" or "- times/mo" that appears in each label. That should give me a shorter but still sufficiently descriptive label. However, I can't seem to figure out how to get just that first part, since what I end up with is a list: [1] "Chocolate milk and hot cocoa " " times/mo" "Milk to drink or on cereal " [4] " times/month" "Yogurt and frozen yogurt " " times/month" [7] "Ice cream,ice milk,milkshakes " Do I then figure out how to pick elements out of the list, or is there a better way to trim a character variable? My dataset (milk) looks like this: id X.NAME. X.LABEL. amt1 sourcedx nh10000 HAN1AS Chocolate milk and hot cocoa - times/mo 0.00 NHANE nh10000 HAN1BS Milk to drink or on cereal - times/month 30.00 NHANE nh10000 HAN1ES Yogurt and frozen yogurt - times/month 0.00 NHANE nh10000 HAN1FS Ice cream,ice milk,milkshakes - times/mo 4.00 NHANE nh10000 HAN1GS Cheese, all types - times/month 17.00 NHANE nh10000 HAN1HS Pizza, calzone, lasagna - times/month 0.00 NHANE nh10000 HAN1IS Cheese dishes - times/month 3.00 NHANE sp60048 HAN1AS Chocolate milk and hot cocoa - times/mo 0.00 SOCOp sp60048 HAN1BS Milk to drink or on cereal - times/month 30.40 SOCOp sp60048 HAN1ES Yogurt and frozen yogurt - times/month 0.00 SOCOp sp60048 HAN1FS Ice cream,ice milk,milkshakes - times/mo 2.00 SOCOp sp60048 HAN1GS Cheese, all types - times/month 30.40 SOCOp sp60048 HAN1HS Pizza, calzone, lasagna - times/month 2.00 SOCOp sp60048 HAN1IS Cheese dishes - times/month 1.00 SOCOp sa30007 HAN1AS Chocolate milk and hot cocoa - times/mo 12.90 SOCOa sa30007 HAN1BS Milk to drink or on cereal - times/month 60.80 SOCOa sa30007 HAN1ES Yogurt and frozen yogurt - times/month NA SOCOa sa30007 HAN1FS Ice cream,ice milk,milkshakes - times/mo 30.40 SOCOa sa30007 HAN1GS Cheese, all types - times/month 0.00 SOCOa sa30007 HAN1HS Pizza, calzone, lasagna - times/month 0.00 SOCOa sa30007 HAN1IS Cheese dishes - times/month 4.00 SOCOa sa30009 HAN1AS Chocolate milk and hot cocoa - times/mo 0.00 SOCOa Thanks, Scot -- Scot W. McNary email:smcnary at charm.net -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._