Create a list from another list with R

Fish

I have a list of letters l

[1] a b c
[2] b c a b

and a vector v of letter too

[1] a
[2] b

My object is to take the letters of the vector v one by one and creating a new list that contains all the letter appearing after that letter. For example I take the first letter of v "a" and I create the list of letter appearing after "a" , And I got this :

[1] b c
[2] b

After i take the second letter or v which is "b" and I add to the list :

[3] c   
[4] c a b

So the final result is :

[1] b c
[2] b
[3] c   
[4] c a b

I don't know how to do this, it seems complicated.

I have also a list of vector with this format

[[1]]
[1] a
[2] b 
[3] c
[[2]]
[1] e
[2] g
Roland

A nested lapply:

lapply(v, function(v, l) lapply(l, function(x, v) {
  if (!(v %in% x)) return(x) #the case of no match
  x[-seq_len(which.max(x == v))]
}, v = v), l = l)
#[[1]]
#[[1]][[1]]
#[1] "b" "c"
#
#[[1]][[2]]
#[1] "b"
#
#
#[[2]]
#[[2]][[1]]
#[1] "c"
#
#[[2]][[2]]
#[1] "c" "a" "b"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to create list of items from another list

From Dev

java - create a list from subproperties of another list

From Dev

Create a list with items from another list at indices specified in a third list

From Dev

R: create a nested list from a list of vectors

From Dev

R: create a nested list from a list of vectors

From Dev

Create a list from a dataframe in R

From Dev

Create tuple list of key,val from another list of values in Python

From Dev

How to create a List<int> basead on two properties from another list?

From Dev

How does haskell create a new list from another list?

From Dev

How does haskell create a new list from another list?

From Dev

Create JSONs from list in directories, created by another list

From Dev

Create a list of repeated consecutive numbers regarding number from another list

From Dev

How to create a list from another list according to a function?

From Dev

Create a list from two lists based on values in another list

From Dev

Copying Data from a List to another in R

From Dev

how to find elements from a list that are not present in another list in r

From Dev

How to remove an object from a list that is not present in another list in R

From Dev

Create an instance of a list of Class (1) that inherits from another list of class(2) with a list from the other (2)

From Dev

R: create a list of admissible names from a string

From Dev

Create dataframe from list of lists in R

From Dev

Create table from list of tags lists in R

From Dev

R - Create a ordered list from a matrix

From Dev

R: Create custom output from list object

From Dev

R: Create list from vector in "triangular" form

From Dev

R: Create custom output from list object

From Dev

Create dataframe from list of lists in R

From Dev

R - How to create a new list from elements in a list?

From Dev

C# asp.net create string list from a another list which returns list of class objects

From Dev

C# asp.net create string list from a another list which returns list of class objects

Related Related

  1. 1

    How to create list of items from another list

  2. 2

    java - create a list from subproperties of another list

  3. 3

    Create a list with items from another list at indices specified in a third list

  4. 4

    R: create a nested list from a list of vectors

  5. 5

    R: create a nested list from a list of vectors

  6. 6

    Create a list from a dataframe in R

  7. 7

    Create tuple list of key,val from another list of values in Python

  8. 8

    How to create a List<int> basead on two properties from another list?

  9. 9

    How does haskell create a new list from another list?

  10. 10

    How does haskell create a new list from another list?

  11. 11

    Create JSONs from list in directories, created by another list

  12. 12

    Create a list of repeated consecutive numbers regarding number from another list

  13. 13

    How to create a list from another list according to a function?

  14. 14

    Create a list from two lists based on values in another list

  15. 15

    Copying Data from a List to another in R

  16. 16

    how to find elements from a list that are not present in another list in r

  17. 17

    How to remove an object from a list that is not present in another list in R

  18. 18

    Create an instance of a list of Class (1) that inherits from another list of class(2) with a list from the other (2)

  19. 19

    R: create a list of admissible names from a string

  20. 20

    Create dataframe from list of lists in R

  21. 21

    Create table from list of tags lists in R

  22. 22

    R - Create a ordered list from a matrix

  23. 23

    R: Create custom output from list object

  24. 24

    R: Create list from vector in "triangular" form

  25. 25

    R: Create custom output from list object

  26. 26

    Create dataframe from list of lists in R

  27. 27

    R - How to create a new list from elements in a list?

  28. 28

    C# asp.net create string list from a another list which returns list of class objects

  29. 29

    C# asp.net create string list from a another list which returns list of class objects

HotTag

Archive