由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 问一个很简单的R问题
相关主题
请教R Code, 多谢!R question
sas help, how to manipulating on the format valuewhich route in SAS is faster?
ask R code如何找出subject with extreme values
a R question包子求sas code
会R的麻烦进一下:R中怎么用SQL? 按道理不应该这么慢的。。。请教linear regression中的subset selection算法
问一个R的问题logistic regression issue
anybody use minitab?关于处理两个csv文件交集和子集的问题
求 imputation 后 出来的iteration 的数据作用How to rank variables in regression?
相关话题的讨论汇总
话题: gene话题: xxx话题: subj话题: value话题: zzz
进入Statistics版参与讨论
1 (共1页)
d*******1
发帖数: 854
1
R的书看了一些,但是具体到做事情还是没有头绪。 下面是问题:
有一个data:
subj gene value
1 xxx 10
1 yyy 11
1 zzz 12
2 xxx 34
2 yyy 45
2 zzz 67
在这里想要用gene xxx的value 对其他gene 的value 做regression (regression by
gene), 第一步先要merge 成下面那样的:
subj gene value xxx_value
1 xxx 10 10
1 yyy 11 10
1 zzz 12 10
2 xxx 34 34
2 yyy 45 34
2 zzz 67 34
谢谢
a********s
发帖数: 188
2
用rep() function生成新的列吧
D*********2
发帖数: 535
3
我也初学,给个 dirty way
m = number of types of gene, in your case, 3
n = number of subjects, in your case, 2
xxx_value <- rep(value[gene=="xxx"], rep(m, n))
D******n
发帖数: 2836
4
dat$xvalue<-rep(subset(dat,gene=='xxx')$value,each=3)

【在 a********s 的大作中提到】
: 用rep() function生成新的列吧
d*******1
发帖数: 854
5
这个data subj 和gene的次序可能都是乱的

【在 D*********2 的大作中提到】
: 我也初学,给个 dirty way
: m = number of types of gene, in your case, 3
: n = number of subjects, in your case, 2
: xxx_value <- rep(value[gene=="xxx"], rep(m, n))

d*******1
发帖数: 854
6
thanks. you use each=3, but i do not know the # of gene for each subj (they
may be different for each subj)

【在 D******n 的大作中提到】
: dat$xvalue<-rep(subset(dat,gene=='xxx')$value,each=3)
m********n
发帖数: 11
7
d1 = read.table('tmp.txt', header = TRUE, sep = ' ')
d2 = d1[d1$gene == 'xxx', c('subj', 'value')]
names(d2)[2] = 'xxx_value'
merge(d1, d2, by = 'subj')
1 (共1页)
进入Statistics版参与讨论
相关主题
How to rank variables in regression?会R的麻烦进一下:R中怎么用SQL? 按道理不应该这么慢的。。。
regression的时候提高自由度对模式有什么好处?问一个R的问题
请教关于简历anybody use minitab?
请问regression 分析求 imputation 后 出来的iteration 的数据作用
请教R Code, 多谢!R question
sas help, how to manipulating on the format valuewhich route in SAS is faster?
ask R code如何找出subject with extreme values
a R question包子求sas code
相关话题的讨论汇总
话题: gene话题: xxx话题: subj话题: value话题: zzz