-4

I have a list containing rules for certain number of trials, such as rules[1] outputs set of 123 rules, rules[[2]] outputs set of 32 rules.Now, I have to get those numbers (123,32 ->number of rules)in a vector? It's not a string it's a List with items as Rules derived using apriori algorithm.

enter image description here

Sandesh
  • 31
  • 5
  • Welcome to StackOverflow. Please be sure to read about providing a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and have a look at making a [reproducible R example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Images are generally not the way to share your example data. – Jota Jan 11 '16 at 07:18
  • 1
    You may be looking for `lengths(thelist)` – Jota Jan 11 '16 at 07:22

1 Answers1

1

We can use str_extract

library(stringr)
as.numeric(str_extract(thelist, '\\d+'))
#[1] 450 396

data

thelist <- list("set of 450 rules", "set of 396 rules")
akrun
  • 874,273
  • 37
  • 540
  • 662