Saving results from for loop as a vector in r

后端 未结 3 608
孤街浪徒
孤街浪徒 2021-01-05 09:24

I have the following for loop which prints numbers from 1 to 10:

for (i in 1:10) {print (i) } 

How do I save the results as a vector, inst

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-05 09:38

    Alternatively

    my_vector = c()
    for(i in 1:5){my_vector=c(my_vector,i)}
    my_vector
    

提交回复
热议问题