由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - R一问
相关主题
R program help【欢迎进来讨论】for loop in R
[合集] 请问如何看到R的source code?How can I do this in R?
问个R里面avoid for loop的问题(sapply,lapply...)How to transpose a data frame in R
说说最近两次面试经历吧How to compute sum of revenue for each day each person in R?
再问随机取样的programming怎样用R找出unique的record
今天又“R”了 -- 感想和请教。如何把model fitting statistics 读出来(R)
R问题请教。Dashagen请进
怎样用apply对多种endpoint构建linear model[R]how to sample all possible continuous subset from ordered data
相关话题的讨论汇总
话题: data话题: cor话题: split话题: good话题: lapply
进入Statistics版参与讨论
1 (共1页)
D******n
发帖数: 2836
1
有一个dataframe叫data,里面有三列叫 id,x,y
怎么样比较快的算出每个id的cor(x,y)
s*r
发帖数: 2757
2
tapply?

【在 D******n 的大作中提到】
: 有一个dataframe叫data,里面有三列叫 id,x,y
: 怎么样比较快的算出每个id的cor(x,y)

s*****n
发帖数: 2174
3
sapply(split(data, data$id), function(t) cor(t$x, t$y))

【在 D******n 的大作中提到】
: 有一个dataframe叫data,里面有三列叫 id,x,y
: 怎么样比较快的算出每个id的cor(x,y)

t**i
发帖数: 688
4
by(data, data$id, function(t) cor(t$x, t$y))
D******n
发帖数: 2836
5
this is good but the output is "by" format

【在 t**i 的大作中提到】
: by(data, data$id, function(t) cor(t$x, t$y))
D******n
发帖数: 2836
6
thanks, good to know split. now i understand the list data type and apply se
ries better..

【在 s*****n 的大作中提到】
: sapply(split(data, data$id), function(t) cor(t$x, t$y))
t**i
发帖数: 688
7
do.call("rbind", by(...))

【在 D******n 的大作中提到】
: this is good but the output is "by" format
s*****n
发帖数: 2174
8
Yes, actually lapply+split is a common way to do "for"-type loop, but in a
much more efficient way. Other "apply"s are just wrappers of lapply.

se

【在 D******n 的大作中提到】
: thanks, good to know split. now i understand the list data type and apply se
: ries better..

m********n
发帖数: 11
9
想问一下songkun,DaShagen和其他熟悉R的xdjm,你们能不能推荐几本R教程?谢谢!
我个情况是,用过1年多R,会用各种apply;理解functional programming;C++/
Matlab系统学过,比较熟练;python/scheme也会一点,语法和模块不太熟悉;SAS会一
点,比较讨厌这种语言。以后做analysis打算都用R,想深入理解R和熟悉各种
functionality。
s*****n
发帖数: 2174
10
我觉得会用各种apply就至少算中级吧, 这种
情况下看书基本用处不大, 就得多用多实践了.

【在 m********n 的大作中提到】
: 想问一下songkun,DaShagen和其他熟悉R的xdjm,你们能不能推荐几本R教程?谢谢!
: 我个情况是,用过1年多R,会用各种apply;理解functional programming;C++/
: Matlab系统学过,比较熟练;python/scheme也会一点,语法和模块不太熟悉;SAS会一
: 点,比较讨厌这种语言。以后做analysis打算都用R,想深入理解R和熟悉各种
: functionality。

D******n
发帖数: 2836
11
manipulating data in R?
hehe, i dont quite have time to finish it though.

【在 m********n 的大作中提到】
: 想问一下songkun,DaShagen和其他熟悉R的xdjm,你们能不能推荐几本R教程?谢谢!
: 我个情况是,用过1年多R,会用各种apply;理解functional programming;C++/
: Matlab系统学过,比较熟练;python/scheme也会一点,语法和模块不太熟悉;SAS会一
: 点,比较讨厌这种语言。以后做analysis打算都用R,想深入理解R和熟悉各种
: functionality。

m********n
发帖数: 11
12
明白,谢谢!

【在 s*****n 的大作中提到】
: 我觉得会用各种apply就至少算中级吧, 这种
: 情况下看书基本用处不大, 就得多用多实践了.

m********n
发帖数: 11
13
Thanks! It seems that this book is good for me to understand some
fundamentals of R in depth.

【在 D******n 的大作中提到】
: manipulating data in R?
: hehe, i dont quite have time to finish it though.

1 (共1页)
进入Statistics版参与讨论
相关主题
[R]how to sample all possible continuous subset from ordered data再问随机取样的programming
这个R LOOP错在那里了今天又“R”了 -- 感想和请教。
R: cutR问题请教。
How to get rid of loop in R code?怎样用apply对多种endpoint构建linear model
R program help【欢迎进来讨论】for loop in R
[合集] 请问如何看到R的source code?How can I do this in R?
问个R里面avoid for loop的问题(sapply,lapply...)How to transpose a data frame in R
说说最近两次面试经历吧How to compute sum of revenue for each day each person in R?
相关话题的讨论汇总
话题: data话题: cor话题: split话题: good话题: lapply