Lezione 1 Flashcards
6 main rules
rm(list=ls())
Use # to comment
Set directory properly and check which files are available with function dir()
Before reading csv files check if data are separated by commas
Use str() function
use dots for decimal numbers instead of commas
How do I create new objects?
An = sign is always necessary to create new objects
I can print them on the console by just typing them in the script
setwd() and get()
Set and print the active folder on the console.
read.csv
Comma Separated Values
head(data)
Print on the console the first rows and columns of a dataframe
Environment
Left Side Toggle: see dataframe structure (str())
Right Side Tab: open new script with full table of data
Delete an object: grid mode=> broom emoji
Delete dataframe vector
dati_pinguini$X = NULL
Convert Vector from chr to num
dati$X = factor(dati$X)
Create vectors (2 ways)
v1=c(1,2,3,4)
v3 = seq(1,10, by = 0.1)
Second v1 element
Second and fourth v1 element
From the first to the third v1 element
v1[2]
v1[c(2,4)]
v1[1:3]
Calculate Quantile
quantile(dati$peso, c(0.25, 0.75))
Dispersion Indices
var(dati$peso)
sd(dati$peso)
IQR(dati$peso)
summary(data)
Prints out the main position indices on the console