Pakiety R

Intermediate R

Filip Schouwenaars

DataCamp Instructor

Pakiety R

  • Skąd pochodzą mean(), list() i sample()?
  • Są częścią pakietów R
  • Kod, dane, dokumentacja i testy
  • Łatwe do udostępniania
  • Przykłady: base, ggvis
Intermediate R

Instalowanie pakietów

  • Pakiet base: instalowany automatycznie
  • Pakiet ggvis: jeszcze nie zainstalowany

    install.packages("ggvis")
    
  • CRAN: Comprehensive R Archive Network

Intermediate R

Ładowanie pakietów

  • ładowanie pakietu = dołączenie do listy wyszukiwania
    search()
    
".GlobalEnv"  ...  "Autoloads"   "package:base"
  • Domyślnie dołączonych jest 7 pakietów
  • ggvis nie jest dołączony domyślnie
ggvis(mtcars, ~wt, ~hp)
Error: could not find function "ggvis"
Intermediate R

Ładowanie pakietów: library()

library("ggvis")
search()
".GlobalEnv"  "package:ggvis" ... "package:base"
ggvis(mtcars, ~wt, ~hp)

Intermediate R

Ładowanie pakietów: require()

library("data.table")
Error in library("data.table") : 
there is no package called 'data.table'
require("data.table")
Loading required package: data.table
Warning message: ...
Intermediate R

Ładowanie pakietów: require()

result <- require("data.table")
Loading required package: data.table
Warning message: ...
result
FALSE
Intermediate R

Podsumowanie

  • Instalowanie pakietów: install.packages()
  • Ładowanie pakietów: library(), require()
  • Załadowanie pakietu = dołączenie do listy wyszukiwania
  • Szukaj ciekawych pakietów R w Google!
Intermediate R

Czas na ćwiczenia!

Intermediate R

Preparing Video For Download...