Create numeric vector that runs from 1 to 10 and let R print it. To create and print it right away, you need to enclose your statement with .
R solution -> dont' peek to early ;) !
(my_numeric_vector <-seq(1 , 10 ))
Now transform that vector so that it's 8th element is being multiplied by 4 and add 7 to it's second element. To access single elements of a vector, you need to use its index via .
R solution -> dont' peek to early ;) !
my_numeric_vector[c(8 , 2 )] <- c(my_numeric_vector[8 ] * 4 ,
my_numeric_vector[2 ] + 7 )
my_numeric_vector
Recode the continent variable into your language, or back to English. To do that, we use the function from the forcats package.
R solution -> dont' peek to early ;) !
conti <- fct_recode(conti,
"Europe" = "Europa" ,
"Afrique" = "Afrika" ,
"Asie" = "Asien" ,
"Amérique Sud" = "Suedamerika" )
table(conti)
Add Atlantis as another level. Now we need the function.
R solution -> dont' peek to early ;) !
conti <- fct_expand(conti, "Atlantis" )
table(conti)
Reorder the factor vector such, that Atlantis is shown first. Now we need the function.
R solution -> dont' peek to early ;) !
conti <- fct_relevel(conti, "Atlantis" )
table(conti)