have lines like this in your supplied data:

0.695282 -0.438185 -0.766791

0.524807 0.759100 0.034400

In R, how can I make a data structure that looks like this:

[[1]]

-0.438185 -0.766791 0.695282 -0.438185 -0.766791 -0.766791 -0.766791 -0.76679

[[2]]

[1] 0.759100 0.034400 0.524807 0.759100 0.034400 0.524807 0.759100 0.034400 0.52
Jun 10, 2022 348 views

## 1 answer to this question.

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.

• 3,040 points

## How to manually find the minors of a matrix in R programming?

I have to write a function that ...READ MORE

## how to make 2 separate substrings from strsplit in R

When it comes to accessing the elements ...READ MORE

## How to implement Knn-algorithm without using k-nn function in r?

I created an example that demonstrates the ...READ MORE

## grepl in R to find matches to any of a list of character strings

Inside of a grepl regular expression, you ...READ MORE

## Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

## Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

The below is the code to perform ...READ MORE