[R] Split data frame and create a new column

Zlatan pollaroid at gmail.com
Fri Nov 16 01:05:54 CET 2012


I need to split a data frame into 3 columns. The column I want to split
contains indices of lag (prefix L1 or L2 and suffix 01, 03, 04), station
name (shown in the sample data as capitalized G, P and S) and pollutant
name. Names with no “L” prefix or 01/04 suffix are lag 0. Lag 01 is average
of lag 0 and 1, and 04 is average of 0 to 4 days. How can one do that in R? 
I will ignore the other components( e.g. 10 , max or mean)



Current stand

L1o3maxG10
L1o3P10
L2o3G10
noxP10
pm25S_01
comeanS_03
noxP_04

What I want to get :

pollutant  Lag	station
o3	1	G
o3	1	P
o3	2	G
nox	0	P
Pm25	01	S
co	03	S
nox	04	P


Thanks




--
View this message in context: http://r.789695.n4.nabble.com/Split-data-frame-and-create-a-new-column-tp4649683.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list