h******3 发帖数: 190 | |
o**m 发帖数: 828 | 2 .Last.value ?
【在 h******3 的大作中提到】 : 多谢!
|
h******3 发帖数: 190 | 3 这是SAS吧。。。
【在 o**m 的大作中提到】 : .Last.value ?
|
a***d 发帖数: 336 | 4 try it in R~ I just did, it seems to return results from the previous command. what do you mean by 上一个row的值 啊?
【在 h******3 的大作中提到】 : 这是SAS吧。。。
|
h******3 发帖数: 190 | 5 I see. Sorry, I did not express this clearly.I want to refer to the last
value in a column in a data frame. For instance, var1[(var2 in the last row)
==1, ]
我也试了一下这个.Last.value.确实可以显示。虽然不是我想要做的。多谢!:P
command. what do you mean by 上一个row的值 啊?
【在 a***d 的大作中提到】 : try it in R~ I just did, it seems to return results from the previous command. what do you mean by 上一个row的值 啊?
|
Y****a 发帖数: 243 | 6 by 'last row', you mean 'previous row' or 'final row'? |
t*******t 发帖数: 633 | 7 想到这个笨方法,抛砖引玉吧。
for (i in 2:dim(data)[1]){
data_out[i]<-data[data$var2[i-1]==1,]$var1[i]}
row)
【在 h******3 的大作中提到】 : I see. Sorry, I did not express this clearly.I want to refer to the last : value in a column in a data frame. For instance, var1[(var2 in the last row) : ==1, ] : 我也试了一下这个.Last.value.确实可以显示。虽然不是我想要做的。多谢!:P : : command. what do you mean by 上一个row的值 啊?
|
k*******a 发帖数: 772 | 8 index<-sapply(2:dim(data)[1],function(x) (data$var2[x] %in% data[x-1,]))
subdata<-data[c(FALSE,index),] |
|
h******3 发帖数: 190 | 9 thanks.后来发现一个叫shift.vector()的function可以用
在 kirklanda (kirkland) 的大作中提到: 】 |