Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###############################
- # Vector arithmetics
- ###############################
- # (+, -, *, /, ^)
- # get the max value
- # get the min value
- # get the range of values
- # calculate the sum of all elements
- # calculate the product of all elements
- ################################
- # Generating regular sequences
- ################################
- # generate a sequence from 1 to 10
- # generate a sequence from 10 to 1
- # generate a sequence from 3.2 to 4.7, with a step 0.2
- ################################
- # Factor values
- ################################
- # create a vector and convert to factor
- # print unique factor values (levels)
- # specify the order of level
- # print the summary
- ################################
- # Missing values
- ################################
- # check which values are NAs
- # NaN missing value
- ################################
- # Data frame
- ################################
- # create a data frame
- # create a data frame from existing vectors
- ################################
- # Task 1
- ################################
- # Create a dataframe called *co2.emissions* containing two columns: *years* (2000, 2002, 2004, 2006, 2008, 2010) and *emission* (2.7, 2.9, 4, 4.9, 5.3, 6.2).
- # Answer:
- ################################
- # Loading data frame from a file
- ################################
- # reading a data frame from the CSV fill
- # head and tail functions
- # print the number of rows
- # print the number of columns
- # str function
- # summary function
- # retrieve and change column names
- # remove column duration
- ################################
- # Subsetting
- ################################
- # get an element from the row 3, column 1
- # get the third row
- # get rows at positions from 3 to 6
- # get rows at positions 3 and 6
- # get the second column
- # get the Year column
- # retrieve all songs released before year 1965
- # alternative
- # retrieve all songs released before year 1965 with duration lower than 150 seconds
- # alternative
- ################################
- # Task 2
- ################################
- # Print a number of songs from 1963 that last more than 2 minutes (120 seconds).
- # Answer:
- ################################
- # Plotting
- ################################
- # create a plot for the given vectors
- # include ggplot2 library
- # render a plot for the given data frame (columns Year and Duration)
- # render a scatter plot for Year and Duration
- # render a scatter plot with custom title and axes labels
- # render a bar chart displaying the number of songs in each year
- # improve the previous chart so that only years with songs are shown;
- # include title and axes labels
- # render a line chart (Year, Duration) for the first five songs
- # with specific line and points properties
- ################################
- # Task 3
- ################################
- # Create a line chart from a dataset *co2.emissions* (created in Task 1) with the x-axis representing the years, and the y-axis representing the values of CO2 emissions.
- # Chart title should be "China CO2 Emissions" and y-axis should have a label "CO2 Emissions".
- # Answer:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement