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 21, 2019 in Data Analytics by sirish
7,361 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 21, 2019 by anonymous
• 33,050 points
0 votes
library(stringi)
palindrome<-function(x)
{
  if(string_rev(x)==x)
  {
    print("palindrome")
  }
  else
  {
    print("not palindrome")
  }
}
s=(readline(prompt="enter the string:"))
palindrome(s)
answered Jan 14, 2022 by Eshita Saha

edited Mar 5

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,370 points
897 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,130 points
973 views
0 votes
1 answer

SMOTE-function not working in R

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

answered Jun 27, 2018 in Data Analytics by CodingByHeart77
• 3,750 points
3,168 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
2,395 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
2,209 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

edited Jun 9, 2020 by Gitika 1,308 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
1,612 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
• 33,050 points
68,635 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
• 33,050 points
1,058 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP