Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Document preview thumbnail
Vista previa 2 fuera de 15 páginas
Resumen

Samenvatting Statistics for Psychologists, part 3 + R cheatsheet

Document preview thumbnail
Vista previa 2 fuera de 15 páginas

Samenvatting van alle hoofdstukken en simulations. Gemaakt voor het schakelprogramma van de master Psychologie voor het vak Statistics for Psychologists, part 3 voor de examenperiode van juni 2025. Zie de tags voor de verschillende onderwerpen. Het document heeft 14 bladzijdes en is gemaakt in mijn gebruikelijke sjabloon (gebruik van kleur en meestal volzinnen, maar een duidelijke structuur). Hierin staat de absolute theoretische basis van het vak, maar met de samenvatting te kopen krijg je ook toegang tot mijn cheatsheet voor R, een zeer uitgebreid en gedetailleerde opsomming en uitleg van alle nodige codes. Vergeet dus zeker geen oefeningen te maken. Let op! Deze samenvatting is in het Engels (net als het vak).

Vista previa del contenido

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

Información del documento

Estudio
Subido en
22 de mayo de 2025
Número de páginas
15
Escrito en
2024/2025
Tipo
Resumen
$8.98

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
Mellowerillish
4.3
(14)
Vendido
171
Seguidores
56
Artículos
41
Última venta
2 semanas hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes