coursera R Programming NOTE(6)

1348 단어

loop functions

lapply(list,function) example:
x 
sapply(list,function) The sapply() function behaves similarly to lapply()
  • If the result is a list where every element is length 1, then a vector is returned
  • If the result is a list where every element is a vector of the same length (> 1), a matrix is returned.
  • If it can’t figure things out, a list is returned
  • tapply(vector,INDEX,function)
  • INDEX is a factor or a list of factors (or else they are coerced to factors) example:
  • x 
    apply(array,dims,function) example:
     x 

    Col/RowSumsandMeans
    rowSums = apply(x, 1, sum)
    rowMeans = apply(x, 1, mean)
    colSums = apply(x, 2, sum)
    colMeans = apply(x, 2, mean)
    
    mapply(function,argument1,argument2,argument3...) example:
    mapply(rep, 1:4, 4:1)
    ## "1:4" is the first argument of function "rep"
    ## "4:1" is the second argument of function "rep"
    
    noise 
    split(vector or list or data frame,factor) The split() function takes a vector or other objects and split sitin to groups determined by a factor or list of factors. example:
     x 

    좋은 웹페이지 즐겨찾기