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

Samenvatting Statistics for Psychologists, part 3 + R cheatsheet

Rating
-
Sold
-
Pages
15
Uploaded on
22-05-2025
Written in
2024/2025

Summary of all chapters and simulations. Created for the master's programme in Psychology for the course Statistics for Psychologists, part 3 for the June 2025 exam period. See the tags for the various topics. The document has 14 pages and is made in my usual template (using color and mostly full sentences, but with a clear structure). This contains the absolute theoretical basis of the course, but buying the summary also gives you access to my cheat sheet for R, a very comprehensive and detailed list and explanation of all the necessary codes. So don't forget to do exercises. Attention! This summary is in English (just like the course).

Show more Read less
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 22, 2025
Number of pages
15
Written in
2024/2025
Type
Summary

Subjects

Content preview

STAT3 – juni 2025 1




INTRODUCTION TO R

SIMPLE CALCULATIONS

ORDER OF OPERATION
R uses the BEDMAS order of operation:
1) Brackets ()
2) Exponents ^
3) Division / and Multiplication *
4) Addition + and Subtraction -
 If we want to force R to calculate, for example, the addition in a command first, we have to enclose it in
brackets

For operations on the same level (e.g. division and multiplication), R will go from left to right

VARIABLES
= a label for a certain piece of information, or even several different pieces of information
- To assign a value to a variable, we use the assignment operator <-, e.g. sales <- 350
• We can also use -> or = (e.g. 350 -> sales), but these are used less
▪ Be mindful of directionality! -> or <- point towards the variable, not the value, and only variable =
value works (not value = variable)
• This does not provide any output, but R will process this internally
• We can, however, check by typing the name of the variable and running this code
- R lets us overwrite, meaning that assigning a new, different value to the previously set variable name will
erase the memory of the first value
- We can do calculations with variables, e.g. sales * royalty will result in the same output as multiplying their
values alone
- Disclaimer: you cannot use spaces in variable names

VECTORS
= a variable that can store multiple values
- To assign multiple values to a variable, we use the combine function c(), e.g. sales.by.month <- c(0, 100,
200, 50, 0, 0, 0, 0, 0, 0, 0, 0)
• This creates a single variable that is a vector containing a number of elements
• The combine function can also be used with vectors, e.g. sales.by.month.extended <- c(sales.by.month,
99)
- To extract information from a vector (e.g. the number of sales in the month of February), we use square
brackets [], e.g. sales.by.month[2] will result in an output of 100
• We can also use the square brackets to alter elements of a vector, e.g. sales.by.month[5] <- 25
• We can add negative indices to remove certain elements, e.g. sales.by.month[-(2:3)] OR
sales.by.month[-c(2,3)] removes elements 2 to 3 in a vector
• We can use the logical operator !=, e.g. salesbymonth[sales.by.month != 0] removes all 0 sales
- We can shorthand a continuous vector by using : , e.g. 2:8 is the same as c(2, 3, 4, 5, 7, 8)
• This can be used both for assigning elements to a vector, altering or extracting information from it
• When replacing information, be aware of the amount of numbers you want replaced and the amount
of numbers in your input, e.g. sales.by.month[1:3] <- c(9, 19) tells R to replace the first three numbers
but only provides two, resulting in an error
• But beware that R does have a recycling rule! E.g. sales.by.month[1:4] <- c(9, 19) WILL work as it uses
“9” as a replacement for both the 1st and 3rd value

, STAT3 – juni 2025 2


- When we multiply/add/subtract/divide/take powers of a vector by a single number, all elements in the
vector get multiplied/added/subtracted/divided/taken powers of
- To quickly find out how many elements a vector has, use the length() function

The recycling rule means that R “recycles” the value of the shorter vector several
times, e.g. when y has a length of 2, as compared to x with a length of 6, then the
third element of x is added to the first element of y again and so on
- This rule also applies for subtraction, multiplication and division
- If the length of the longer vector is not an exact multiple of the length of the
shorter one (e.g. 5 and 2), R will still do it but give us a warning

WARNINGS AND ERRORS
Both errors and warning signal something is off
- When R throws an error, R couldn’t do what we asked it to do, so it stopped, producing no output
- With a warning, it powered through and produced output, but it thinks something could be off, so we
should look at the code and the output with extra care

LOGICAL DATA
A logical value is an assertion about whether something is true or false
- We can test this using the equality operator ==, e.g. 2 + 2 == 4 → TRUE
• This is different from the assignment operator = !
- R will output either TRUE or FALSE
- We can also assign the value directly, e.g. is.it.correct <- TRUE
• We can even shortcut using T and F (but only in capitals)
- We can also both assign logical values in a vector as use the equality operator to extract logical values from
a vector
- It is possible to use logical values in numerical operations, where true will change to a value of 1 and false
to a value of 0

OTHER LOGICAL OPERATORS




In the or operator, at least one of the statements needs to be true for R to return a TRUE-value

Get to know the seller

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.
Mellowerillish Katholieke Universiteit Leuven
Follow You need to be logged in order to follow users or courses
Sold
150
Member since
7 year
Number of followers
55
Documents
37
Last sold
4 days ago

Ik ben een studente van 25 jaar oud en ik verdien heel graag een centje meer. Al sinds de middelbare school deel ik vaak mijn samenvattingen met medeleerlingen in mijn klas, die ze altijd voor testen en examens gebruiken. Ik bied samenvattingen aan van mijn vorige opleidingen (Kleuteronderwijs aan de UCLL in Heverlee, en verkort traject Toegepaste Psychologie aan de Thomas More in Antwerpen) en van mijn huidige opleiding (schakel/master Psychologie aan de KU Leuven). Hou er rekening mee dat leerstof kan variëren met de jaren en lectoren; mogelijks komen oudere samenvattingen niet helemaal meer overeen met jouw leerstof. Kijk goed de tags na als het gaat om een ouder bestand. Aarzel niet om me een berichtje te sturen met vragen, feedback of opmerkingen! Als een freebie: hier de link naar mijn quizlet pagina met een flashcard set per vak van het schakelprogramma psychologie. Wachtwoord: quizlet

Read more Read less
4.4

12 reviews

5
6
4
5
3
1
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