# Exercise 13 - Working with functions

### Function Definitions

# loadDataFile - Reads the data file into a data frame
# No parameters passed to the function
# Returns the data frame

loadDataFile<-function()
{
  # Load the csv file into a temporary data frame tempFrame

  
  # Return tempFrame to the main script
 
  
} # End of loadDataFile

# extractSunspotClass - Extracts the $SunspotClass column into a vector
# Data frame df passed to the function
# Returns the tempVector

extractSunspotClass<-function(df)
{
  # Save the %SunspotClass column to vector tempVector
  
  
  # Return tempVector to the main script
  
  
} # End of extractSunspotClass

# extractSpotSize - Extracts the $SpotSize column into a vector
# Data frame df passed to the function
# Returns the tempVector

extractSpotSize<-function(df)
{
  # Save the %SpotSize column to vector tempVector
  
  
  # Return tempVector to the main script
  
  
} # End of extractSpotSize

# extractSpotDistribution - Extracts the $SpotDistribution column into a vector
# Data frame x passed to the function
# Returns the tempVector

extractSpotDistribution<-function(df)
{
  # Save the %SpotDistribution column to vector tempVector
  
  
  # Return tempVector to the main script
 

} # End of extractSpotDistribution

# countElements - Count how many times each element of v1 occurs in v2
# Vector v1 is the unique elements in v2
# Return a vector of numbers representing the counts

countElements<-function(v1,v2)
{
  # This will create a vector of numbers representing the number of times
  # each element of v1 appears in v2
  # Each iteration of the loop will add a new element to this vector
  
  
  # Loop for all elements in v1
  
  
    # This will count in a loop, so set up a counter currentValue to 0
    
    
    # Loop for all elements in v2
    
    
      
      # If the current element of v1 is the same as that of v2 then
      # increment the currentValue counter
      
  
   # End of v2 loop
    
    # Append the currentValue counter to the tempCount vector 
    
    
  # End of v1 loop
  
  # Return tempCount to the calling function
  )
}

# createSummary - Create data frame of show the values and count of values
# Vector v passed to the function
# Return the new data frame

createSummary<-function(v)
{
  # Identify the unique elements of the vector v and place in tempValues
  
  
  # Call countElements to calculate the number of occurrences of each element
  # and place in tempCount. Pass in tempElements and v
  
  
  # Build tempDF from tempValues and tempCount
  
  
  # Return tempDF to the main script
  
  
}


### Main Script  ###

# Create data frame solarFlares



# Extract SunspotClass into a vector v_sunspotClass



# Extract SpotSize into a vector v_spotSize



# Extract SpotDistribution into a vector v_spotDistribution



# Create and display summarySunspotClass from v_sunspotClass



# Create and display summarySunspotClass from v_spotSize



# Create and display summarySpotDistribution from v_spotDistribution

