Re: [R] data frame: adding columns from data and file title

2012-11-28 Thread jim holtman
Here is how to get the information from the file name that you want: > # let's assume you have the filename > fileName <- "G7_pig328_unit328_Site141_30MAR2012_RNo4_SitNo1.csv" > # parse it for the group and bird names > group <- sub("^G([0-9]+).*", "\\1", fileName) > bird <- sub(".*pig([0-9]+).*",

Re: [R] data frame: adding columns from data and file title

2012-11-28 Thread arun
Hi, TRy this: dat1 <- read.table(text=" Date_ Time_ Speed  Course  Type_  Distance 30/03/2012  11:15:05  108  121  -2 0 30/03/2012  11:15:06    0  79  0 0 30/03/2012  11:15:07    0  76  0 1 30/03/2012  11:15:08    0  86  0 2 30/03/2012  11:15:09    0  77  0 3 ", header = TRUE, stringsAsFactors = FA

Re: [R] data frame: adding columns from data and file title

2012-11-28 Thread Rui Barradas
Hello, First of all, the best way of posting data examples is ?dput. Anyway, try the following. dat <- read.table(text=" Date_ Time_ Speed Course Type_ Distance 30/03/2012 11:15:05 108 121 -2 0 30/03/2012 11:15:060 79 0 0 30/03/2012 11:15:070 76 0 1 30/03/2012 11:15