what different data types do you know and how to transform into these data types?
Numeric -> X = 42.3
Character -> X = as.character(“Hi”) <- don’t forget ““
Integer -> X = as.integer(42)
Logical -> X = TRUE
and how can you check the class of a variable?
Check the class -> class(X) or specific: is.integer/numeric
how to build a vector
x = C(1,2,3,4)
difference between array, and date a frame
Arrays:
Multi dimensional
Fixed size
Homogenous elements
Lists
1 dimensional
Dynamic size
Heterogenous –> elements of different data types
Dataframe
Two dimensional tabulat strcuture
Columns have diff datatypes but each column is homogenous
Flexible size
my.factor <- factor(c("medium", "rare", "rare")
what happen when you use
levels(my.factor)
length(my.factor)
levels(my.factor) => "medium", "rare", "rare"
length(my.factor) => 3
creat a factor and more levels afterwards and delete the levels at last
my.factor <- factor(c("medium", "rare", "rare"),
levels(“medium”, “janistdoof”, “rare”)
droplevel(my.factor)
Build a matrix with 3 rows and 2 columns
my.matrix <- matrix(
c(1,2,3,4,5,6), nrow = 3, ncol = 2, byrow = TRUE)
what happens when you use byrow = FALSE in a matrix?
TRUE = sorted by rows
FALSE = sorted by columns
vector <- c("A","B","C")
wie kannst du dir nur B anzeigen lassen
wie kann du dir eine range anzeigen lassen
vector[2] → "B"
vector[2:3] → "B", "C" / vector[c(2,3)] → "B", "C"
was erhältst du bei folgenden codes:
my.matrix[1,1]
my.matrix[1,]
my.matrix[,1]
my.matrix[1,2]
my.matrix[1,1] => oben links
my.matrix[1,] => 1. Spalte
my.matrix[,1] => 1. Zeile
my.matrix[1,2] => 1. Zeile
Was benötigt man alles für Conjoint Analysis?
Tabelle mit den einzelnen levels name-> tlevel
-> tpf
Matrix mit allen pref zu den einzelnen profiles -> tprefm
Matrix mit pref der attribute profiles -> tprof
-> tsimp
caModel(y=tprefm[1,], x=tprof)
caUtilities(y=tprefm[1,], x=tprof, z=tlevn)
caPartUtilities(y=tprefm[1:6,], x=tprof, z=tlevn)
Last changed5 months ago