How to loop through a list in R -
I have a list that says:
dataset $ mixed_bag & lt; - ("USA", "Red", "100"), "C" ("India"), "Hello" , "Blue", "76")) List and new variables based on the list list. A pseudo code will look something like this. the foreach line in the dataset $ mixed_bag {if (sapply (DataSet $ mixed_bag, length) == 3) {dataSet $ country & lt; - dataset $ mixed_bag [[line]] [1]; dataset $ color <- dataset $ composite_bag [[row]] [2]; Dataset $ score & lt; - Dataset $ composite_bug [[row]] [3];} and if (sapply) (DataSet $ mixed_bag, length) == 2) {# nothing else} and {# nothing}} Please suggest how I R
something like this?
dataList = list ("Hello" C ("USA" , "Red", "100"), c ("India", "blue", "76")) (in i data list) {print (i)} Returns: [1] "Hello" [1] "USA" "Red" "100" [1] "India" "Blue" "76"
or: for (in data list) {for (j) i {print (j)}}
returns [ 1] "Hello" [1] "USA" [1] "red" [1] "100" [1] "Weight "[1]" Blue "[1]" 76 "
Comments
Post a Comment