0
--
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of arun
> Sent: F
ot;\\1",dat1$slope)
dat2<-strsplit(dat1$slope,"/")
dat2[[1]][4]<-0
dat2[[2]][3:4]<-0
data.frame(do.call(rbind,dat2))
# X1 X2 X3 X4
#1 60 25 15 0
#2 90 10 0 0
#3 40 35 15 10
#4 40 25 25 10
- Original Message -----
From: Sapana Lohani
To: "r-help@r-project.o
Hello,
Try the following.
x <- c("slope (60/25/15)",
"slope (90/10)",
"slope (40/35/15/10)",
"slope (40/25/25/10)")
dat <- data.frame(X = x)
lst <- unlist(lapply(dat, function(.x) gsub("slope \\((.*)\\)$", "\\1",
.x)))
lst <- strsplit(lst, "/")
keep <- seq_len(max(unlist(lapply(lst, length))
Hi I am new to R so am struggling with the commands here
I have one column in a table that looks like
slope (60/25/15)
slope (90/10)
slope (40/35/15/10)
slope (40/25/25/10)
I want to have 4 columns with just the number inside the parenthesis. when
there is no number that cell can have 0. I
4 matches
Mail list logo