Book Image

Learning Shiny

By : Hernan Resnizky
Book Image

Learning Shiny

By: Hernan Resnizky

Overview of this book

Table of Contents (19 chapters)
Learning Shiny
Credits
About the Author
Acknowledgements
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Introducing R, RStudio, and Shiny
Index

grep and regular expressions


grep() in R works exactly as it does in every UNIX-based operating system. Closely related to grep() (in fact, R groups them together and treats them as a group of functions), various other functions can be found. In this section, only grepl(), gregexpr(), and gsub() will be examined. One thing that all these functions have in common is that they perform an action based on a string pattern. The description of the functions are as follows:

  • grep(): This returns the indexes of the elements in a vector that match a string pattern. If the value is set to TRUE, it returns the values instead of the indexes.

  • grepl(): This returns a logical vector of the same length as the input vector, denoting whether the sought pattern was found or not.

  • gsub(): This substitutes the pattern for the replacement argument in the specified vector.

  • gregexpr(): This returns a list consisting of the vectors of starting positions that specify where the pattern was matched in the text in addition...