'Finding a polyndrom in R

polindrome <- function(path_to_file){
  for(i in read.delim(path_to_file)){
    print(i)
   }
 }

polindrome("phrases.txt")

I have a text file "phrases.txt" (UTF-8 encoding). My task is to create a function that will load the entered data on call (1) and (2) return the file "phrases_updated.txt". The output of the function will be (3) a list with two elements a) a vector of all phrases that are a palindrome, b) a vector of all phrases that are not a palindrome. (4) The function also writes to the console the number of evaluated phrases, their average length (number of characters), average number of words and in percentages express how many of the input phrases is a palindrome (fill in a suitable description, eg the representation of the palindrome in the file is ...). etc., use arguments referring to the path to the input file and the output file as an argument to the function.

r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source