zoukankan      html  css  js  c++  java
  • Advanced R之词汇表

    转载请注明出处:http://www.cnblogs.com/lizichao/p/4800513.html

    词汇表

      想要玩得转R,重要的一点是有一个好的工作词汇表。以下是我认为的一个好的词汇表。你不必熟悉每个函数的细节,但是你应该知道它们的存在。如果词汇表中的函数你没有听说过,我强烈建议你阅读下相关文档。

      我阅读了base包、stats包、untils包所有的函数,并提取了我认为最重要的函数,组成了下列的词汇表。列表中也有一些其他包中的重要函数,而且还有一些更加重要的,比如options()。

    基本函数

    # The first functions to learn
    ?
    str
    
    # Important operators and assignment
    %in%, match
    =, <-, <<-
    $, [, [[, head, tail, subset
    with
    assign, get
    
    # Comparison 
    all.equal, identical
    !=, ==, >, >=, <, <=
    is.na, complete.cases
    is.finite
    
    # Basic math
    *, +, -, /, ^, %%, %/%
    abs, sign
    acos, asin, atan, atan2
    sin, cos, tan
    ceiling, floor, round, trunc, signif
    exp, log, log10, log2, sqrt
    
    max, min, prod, sum
    cummax, cummin, cumprod, cumsum, diff
    pmax, pmin
    range
    mean, median, cor, sd, var
    rle
    
    # Functions to do with functions
    function
    missing
    on.exit
    return, invisible
    
    # Logical & sets 
    &, |, !, xor
    all, any
    intersect, union, setdiff, setequal
    which
    
    # Vectors and matrices
    c, matrix
    # automatic coercion rules character > numeric > logical
    length, dim, ncol, nrow
    cbind, rbind
    names, colnames, rownames
    t
    diag
    sweep
    as.matrix, data.matrix
    
    # Making vectors 
    c
    rep, rep_len
    seq, seq_len, seq_along
    rev
    sample
    choose, factorial, combn
    (is/as).(character/numeric/logical/...)
    
    # Lists & data.frames 
    list, unlist
    data.frame, as.data.frame
    split
    expand.grid
    
    # Control flow 
    if, &&, || (short circuiting)
    for, while
    next, break
    switch
    ifelse
    
    # Apply & friends
    lapply, sapply, vapply
    apply
    tapply
    replicate

    常见数据结构相关函数

    # Date time
    ISOdate, ISOdatetime, strftime, strptime, date
    difftime
    julian, months, quarters, weekdays
    library(lubridate)
    
    # Character manipulation 
    grep, agrep
    gsub
    strsplit
    chartr
    nchar
    tolower, toupper
    substr
    paste
    library(stringr)
    
    # Factors 
    factor, levels, nlevels
    reorder, relevel
    cut, findInterval
    interaction
    options(stringsAsFactors = FALSE)
    
    # Array manipulation
    array
    dim
    dimnames
    aperm
    library(abind)

    统计函数

    # Ordering and tabulating 
    duplicated, unique
    merge
    order, rank, quantile
    sort
    table, ftable
    
    # Linear models 
    fitted, predict, resid, rstandard
    lm, glm
    hat, influence.measures
    logLik, df, deviance
    formula, ~, I
    anova, coef, confint, vcov
    contrasts
    
    # Miscellaneous tests
    apropos("\.test$")
    
    # Random variables 
    (q, p, d, r) * (beta, binom, cauchy, chisq, exp, f, gamma, geom, 
      hyper, lnorm, logis, multinom, nbinom, norm, pois, signrank, t, 
      unif, weibull, wilcox, birthday, tukey)
    
    # Matrix algebra 
    crossprod, tcrossprod
    eigen, qr, svd
    %*%, %o%, outer
    rcond
    solve

     使用R

    # Workspace 
    ls, exists, rm
    getwd, setwd
    q
    source
    install.packages, library, require
    
    # Help
    help, ?
    help.search
    apropos
    RSiteSearch
    citation
    demo
    example
    vignette
    
    # Debugging
    traceback
    browser
    recover
    options(error = )
    stop, warning, message
    tryCatch, try

    输入/输出

    # Output
    print, cat
    message, warning
    dput
    format
    sink, capture.output
    
    # Reading and writing data
    data
    count.fields
    read.csv, write.csv
    read.delim, write.delim
    read.fwf
    readLines, writeLines
    readRDS, saveRDS
    load, save
    library(foreign)
    
    # Files and directories 
    dir
    basename, dirname, tools::file_ext
    file.path
    path.expand, normalizePath
    file.choose
    file.copy, file.create, file.remove, file.rename, dir.create
    file.exists, file.info
    tempdir, tempfile
    download.file, library(downloader)
  • 相关阅读:
    [leetcode]Longest Common Prefix
    [leetcode]Container With Most Water
    [leetcode]Regular Expression Matching
    [leetcode]Palindrome Number
    [leetcode]String to Integer (atoi)
    [leetcode]Reverse Integer
    [leetcode]ZigZag Conversion
    [leetcode]Longest Palindromic Substring
    [leetcode]Add Two Numbers
    poj 1228 Grandpa's Estate
  • 原文地址:https://www.cnblogs.com/lizichao/p/4800513.html
Copyright © 2011-2022 走看看