Check palindrome or not in R

0 votes
How to check palindrome or not in R?

Im new to R. I want to check if user names whether they are palindrome.
Aug 20, 2019 in Data Analytics by sirish
113 views

1 answer to this question.

0 votes

Hi,

I found this code simple and easy.

is_palindrome <- function(word) {
  library(stringr)
  split_word <- unlist((str_split(word, pattern = "")))
  reverse_word <- split_word[str_length(word):1]
  paste_word <- paste(reverse_word, collapse = "")
  cat(word == paste_word)
}
is_palindrome("bob")
answered Aug 20, 2019 by anonymous
• 32,440 points

Related Questions In Data Analytics

0 votes
1 answer
0 votes
1 answer

Check if the object(variable) is defined in R

You can use the exists(): > exists("toFindUnknown") [1] FALSE > ...READ MORE

answered Apr 17, 2018 in Data Analytics by Sahiti
• 6,290 points
78 views
0 votes
1 answer

Is there any way to check for missing packages and install them in R?

There are 2 options: Either you can use ...READ MORE

answered Apr 17, 2018 in Data Analytics by nirvana
• 3,060 points
66 views
0 votes
1 answer

SMOTE-function not working in R

If you convert 'y' to a factor, ...READ MORE

answered Jun 26, 2018 in Data Analytics by CodingByHeart77
• 3,710 points
619 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
201 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
240 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,720 points
107 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,720 points
143 views
0 votes
1 answer

How to check if a file already exists or not in R?

Check out file.exists() function!! The function file.exists() returns a ...READ MORE

answered Oct 29, 2019 in Data Analytics by Cherukuri
• 32,440 points
127 views
0 votes
2 answers

R Package installed or not

To see all installed packages in system ...READ MORE

answered Jun 27, 2019 in Data Analytics by anonymous
• 32,440 points
45 views