## The following objects are masked from 'package:ggplot2':
##
## geom_errorbarh, GeomErrorbarh
##
## New to ggformula? Try the tutorials:
## learnr::run_tutorial("introduction", package = "ggformula")
## learnr::run_tutorial("refining", package = "ggformula")
## Loading required package: mosaicData
## Loading required package: Matrix
## Registered S3 method overwritten by 'mosaic':
## method from
## fortify.SpatialPolygonsDataFrame ggplot2
##
## The 'mosaic' package masks several functions from core packages in order to add
## additional features. The original behavior of these functions should not be affected by this.
##
## Note: If you use the Matrix package, be sure to load it BEFORE loading mosaic.
##
## Have you tried the ggformula package for your plots?
##
## Attaching package: 'mosaic'
## The following object is masked from 'package:Matrix':
##
## mean
## The following object is masked from 'package:ggplot2':
##
## stat
## The following objects are masked from 'package:dplyr':
##
## count, do, tally
## The following objects are masked from 'package:stats':
##
## binom.test, cor, cor.test, cov, fivenum, IQR, median,
## prop.test, quantile, sd, t.test, var
## The following objects are masked from 'package:base':
##
## max, mean, min, prod, range, sample, sum
Comments on R script
不要顯示程式碼、程式碼要執行
環境設定:超過一行的字串用" "、顯示三個位數、控制顯示寬度
讀取檔案、使用dplyr、選取變項
顯示檔案變項名稱、顯示檔案前十個變項的資料
描述前十個變項:最大值、最小值、平均數、中位數、第一、三四分位數
從頭顯示前三筆資料
對newds做解釋與命名,並儲存
讀取資料
載入foreign套件,讀取檔案
讀取newds檔案前十筆資料
讀取newds檔案大於56的資料
載入dplyr套件,挑選大於56的資料,並顯示id
排序前四筆資料、最小值在第199個位置
載入mosaic套件,分組計數f1g的缺失值,對f1g做描述性統計
編碼cesditems
計算na個數
將cesditems設定為0,計算扣除後的總數,設定imputemeancesd的計算方式
列出上述資料表格
不希望跑出訊息,載入套件
新增&定義abstinent、moderate、highrisk
不要顯示程式碼,載入套件
不要顯示程式碼,卸除套件
載入套件,選擇變項,檢視365~370筆資料
載入套件,選擇飲酒程度moderate的女性
不希望跑出訊息,載入套件,呈現飲酒程度次數分配表
呈現飲酒程度與性別的次數分配表
創立“Male”,“Female”變項,計算個數
載入套件,排序資料,顯示1~5筆
載入套件,選出女性,計算cesd的平均
計算female(包含Male, Female)的cesd平均