Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 7 pages
Summary

Samenvatting MLT01 - Statistiek R Studio

Document preview thumbnail
Preview 2 out of 7 pages

Veralgemeende scripts voor R Studio met uitleg die perfect gebruikt kunnen worden tijdens het open boek examen.

Content preview

Rstudio
# Eerst willen we controleren of we het pakket reeds geïnstalleerd hebben.

# In het schermpje rechtsonderaan zie je een tabblad "Packages". Hier kun je met het
vergrootglas rechtsboven in het schermpje zoeken naar het pakket.

# Indien het nog niet geïnstalleerd is dan kun je op de knop "Install" klikken

# En het gewenste pakket zoeken en installeren.

Pakket inladen in R
# Om een pakket te gebruiken moet je dit eerst inladen. Zoek bij "Packages" in het
schermpje onderaan naar het pakket dat je wilt gebruiken, klik daarna het hokje links
ervan aan.

Automatisch pakketten installeren en inladen.
# Laad de installed packages in 1 lijst

installed_packages <- installed.packages()

# Staat het pakket dat we willen installeren al geïnstalleerd? Sla dit op in een variable
'is_installed'

is_installed <- "openxlsx" %in% installed_packages

# Indien het pakket nog niet geïnstalleerd is

if (is_installed==FALSE){ install.packages("openxlsx")}

# Code die hier staat tussen {} wordt enkel uitgevoord wanneer het stukje tussen ()
waar is. In dit geval dus enkel als het pakket niet geïnstalleerd is.

# Laad het pakket in R

library(openxlsx)



#######################################################
#########################

### Inlezen van een dataset

#######################################################
#########################

Let er op: de functie 'read.xlsx' werkt enkel wanneer we het pakket 'openxlsx' van
hierboven hebben ingeladen.

# via Session > Set Working Directory > Choose Directory

# Een dataset in Excel formaat inlezen met read.xlsx

# Als de eerste lijn de kolom namen bevat (hoofding), kies je colNames = TRUE

# Als de data op een andere tabblad staat kun je ook sheet = aanpassen naar het
tabblad

naam_die_je_wil_geven <- read.xlsx("naam.xlsx",colNames = TRUE, sheet = 1)

# De namen van de kolommen opvragen

, colnames(naam)

# Hoeveel observaties zijn er en zijn het kwantitatieve of kwalitatieve resultaten?

str(naam)



#######################################################
#########################

### Basis statistiek

#######################################################
#########################

# standaard deviatie

sd(naam$kolomnaam)

# gemiddelde

mean(naam$kolomnaam)

# maximum waarde

max(naam$kolomnaam)

# minimum waarde

min(naam$kolomnaam)

# min, max, mediaan, gemiddelde en 1ste en 3de kwartiel (Qu.)

summary(naam$kolomnaam)



#######################################################
#########################

### Een staafdiagram (barplot) maken van een kwalitatieve variabele

#######################################################
#########################

# Maak eerst een frequentie tabel

freq.tabel <- table(naam$kolomnaam)

# De frequentie tabel zien

freq.tabel

# Gebruik deze frequentie tabel om een staafdiagram te maken

barplot(freq.tabel,

main = "naam grafiek",

names = c("naam staaf","naam staaf"))

Document information

Study
Uploaded on
February 11, 2022
Number of pages
7
Written in
2021/2022
Type
Summary
$4.62

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
latoyaloosveld
4.4
(19)
Sold
63
Followers
19
Items
31
Last sold
1 year ago


Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions