This additonal information might help. Here is what I am trying to do: This throws more light but here is what I am trying to. Lets say you have a data like the one below –
Region Open Store
120..141 + France
145..2115 + Germany
3322..5643 + Wales
5646..7451 - Scotland
7454..8641 - Mexico
8655..9860 - India
9980..11413 + Zambia
11478..1261 - Nicaragua
12978..1318 + Sweeden
What I was trying to do was to pick find the difference between the second element (141) and the consecutive first element (143) and if they meet a certain value and they have the same sign ( + or -), list all their stores together.
Use sapply and pass to it [ as the function and tell it you want to extract the second element.
# Create your data set
dat <- list(c(100, 150), c(201, 202), c(147, 269), c(301, 401))
dat
#[[1]]
#[1] 100 150
#
#[[2]]
#[1] 201 202
#
#[[3]]
#[1] 147 269
#
#[[4]]
#[1] 301 401
#
sapply(dat, "[", 2)
#[1] 150 202 269 401
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With