Dear All, I need to separate one column which is in a format like, "can_region", into two columns like, "can", and "region". Do we have a function in R to do this? Thanks. Regards, Jin [[alternative HTML version deleted]]
Does strsplit fit what you want? Tom> -----Original Message----- > From: Jin.Li at csiro.au [mailto:Jin.Li at csiro.au] > Sent: Thursday, 24 February 2005 11:46 AM > To: r-help at stat.math.ethz.ch > Subject: [R] a simple question > > > Dear All, > > I need to separate one column which is in a format like, "can_region", > into two columns like, "can", and "region". Do we have a > function in R > to do this? Thanks. > > Regards, > > Jin > > > [[alternative HTML version deleted]] > > ______________________________________________ > 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 >
hi, all. I am a beginner. Could you tell me how to use read.table() to read following beams.txt file. thanks file content is here: "beams" <- structure(list(strength = c(11.14, 12.74, 13.13, 11.51, 12.38, 12.6, 11.13, 11.7, 11.02, 11.41), SpecificGravity = c(0.499, 0.558, 0.604, 0.441, 0.55, 0.528, 0.418, 0.48, 0.406, 0.467), moisture = c(11.1, 8.9, 8.8, 8.9, 8.8, 9.9, 10.7, 10.5, 10.5, 10.7)), .Names = c("strength", "SpecificGravity", "moisture" ), class = "data.frame", row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"))
Try source("beams.txt") which reads and executes the commands in beams.txt. It might make more sense in future to store and work with dataframes, especially with big datasets. Regards, Adai On Tue, 2005-03-22 at 17:00 +0800, chin wei wrote:> hi, all. > I am a beginner. Could you tell me how to use read.table() to read > following beams.txt file. > thanks > > file content is here: > > "beams" <- > structure(list(strength = c(11.14, 12.74, 13.13, 11.51, 12.38, > 12.6, 11.13, 11.7, 11.02, 11.41), SpecificGravity = c(0.499, > 0.558, 0.604, 0.441, 0.55, 0.528, 0.418, 0.48, 0.406, 0.467), > moisture = c(11.1, 8.9, 8.8, 8.9, 8.8, 9.9, 10.7, 10.5, 10.5, > 10.7)), .Names = c("strength", "SpecificGravity", "moisture" > ), class = "data.frame", row.names = c("1", "2", "3", "4", "5", > "6", "7", "8", "9", "10")) > > ______________________________________________ > 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 >