Import data

Screen Shot 2021-09-24 at 10.20.11 AM.png

Untitled

Cleaning data

Export data

Untitled

Text Example: Deal the text input & Write Function


HC <- scan("HonorCode.txt", what = "")
head(HC, 15)

##########################

# square input: write my own function
square_it <- function(x){
	out <- x*x
	return(out) 
}

##########################

# write a func to split the words by words.
findwords <- function(text_vec){
   words <- split(1:length(text_vec), text_vec)
return(words) 
}

# output is list bc: we cannot make sure each line are same
# for bose previous and below function

##########################

# write a func to alphabetize the word list
alphabetized_list <- function(wordlist) {
   nms <- names(wordlist) # The names are the words
   sorted <- sort(nms) # The words, but now in ABC order
return(wordlist[sorted]) # Returns the sorted version +}

Control Statements: Loops, While, If Else