当前位置: 动力学知识库 > 问答 > 编程问答 >

How can I assign values in R using row numbers?

问题描述:

I have a data frame and I would like to assign a particular value (Say "water") to all elements with row numbers from 10-100 and column 5. I would do the same for another row range of 500-600 in the same column 5.

I can do this separately as I have to do it only 3-4 times. Please let me know how to do it.

Thanks.

网友答案:

This could be done with:

dat[c(10:100, 500:600), 5] = "water"

(Where dat is your data frame).

分享给朋友:
您可能感兴趣的文章:
随机阅读: