Create a list:
List() on x returns x[[1]] <- c(-0.438185, -0.766791, 0.695282) > x[[2]] <- c (-0.759100, 0.034400, 0.524807)
> x [[1]] \s[1] -0.438185 -0.766791 0.695282
[[2]]
[1] -0.759100 0.034400 0.524807
Imagine it as an integer-indexed map, dictionary, or associative array.
And if you want to create a list of vectors from a string similar to the one above:
> s = "-0.438185 -0.766791 0.695282n0.759100 0.034400 0.524807" > x = "lapply(strsplit(s, "n")[[1]], function(x)" > x = "x [[1]]"
[1] -0.438185 -0.766791 0.695282
[[2]]
[1] 0.759100 0.034400 0.524807
I'm splitting lines with strsplit by newlines and then using strsplit once more to split each line. As.numeric is used to convert strings to numbers, and [[1]]s are used since strsplit generates a list rather than the single-valued result we are after.
Discover the world of data with our Data Science Course and embark on a transformative journey towards analytical excellence.