R convert list of lists into single numeric list


# 		Set seed so results able to be replicated:
set.seed(123)
# 		Make arbitrary List of sub-lists in each index:
list.of.lists <- list()
for (i in 1:3) {
  list.of.lists[[i]] <- rnorm(5)
}
# 		Print list.of.lists
list.of.lists
#[[1]]
#[1] -0.56047565 -0.23017749  1.55870831  0.07050839  0.12928774
#
#[[2]]
#[1]  1.7150650  0.4609162 -1.2650612 -0.6868529 -0.4456620
#
#[[3]]
#[1]  1.2240818  0.3598138  0.4007715  0.1106827 -0.5558411

# 		Convert to single list:
big.numeric <- as.numeric(do.call(c, list.of.lists))
big.numeric
#[1] -0.56047565 -0.23017749  1.55870831  0.07050839  0.12928774  1.71506499  0.46091621
#[8] -1.26506123 -0.68685285 -0.44566197  1.22408180  0.35981383  0.40077145  0.11068272
#[15] -0.55584113

Are there any code examples left?
New code examples in category R
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source