P
#3 o3 2 G
#4 nox 0 P
#5 pm25 01 S
#6 co 03 S
#7 nox 04 P
A.K.
----- Original Message -
From: Rui Barradas
To: Zlatan
Cc: r-help@r-project.org
Sent: Saturday, November 17, 2012 10:22 AM
Subject: Re: [R] Split data frame and create a new column
H
Hello,
I don't know if this is general purpose but try
x <- scan(what = "character", text="
L1o3maxG10
L1o3P10
L2o3G10
noxP10
pm25S_01
comeanS_03
noxP_04")
fun <- function(x){
r1 <- unlist(strsplit(x, "L[[:digit:]]+|G|P|S"))
r1 <- r1[nchar(r1) != 0]
r1 <- r1[rep(c(TRUE, FALSE), len
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
3 matches
Mail list logo