Recap - Event Guests
Part of the Logic & Flow section of Coddy's R journey. Lesson 16 of 64.
Challenge
MediumComplete guest_report(invited, arrivals). arrivals lists every check-in, and a guest may check in more than once. Return four lines:
Arrived:followed by the number of different guests who checked inNo-shows:followed by the invited guests who never checked inUninvited:followed by the guests who checked in without an invitationRepeat check-ins:followed by the guests who checked in more than once
Sort each list of names, write each name once, and join them with , . An empty list is written none.
The supplied code reads the invited guests and the arrivals as comma-separated lines and prints each returned line.
Try it yourself
guest_report <- function(invited, arrivals) {
# Write your code here
character(0)
}
# Supplied input/output code: keep it as it is
input <- suppressWarnings(readLines(file("stdin")))
cat(guest_report(strsplit(input[1], ",")[[1]], strsplit(input[2], ",")[[1]]), sep = "\n")
All lessons in Logic & Flow
1Strings In Depth
Substrings with substr()Formatting with sprintf()Splitting and JoiningSearching StringsReplacing TextRecap - Username Builder4Matrices
Creating MatricesIndexing MatricesRow and Column SummariesMatrix ArithmeticRecap - Seating Chart2Key-Value Lookups
Named Vector LookupsChecking KeysAdding and Removing KeysLooping Over NamesRecap - Stock Desk3Sets and Counting
Unique ValuesSet OperationsMembership TestsCounting with table()Recap - Event Guests6Functions as Values
Anonymous FunctionsPassing FunctionsReturning FunctionsClosures with StateRecap - Discount Rules9Data Frames
Creating Data FramesColumns and RowsFiltering RowsAdding and SortingRecap - Sales Report12Project - Expense Tracker
Recording ExpensesTotal SpendingPractice on your own: Online R compiler