R Basisquellen:

Auf folgender Referenzkarte finden sich die grundlegenden Funktionen in R: https://cran.r-project.org/doc/contrib/Baggott-refcard-v2.pdf

R Datenstruktur:

D1 <- c(1,2,3) #f?r heterogene Daten list
D2 <- matrix(1:6, ncol = 3, nrow = 2) #f?r heterogene Daten data.frame
D3 <- array(0, dim = c(2, 2, 3))
class(D1);class(D2);class(D3)
## [1] "numeric"
## [1] "matrix" "array"
## [1] "array"

R Beispiel linerares Modell

plot(diamonds$price ~ diamonds$carat)

lm.price_carat <- lm(data = diamonds, formula = price ~ carat)
summary(lm.price_carat)
## 
## Call:
## lm(formula = price ~ carat, data = diamonds)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -18585.3   -804.8    -18.9    537.4  12731.7 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -2256.36      13.06  -172.8   <2e-16 ***
## carat        7756.43      14.07   551.4   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1549 on 53938 degrees of freedom
## Multiple R-squared:  0.8493, Adjusted R-squared:  0.8493 
## F-statistic: 3.041e+05 on 1 and 53938 DF,  p-value: < 2.2e-16
plot(lm.price_carat, which=1)

lm hat Attribute und geh?rt einer Umgebung an

attributes(lm.price_carat)
## $names
##  [1] "coefficients"  "residuals"     "effects"       "rank"         
##  [5] "fitted.values" "assign"        "qr"            "df.residual"  
##  [9] "xlevels"       "call"          "terms"         "model"        
## 
## $class
## [1] "lm"
where("lm.price_carat")
## <environment: R_GlobalEnv>

summary und plot sind jeweils generische Funktionen

methods(generic.function = "summary")
##  [1] summary,ANY-method                  summary,DBIObject-method           
##  [3] summary.aov                         summary.aovlist*                   
##  [5] summary.aspell*                     summary.check_packages_in_dir*     
##  [7] summary.connection                  summary.data.frame                 
##  [9] summary.Date                        summary.default                    
## [11] summary.ecdf*                       summary.factor                     
## [13] summary.ggplot*                     summary.glm                        
## [15] summary.hcl_palettes*               summary.infl*                      
## [17] summary.lm                          summary.loess*                     
## [19] summary.manova                      summary.matrix                     
## [21] summary.mlm*                        summary.nls*                       
## [23] summary.packageStatus*              summary.POSIXct                    
## [25] summary.POSIXlt                     summary.ppr*                       
## [27] summary.prcomp*                     summary.princomp*                  
## [29] summary.proc_time                   summary.rlang:::list_of_conditions*
## [31] summary.rlang_error*                summary.rlang_message*             
## [33] summary.rlang_trace*                summary.rlang_warning*             
## [35] summary.srcfile                     summary.srcref                     
## [37] summary.stepfun                     summary.stl*                       
## [39] summary.table                       summary.tukeysmooth*               
## [41] summary.vctrs_sclr*                 summary.vctrs_vctr*                
## [43] summary.warnings                   
## see '?methods' for accessing help and source code
methods(generic.function = "plot")
##  [1] plot,ANY-method     plot,color-method   plot.acf*          
##  [4] plot.data.frame*    plot.decomposed.ts* plot.default       
##  [7] plot.dendrogram*    plot.density*       plot.ecdf          
## [10] plot.factor*        plot.formula*       plot.function      
## [13] plot.ggplot*        plot.gtable*        plot.hcl_palettes* 
## [16] plot.hclust*        plot.histogram*     plot.HoltWinters*  
## [19] plot.isoreg*        plot.lm*            plot.medpolish*    
## [22] plot.mlm*           plot.ppr*           plot.prcomp*       
## [25] plot.princomp*      plot.profile.nls*   plot.R6*           
## [28] plot.raster*        plot.spec*          plot.stepfun       
## [31] plot.stl*           plot.table*         plot.trans*        
## [34] plot.ts             plot.tskernel*      plot.TukeyHSD*     
## see '?methods' for accessing help and source code

weitere Quellen:

Die Cheatsheets in R bieten einen kompakten Überblick: https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf