Error in 'strsplit(ac1, "-")': non-character argument
This seem to be the current problem.
You split the main string (input) into a list of strings (ac1), then the line below you call the split function again on the just created list (ac1), and the function wonβt accept a list as argument.
What should happen is you apply the strsplit function again on each string inside the list (ac1)
acronym <- function(input) {
ac1 <- strsplit(input, " ")
for(word in ac1){
result <- ""
result <- append(result, strsplit(word, "-"))
}
final <- ""
for (word in result) {
final <- append(final, substr(word,1,1))
}
final <- toString(final)
final <- toupper(final)
return(final)
}
ββ Failure: Abbreviate a phrase ββββββββββββββββββββββββββββββββββββββββββββββββ
acronym(input) not equal to "PNG".
1/1 mismatches
x[1]: ", , P, N, G"
y[1]: "PNG"
Error: Test failed
Execution halted