close

撒丁語翻譯

文章標籤
R軟體 R說話 中華R軟體學會 資料分析 統計程式 統計資料 統計軟體 開放源碼

attach 資料框後,在 detach 之前都可直接取用資料框中所有變數翻譯

> attach(Duncan)
> prestige
[1] 82 83 90 76 90 87 93 90 52 88 57 89 97 59 73 38 76 81 45 92 39 34 41 16 33 53 67 57 26 29 10 15 19 10 13 24
[37] 20 7 3 16 6 11 8 41 10
> detach(Duncan)

資料框名後接串列取值字元($)加變數名後果以下:

> library(car)
> head(Duncan)

Call:
lm(formula = prestige ~ income + education, data = Duncan)

Coefficients:
(Intercept)     income   education
  -6.0647        0.5987   0.5458

> with(Duncan, {
+ plot(education, prestige)
+ identify(education, prestige, row.names(Duncan))
+ })

R1   
  參考資料:Fox翻譯社 J. and Weisberg, S. (2011), An R Companion to Applied Regression翻譯社 2nd Edition,Sage.

                   type income education prestige
accountant prof     62           86           82
pilot            prof     72           76           83
architect     prof     75           92           90
author        prof     55           90           76
chemist       prof     64           86          90
minister      prof      21           84          87

固然,我們也能夠行使 R 中很多統計建模函數的 data 參數,其效果與前面的 with 指令溝通。
> (lm(prestige ~ income + education, data = Duncan))

> with(Duncan翻譯社 Duncan[type == "bc" & income > mean(income), ])
                            type income education prestige
electrician                bc       47         39           53
RR.engineer            bc       81         28           67
plumber                   bc       44         25           29
streetcar.motorman bc       42         26           19

Call:
lm(formula = prestige ~ income + education)

Coefficients:
(Intercept)  income   education
-6.0647       0.5987   0.5458

> summary(Duncan)
type      income              education           prestige
bc :21    Min. : 7.00        Min. : 7.00          Min. : 3.00
prof:18  1st Qu.:21.00   1st Qu.: 26.00    1st Qu.:16.00
wc : 6    Median :42.00   Median : 45.00   Median :41.00
              Mean :41.87     Mean : 52.56      Mean :47.69
              3rd Qu.:64.00   3rd Qu.: 84.00    3rd Qu.:81.00
              Max. :81.00       Max. :100.00       Max. :97.00

最後,掏出部分子集與資料繪圖等工作也可搭配 with 指令來利用,此處互動式畫圖的後果並未顯示於圖面上。

以下是一些不贊同 attach 的來由:起首是附加上之資料框變數會遮罩住其它同名的變數;再
者,attach 是將資料框一時的快照(snapshot)複本,附加在全域情況(global environment)之後,
萬一資料框有所更改,是不會反應在其複本上;最後,使用者常常會忘掉 detach 臨時不消的
資料框,徒增資料分析進程的雜沓。是以,避免附加資料框到搜索路徑的做法除了前述的全
名援用外,也能夠用 with 指令,使得 R 在該資料框環境下評析後續的指令。

> with(Duncan翻譯社 mean(prestige))
[1] 47.68889
> with(Duncan, lm(prestige ~ income + education))

[1] 1 3 4 6 10 12 15 20

最近在學會(http://www.r-software.org/)的台灣 R 軟體利用者論壇上有人提起 attach 指令,讓天成翻譯公司想起前一陣子看到的 with 指令翻譯曩昔我們經常使用 attach 指令,將資料框物件附加到搜尋路徑(search path)上,使得資料框中的變數對於 R 的直譯器(interpreter)而言是可見的(visible),省去須敲擊資料框全名方能援用變數的麻煩!以 car 套件中的資料框 Duncan 為例,

撰文者:
鄒慶士 博士
現任:
北商資訊與決議計劃科學所傳授
中華 R 軟體學會理事長
信箱:
vince.tsou@gmail.com

> Duncan$prestige
[1] 82 83 90 76 90 87 93 90 52 88 57 89 97 59 73 38 76 81 45 92 39 34 41 16 33 53 67 57 26 29 10 15 19 10 13 24
[37] 20 7 3 16 6 11 8 41 10
> mean(Duncan$prestige)
[1] 47.68889



本文來自: http://cars2012.pixnet.net/blog/post/21906627-r%e8%bb%9f%e9%ab%94%e4%b8%ad%e7%9a%84attach-%e8%88%87%有關各國語文翻譯公證的問題歡迎諮詢天成翻譯公司02-77260931
arrow
arrow
    文章標籤
    翻譯社
    全站熱搜
    創作者介紹
    創作者 dorothjw237f 的頭像
    dorothjw237f

    這裡是和dorothjw237f@outlook.com有關的地盤,歡迎到訪我的BLOG!

    dorothjw237f 發表在 痞客邦 留言(0) 人氣()