Create composite object types
In this exercise you will investigate different types of data objects. There are four objects loaded for you in your environment: vectors numvec1, numvec2, charvec and logicvec which each have 3 elements.
numvec1is a numeric vector with values 1, 2, 3;numvec2is a numeric vector with values 5, 2, 3;charvecis a character vector with values "red", "green", "blue";logicvecis a logical vector with values TRUE, TRUE, FALSE.
You can view each by typing the name of the object in the console. You will use these objects to create two new composite objects:
- a numeric matrix
nummtx - a dataframe
dataframe
Deze oefening maakt deel uit van de cursus
R For SAS Users
Oefeninstructies
- Create a numeric matrix named
nummtxwith numeric vectorsnumvec1andnumvec2which has 2 columns and 3 rows. - Create a dataframe named
dataframefrom the four vectorsnumvec1,numvec2,charvecandlogicvec. - Get the structure of the dataframe
dataframe.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Create matrix with numvec1 and numvec2 with 2 columns, 3 rows
___ <- matrix(c(___, ___), ___, ___)
# Create dataframe from numvec1, numvec2, charvec and logicvec
___
# Get the structure of dataframe
___