Skip to content
Prev 15013 / 15274 Next

Data

Hi Enrico,

thanks for the feedback.
I am having something different here:
I would be grateful for your assistance.

res <- strsplit(as.character(my.data$Strike), ":")
#[[1]]
#[1] "character(0)"

#[[2]]
#[1] "c(\"CAP ATM Fwd\", \" -0.49%\")"

#[[3]]
#[1] "c(\"SWT 0.50% fwd\", \" 0.05%\")"

#[[4]]
#[1] "c(\"CAP ATM Fwd\", \" -0.46%\")"

#[[5]]
#[1] "c(\"SWT 0.50% fwd\", \" 0.08%\")"




col1 <- sapply(res, `[[`, 1L)

#> col1
#[1] "character(0)"                     "c(\"CAP ATM Fwd\", \" -0.49%\")"
 "c(\"SWT 0.50% fwd\", \" 0.05%\")"
#[4] "c(\"CAP ATM Fwd\", \" -0.46%\")"  "c(\"SWT 0.50% fwd\", \" 0.08%\")"
"c(\"CAP ATM Fwd\", \" -0.40%\")"
#[7] "c(\"SWT 0.50% fwd\", \" 0.11%\")" "c(\"CAP ATM Fwd\", \" -0.32%\")"
 "c(\"SWT 0.50% fwd\", \" 0.14%\")"
#[10] "c(\"CAP ATM Fwd\", \" -0.23%\")"  "c(\"SWT 0.50% fwd\", \" 0.17%\")"
"c(\"CAP ATM Fwd\", \" -0.14%\")"


col2 <- sapply(res, `[[`, 2L)


#Error in FUN(X[[i]], ...) : subscript out of bounds

col2 <- as.numeric(sub("%", "", col2, fixed = TRUE))/100
res <- data.frame(col1, col2)


#col1 col2
#1                  character(0)   NA
#2   c("CAP ATM Fwd", " -0.49%")   NA
#3  c("SWT 0.50% fwd", " 0.05%")   NA
#4   c("CAP ATM Fwd", " -0.46%")   NA
#5  c("SWT 0.50% fwd", " 0.08%")   NA
#6   c("CAP ATM Fwd", " -0.40%")   NA
#7  c("SWT 0.50% fwd", " 0.11%")   NA
#8   c("CAP ATM Fwd", " -0.32%")   NA

i <- seq(from = 1, to = nrow(res), by = 2)
res[i, ]
#col1 col2
#1                  character(0)   NA
#3  c("SWT 0.50% fwd", " 0.05%")   NA
#5  c("SWT 0.50% fwd", " 0.08%")   NA
#7  c("SWT 0.50% fwd", " 0.11%")   NA
#9  c("SWT 0.50% fwd", " 0.14%")   NA
#11 c("SWT 0.50% fwd", " 0.17%")   N
res[i + 1, ]

#2  c("CAP ATM Fwd", " -0.49%")   NA
#4  c("CAP ATM Fwd", " -0.46%")   NA
#6  c("CAP ATM Fwd", " -0.40%")   NA
#8  c("CAP ATM Fwd", " -0.32%")   NA
#10 c("CAP ATM Fwd", " -0.23%")   NA

Many thanks,
Emmanuel


The information transmitted is intended only for the person or entity
to which it is addressed and may contain confidential and/or
privileged material. Any review, retransmission, dissemination or
other use of, or taking of any action in reliance upon, this
information by persons or entities other than the intended recipient
is prohibited. If you received this in error, please contact the
sender and delete the material from any computer.







<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Sat, Mar 20, 2021 at 9:18 AM Enrico Schumann <es at enricoschumann.net>
wrote:
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>