全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
3877 3
2010-04-04
现在有一个例子:

> data(cathedral)
> cathedral
style x y
Durham r 75 502
Canterbury r 80 522
....etc....
Old.St.Paul g 103 611
Salisbury g 84 473
> lapply(split(cathedral,cathedral$style),summary)
$g
style x y
g:16 Min. : 45.0 Min. :182
r: 0 1st Qu.: 60.8 1st Qu.:299
Median : 73.5 Median :412
Mean : 74.9 Mean :397
3rd Qu.: 86.5 3rd Qu.:481
Max. :103.0 Max. :611
$r
style x y
g:0 Min. :64.0 Min. :344
r:9 1st Qu.:70.0 1st Qu.:425
Median :75.0 Median :502
Mean :74.4 Mean :475
3rd Qu.:80.0 3rd Qu.:530
Max. :83.0 Max. :551

请问lapply(split(cathedral,cathedral$style),summary)是干嘛用的?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2010-4-4 19:04:32
data(cathedral)
25 obs
3  variables
   style a factor with levels g, Gothic, r, Romanesque
   x  nave height
   y  total length in feet

split():Divide into Groups and Reassemble
> cathedral
                    style   x   y
Durham            r  75 502
Canterbury       r  80 522
Gloucester       r  68 425
Hereford           r  64 344
Norwich            r  83 407
Peterborough  r  80 451
St.Albans          r  70 551
Winchester       r  76 530
Ely                      r  74 547
York                   g 100 519
Bath                   g  75 225
Bristol               g  52 300
Chichester       g  62 418
Exeter                g  68 409
GloucesterG    g  86 425
Lichfield            g  57 370
Lincoln              g  82 506
NorwichG         g  72 407
Ripon                g  88 295
Southwark        g  55 273
Wells                 g  67 415
St.Asaph           g  45 182
WinchesterG    g 103 530
Old.St.Paul       g 103 611
Salisbury          g  84 473

> split(cathedral,cathedral$style)
$g
                style   x   y
York            g 100 519
Bath            g  75 225
Bristol         g  52 300
Chichester      g  62 418
Exeter          g  68 409
GloucesterG     g  86 425
Lichfield       g  57 370
Lincoln         g  82 506
NorwichG    g  72 407
Ripon           g  88 295
Southwark   g  55 273
Wells            g  67 415
St.Asaph      g  45 182
WinchesterG     g 103 530
Old.St.Paul     g 103 611
Salisbury        g  84 473

$r
             style  x   y
Durham           r 75 502
Canterbury       r 80 522
Gloucester       r 68 425
Hereford         r 64 344
Norwich          r 83 407
Peterborough     r 80 451
St.Albans        r 70 551
Winchester       r 76 530
Ely              r 74 547
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-4-5 22:28:12
'split' divides the data in the vector 'x' into the groups defined
     by 'f'.  The replacement forms replace values corresponding to
     such a division.  'unsplit' reverses the effect of 'split'.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-4-6 09:39:53
谢谢!
呵呵,你也阅读了那本书啊。对了上次你给我推荐的那篇英文资料看不懂啊,我的统计学基础不是很好,能告诉我这篇文献大概是再说明什么问题吗?好像涉及对应于任何一点的协方差分析?
(Difficultiues of interpreting mult-slpe analysis of covariance from statistical computer packages)
我正在写一篇论文,但是不晓得方法对不对。
我的邮箱是peijianshi@gmail.com
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群