#$$$$$$$$$$$$$$$$$$$$$ EXE 1.1 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$# ################################################# ############## 1.create vector ################ ################################################# # a. create a vector 20 numbers # b. assign a FALSE to the fifth element # what happens? # c. transform the vector into a matrix of 4 rows and 5 columns # in such a way that the last element of row 1 is 0 # d. generate a dataframe with 5 observations (i.e. rows) # and two variables (i.e. columns) # the first column is labeled gender and consists # of 2 boys and 3 girls (boy=1, girl=2) # the second column is labeled etnicity and has subsequent # values: Dutch, Surinamese, Turkish, Dutch, and Moroccan # e. add a third column labeled age: 15, 34, 62, 12, 74 # to the dataframe ################################################# ############## 2.inspect juul ################# ################################################# # install package ISwR and load into environment # the dataset juul is provided by ISwR ?juul # show first six lines of juul # show summary statistics of all variables in juul #$$$$$$$$$$$$$$$$$$$$$ EXE 1.2 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$# ################################################# ################# read datafile ################# ################################################# # set directory setwd("....") # note / instead of \ in windows setwd("....") # macs without C: getwd() # print the current working directory # look up function read.table in help (right lower pane) or use ?read.table # read the csv file using read.table # assign a name to the file # inspect dataset using head and summary ################################################# ################# explore data ################# ################################################# # what is the mean budget? # how many Comedy movies are there in percentages? # sort budget (high to low) # look up function 'sort' # order the dataset according to budget # look up function 'order' # look up the first 10 movies ################################################# ############### select cases ################## ################################################# # create subset of Mystery movies # in two ways using function 'subset' and without this function # select variables revenues, rating, screens & budget # check two solutions using function 'identical' ################################################# ################## write table ################ ################################################# # to write away a table use function 'write.table' # in a specified location with .csv extension # use arguments dec=".", sep=";" and row.names=FALSE # open the file from the specified location in excel # write away the same file with same arguments but now # with extension .txt and open it again in excel