multiple lists combines errors in R

r

#1

0
down vote
favorite
I have multiple lists wanted to combine, but got wrong results

The code I used

hiv.Scatter <- list(predictions = predictdata, labels = L)

for (k in 1:2){
hiv.Scatter <-
list(predictions = append(
list(hiv.Scatter$predictions),
list(predictdata)
),
labels = append(list(hiv.Scatter$labels), list(L)))
}
But use the code above, I got very strange results. the results I wanted is:

str(hiv.Scatter)
List of 2
predictions:List of 3 .. : num [1:6] 0.0287 0.00648 0.00926 0.04352 0.01296 …
: num [1:6] 0.0287 0.00648 0.00926 0.04352 0.01296 ... .. : num [1:6] 0.0287 0.00648 0.00926 0.04352 0.01296 …
labels :List of 3 .. : num [1:6] 1 1 1 1 1 1
: num [1:6] 1 1 1 1 1 1 .. : num [1:6] 1 1 1 1 1 1
The data I used

dput(L)
c(1, 1, 1, 1, 1, 1)
dput(predictdata)
c(0.0287037037037037, 0.00648148148148148, 0.00925925925925926,
0.0435185185185185, 0.012962962962963, 0.00833333333333333)
Thanks for your help


#2

@xiong.pan you have not used k anywhere in the for loop. May be that’s why you are not getting the desired results.