由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 如何在R里refer上一个row的值
相关主题
SAS问题来了再来问一个SAS问题
SAS问题A SAS question
请问R Code和 Matlab Code 思路是否近似?SAS question - baozi
请教一个SAS小问题:如何得到 one cumulative varialbe of character variable?请教SAS LABEL问题。
SAS question: count non-missing value for different variablesSAS question - baozi
[合集] how to calculate column sum not row sum in SAS? thanks a lo急问一个call symput问题(SAS)
SAS 请教一个SAS的时间区域求值问题
Ask 2 simple SAS questions,thanks双包子求教:SAS问题
相关话题的讨论汇总
话题: row话题: data话题: refer话题: var2话题: mean
进入Statistics版参与讨论
1 (共1页)
h******3
发帖数: 190
1
多谢!
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) 的大作中提到: 】
1 (共1页)
进入Statistics版参与讨论
相关主题
双包子求教:SAS问题SAS question: count non-missing value for different variables
弱问一个SAS里面求adjusted means的问题[合集] how to calculate column sum not row sum in SAS? thanks a lo
我也来请教一个SAS问题SAS 请教
SAS helpAsk 2 simple SAS questions,thanks
SAS问题来了再来问一个SAS问题
SAS问题A SAS question
请问R Code和 Matlab Code 思路是否近似?SAS question - baozi
请教一个SAS小问题:如何得到 one cumulative varialbe of character variable?请教SAS LABEL问题。
相关话题的讨论汇总
话题: row话题: data话题: refer话题: var2话题: mean