100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Summary

summary statistics 3

Rating
-
Sold
1
Pages
70
Uploaded on
13-05-2025
Written in
2024/2025

This is a summary of the 12 chapters we had to read in Studio.r. I added extra info if something wasn't clear. It also contains many photos so you always know which code to enter.

Institution
Course











Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Study
Course

Document information

Uploaded on
May 13, 2025
Number of pages
70
Written in
2024/2025
Type
Summary

Subjects

Content preview

Statistiek 3
Hst 2: getting started with R
2.1 Typing commands
 G typo’s
 Spacing maakt n uit/ tenzij in een woord

add 10 + 20
Substract 10-20
R-handleiding citeren Citation ()

2.2 Doing simple calculations
 Vb operation = addition
- Operator = +




 Order of operations: BEDMAS
- Brackets ()
- Exponents ^
- Devision / and Multiplication *
- Addition + and Substraction –

2.3. Storing a nr as a variable
Assign a value to variable: assignment operator Sales <- 350
350 -> sales
Sales < - 350
Sales = 350
350 = sales


2.4. Working with variables
Assign new value to variable Sales <- 250
Sales

2.5. Doing calculations using variables
Multiplication Sales <- 350

1

, Royalty <- 7
----------------------------------------------------------------
Sales * royalty (= 350 * 7)
Assign output calculation to new variable Revenue <- sales * royalty
Revenue
Overwrite previous value (donation of 550 €) Revenue <- revenue + 550
Revenue


2.6. Storing many nr’s as a vector
 Vector = variable that can store multiple values
- Between ( )  elements (12 in vb)

Combine function C () Sales.by.month <- c(0, 100, 200, 50, 0, 0, 0, 0, 0, 0, 0, 0)
Sales.by.month


 Flexible with c ()  works on nr’s and vectors at the same time

Add sales in a new month Sales.by.month.extended <- c(sales.by.month, 99)
Sales.by.month.extended
C( ) wordt gebruikt voor

 Data te groeperen in een vector
 Dataset te maken en te verwerken
 Rekenen met meerdere getallen tegelijk

2.7. Working with a vector
Get info out of a vector Sales.by.month[2]
- boeken in feb
Create new variables February.sales <- sales.by.month[2]
February.sales
Get access to more elements Sales.by.month[c(1,2,3)]
Change a value stored in a vector Sales.by.month[5] <- 25
- 25 extra boeken in mei Sales.by.month


Sales.by.month [c(1,2,3,4,5,6)] Sales.by.month [1:6]




Use it to alter (wijzig) elements of a vector Sales.by.month[3:7] <- 2
Sales.by.month


2

,  3 nr’s wijzigen en je geeft er twee lukt niet
 4 wijzigen en je geeft er 2 lukt wel  recycling rule




2.8. Doing calculation with vectors
Alter all the elements of a vector at once (+/*-) Sales.by.month * 7
- = profit ----------------------------------------------------------------
0 700 1400 350 0 0 0 0 0 0 0 0
Bonus 1€ in jan, 2 in feb… Bonus <- 1:12
- The nth element of bonus is added Bonus
to the nth element of profit
Profit_bonus <- profit + bonus
Profit_bonus
---------------------------------------------------------------
1 702 1403 354 5 6 7 8 9 10 11 12
Wil weten hoeveel geld je per dag krijgt Days.per.month <- c(31, 28, 31, 30, 31, 30, 31,
- Divide every element of profit by 30, 31, 30, 31, 30, 31)
the corresponding element of
days.per.month Profit/days.per.month



The recycling rule




 R has recycled the value of the shorter vector Y several times
- The first element of x is added to the first element of y
- Second element of x is added to the second element of y
- Third element of x  isn’t any corresponding element in y  returns to the beginning
 R also does it when the length of the longer vector isn’t an exact multiple of the length of the shorter one
- Gives warning, but we will ignore it



3

, 2.9. Using functions to do calculations
Square root function Sqrt ()
225th element of sqrt Sqrt []
Absolute value function Abs ()
Use a function to do something Calling the function
Values typed into the function Arguments of that functions
1. Calculate value abs (-8)



2. Sqrt (1 + 8)

Sqrt (c (25, 49, 36)) 576
Does it on each element separately = vector element-wise
Know how many elements there are in a vector length ()


2.10 Combining stuff and the work-from-within-rule
Sqrt( abs(-25) ) First take the absolute value of -25 and then take the
square root
= work-from-within-rule




4
$12.72
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
mirtedeboeck

Get to know the seller

Seller avatar
mirtedeboeck Thomas More Hogeschool
Follow You need to be logged in order to follow users or courses
Sold
1
Member since
1 year
Number of followers
0
Documents
4
Last sold
8 months ago

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right 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 aced it. It really can be that simple.”

Alisha Student

Frequently asked questions