2016-08-16 2 views
0

일반적으로 콘솔에 par()을 입력하면 par의 모든 기본 매개 변수 목록이 제공됩니다. 그러나 plot은 어떨까요? 시도 할 때 plot() 오류가 발생합니다. 이와 같은 기능에 대해 다른 점은 무엇입니까?plot() 함수의 기본 매개 변수

제네릭 기능과 관련이 있습니까? 내가 읽을 수있는 모든 자료를 가리 키도록하십시오.

+1

'도움 ("파") ' "파를 설정하는 데 사용 또는 ** 질문 ** 그래픽 매개 변수가 될 수있다 . " 'help ("plot")': "R 객체의 플롯을위한 일반 함수." – Roland

+0

비슷한 질문이 여기에 코멘트에 논의되었습니다 : http://stackoverflow.com/q/38958236/4770166 – RHertel

답변

2

예를 들어, args()formalArgs() 또는 formals()을 사용하면 함수의 인수 목록을 알 수 있습니다. args()

args(qplot) 
    # function (x, y = NULL, ..., data, facets = NULL, margins = FALSE, 
    #  geom = "auto", xlim = c(NA, NA), ylim = c(NA, NA), log = "", 
    #  main = NULL, xlab = deparse(substitute(x)), ylab = deparse(substitute(y)), 
    #  asp = NA, stat = NULL, position = NULL) 
    # NULL 

II를 사용

I.. 사용시 : formalArgs()

formalArgs(qplot) 
    # [1] "x"  "y"  "..."  "data"  "facets" "margins" "geom"  "xlim"  "ylim"  "log"  
    # [11] "main"  "xlab"  "ylab"  "asp"  "stat"  "position" 

III. R 콘솔에서 입력 ?qplot을 확인하고이 같은 인수가 있는지 여부를 도움말 페이지에서 확인하기 위해 다음

formals(qplot) 
    # $x 


    # $y 
    NULL 

    # $... 


    # $data 


    # $facets 
    # NULL 

    # $margins 
    # [1] FALSE 

    # $geom 
    # [1] "auto" 

    # $xlim 
    # c(NA, NA) 

    # $ylim 
    # c(NA, NA) 

    # $log 
    # [1] "" 

    # $main 
    # NULL 

    # $xlab 
    # deparse(substitute(x)) 

    # $ylab 
    # deparse(substitute(y)) 

    # $asp 
    # [1] NA 

    # $stat 
    # NULL 

    # $position 
    # NULL 

formals() 사용.

IV. par()에 대한 분석 및 options()

class(par) 
    # [1] "function" 
    class(par()) 
    # [1] "list" 
    class(plot) 
    # [1] "function" 
    class(plot()) 
    # Error in xy.coords(x, y, xlabel, ylabel, log) : 
    # argument "x" is missing, with no default 

    names(par()) 
    # [1] "xlog"  "ylog"  "adj"  "ann"  "ask"  "bg"  "bty"  "cex"  "cex.axis" 
    # [10] "cex.lab" "cex.main" "cex.sub" "cin"  "col"  "col.axis" "col.lab" "col.main" "col.sub" 
    # [19] "cra"  "crt"  "csi"  "cxy"  "din"  "err"  "family" "fg"  "fig"  
    # [28] "fin"  "font"  "font.axis" "font.lab" "font.main" "font.sub" "lab"  "las"  "lend"  
    # [37] "lheight" "ljoin"  "lmitre" "lty"  "lwd"  "mai"  "mar"  "mex"  "mfcol"  
    # [46] "mfg"  "mfrow"  "mgp"  "mkh"  "new"  "oma"  "omd"  "omi"  "page"  
    # [55] "pch"  "pin"  "plt"  "ps"  "pty"  "smo"  "srt"  "tck"  "tcl"  
    # [64] "usr"  "xaxp"  "xaxs"  "xaxt"  "xpd"  "yaxp"  "yaxs"  "yaxt"  "ylbias" 

par() 같은 기능의 다른 유사한 종류는, 나머지 매개 변수 사람들은 줄거리에 영향을 것입니다 par() 내부에 차례로 저장됩니다 지정 중 매개 변수의 목록을 가지고있는 기능입니다 자체 기본 설정이 있습니다. 호출 기능 options()

class(options) 
    # [1] "function" 
    class(options()) 
    # [1] "list" 

    head(names(options())) # List is bigger, just printing head of it 
    # [1] "add.smooth"   "browserNLdisabled" "CBoundsCheck"  "check.bounds"  "citation.bibtex.max" 
    # [6] "continue" 

비슷한 종류의 options()par() 같은

options() 
    $add.smooth 
    # [1] TRUE 

    # $browserNLdisabled 
    # [1] FALSE 

    # $CBoundsCheck 
    # [1] FALSE 

    # $check.bounds 
    # [1] FALSE 

    # $citation.bibtex.max 
    # [1] 1 

    # $continue 
    # [1] "+ " 

    # $contrasts 
    #   unordered   ordered 
    # "contr.treatment"  "contr.poly" 

    # $defaultPackages 
    # [1] "datasets" "utils"  "grDevices" "graphics" "stats"  "methods" 

    # $demo.ask 
    # [1] "default" 

    # $deparse.cutoff 
    # [1] 60 

    # $device 
    # function (width, height, pointsize, record, rescale, xpinch, 
    #  ypinch, bg, canvas, gamma, xpos, ypos, buffered, title, restoreConsole, 
    #  clickToConfirm, fillOddEven, family = "", antialias) 
    # { 
    #  check <- Sys.getenv("_R_CHECK_SCREEN_DEVICE_", "") 
    #  msg <- "screen devices should not be used in examples etc" 
    #  if (identical(check, "stop")) 
    #   stop(msg, domain = NA) 
    #  else if (identical(check, "warn")) 
    #   warning(msg, immediate. = TRUE, noBreaks. = TRUE, domain = NA) 
    #  new <- list() 
    #  if (!missing(width)) 
    #   new$width <- as.double(width) 
    #  if (!missing(height)) 
    #   new$height <- as.double(height) 
    #  if (!missing(pointsize)) 
    #   new$pointsize <- as.double(pointsize) 
    #  if (!missing(record)) 
    #   new$record <- record 
    #  if (!missing(rescale)) 
    #   new$rescale <- rescale 
    #  if (!missing(xpinch)) 
    #   new$xpinch <- as.double(xpinch) 
    #  if (!missing(ypinch)) 
    #   new$ypinch <- as.double(ypinch) 
    #  if (!missing(bg)) 
    #   new$bg <- bg 
    #  if (!missing(canvas)) 
    #   new$canvas <- canvas 
    #  if (!missing(gamma)) 
    #   new$gamma <- gamma 
    #  if (!missing(xpos)) 
    #   new$xpos <- as.integer(xpos) 
    #  if (!missing(ypos)) 
    #   new$ypos <- as.integer(ypos) 
    #  if (!missing(buffered)) 
    #   new$buffered <- buffered 
    #  if (!missing(title)) 
    #   new$title <- title 
    #  if (!missing(restoreConsole)) 
    #   new$restoreConsole <- restoreConsole 
    #  if (!missing(clickToConfirm)) 
    #   new$clickToConfirm <- clickToConfirm 
    #  if (!missing(fillOddEven)) 
    #   new$fillOddEven <- fillOddEven 
    #  if (!missing(antialias)) 
    #   new$antialias <- match.arg(antialias, aa.win) 
    #  d <- check.options(new = new, envir = .WindowsEnv, name.opt = ".Windows.Options", 
    #   reset = FALSE, assign.opt = FALSE) 
    #  rescale <- match(d$rescale, c("R", "fit", "fixed")) 
    #  if (is.na(rescale)) 
    #   stop("invalid value for 'rescale'") 
    #  antialias <- pmatch(d$antialias, aa.win) 
    #  invisible(.External(C_devga, "", d$width, d$height, d$pointsize, 
    #   d$record, rescale, d$xpinch, d$ypinch, d$canvas, d$gamma, 
    #   d$xpos, d$ypos, d$buffered, .PSenv, d$bg, d$restoreConsole, 
    #   d$title, d$clickToConfirm, d$fillOddEven, family, antialias)) 
    # } 
    # <bytecode: 0x0000000015330530> 
    # <environment: namespace:grDevices> 

    # $device.ask.default 
    # [1] FALSE 

    # $digits 
    # [1] 7 

    # $echo 
    # [1] TRUE 

    # $editor 
    # [1] "internal" 

    # $encoding 
    # [1] "native.enc" 

    # $example.ask 
    # [1] "default" 

    # $expressions 
    # [1] 5000 

    # $help.search.types 
    # [1] "vignette" "demo"  "help"  

    # $help.try.all.packages 
    # [1] FALSE 

    # $help_type 
    # [1] "html" 

    # $HTTPUserAgent 
    # [1] "R (3.3.0 x86_64-w64-mingw32 x86_64 mingw32)" 

    # $install.packages.compile.from.source 
    # [1] "interactive" 

    # $internet.info 
    # [1] 2 

    # $keep.source 
    # [1] TRUE 

    # $keep.source.pkgs 
    # [1] FALSE 

    # $lme4.summary.cor.max 
    # [1] 12 

    # $locatorBell 
    # [1] TRUE 

    # $mailer 
    # [1] "mailto" 

    # $max.print 
    # [1] 99999 

    # $menu.graphics 
    # [1] TRUE 

    # $mgcv.vc.logrange 
    # [1] 25 

    # $na.action 
    # [1] "na.omit" 

    # $nwarnings 
    # [1] 50 

    # $OutDec 
    # [1] "." 

    # $pager 
    # [1] "internal" 

    # $papersize 
    # [1] "letter" 

    # $pdfviewer 
    # [1] "C:/PROGRA~1/R/R-33~1.0/bin/x64/open.exe" 

    # $pkgType 
    # [1] "both" 

    # $prompt 
    # [1] "> " 

    # $repos 
    #          CRAN         CRANextra 
    # "https://mirrors.tuna.tsinghua.edu.cn/CRAN"  "http://www.stats.ox.ac.uk/pub/RWin" 

    # $scipen 
    # [1] 0 

    # $show.coef.Pvalues 
    # [1] TRUE 

    # $show.error.messages 
    # [1] TRUE 

    # $show.signif.stars 
    # [1] TRUE 

    # $str 
    # $str$strict.width 
    # [1] "no" 

    # $str$digits.d 
    # [1] 3 

    # $str$vec.len 
    # [1] 4 


    # $str.dendrogram.last 
    # [1] "`" 

    # $stringsAsFactors 
    # [1] TRUE 

    # $timeout 
    # [1] 60 

    # $ts.eps 
    # [1] 1e-05 

    # $ts.S.compat 
    # [1] FALSE 

    # $unzip 
    # [1] "internal" 

    # $useFancyQuotes 
    # [1] TRUE 

    # $verbose 
    # [1] FALSE 

    # $warn 
    # [1] 0 

    # $warning.length 
    # [1] 1000 

    # $width 
    # [1] 130 

    # $windowsTimeouts 
    # [1] 100 500 
+0

그게 어떻게 인자를 찾는 대답을하지만, 왜'plot' 함수는 기본 매개 변수의 목록을주지 않는다는 점에서 특별한가요? – emperorspride188

+1

@emperorspride : 어떤 함수는 그 안에'UseMethod'를 사용합니다. Plot은'plot' 메소드를 사용합니다. 차이가 있습니다. 곧 여기로 돌아올거야. –

+1

@ emperorspride188 R 콘솔에서'R-lang.pdf '로 저장된'R 언어 정의 '라는 pdf 파일을 참조하십시오. '도움말로 이동 -> 매뉴얼 (PDF) -> R 언어 정의 및 제 4 장 모든 설명이있는 몇 페이지의 기능을 참조하십시오 .' –