Shadow

Tag: grep

How To Select Multiple Columns Using Grep & R

How To Select Multiple Columns Using Grep & R

Blog, Data Science, Recent Posts
Why you need to be using Grep when programming with R. There's a reason that grep is included in most if not all programming language to this day 44 years later from creation. It's useful and simple to use. Below is an example of using grep to make selecting multiple columns in R simple and easy to read. The dataset below has the following column names. names(data) # Column Names [1] "fips" "state" "county" "metro_area" [5] "population" "med_hh_income" "poverty_rate" "population_lowaccess" [9] "lowincome_lowaccess" "no_vehicle_lowaccess" "s_grocery" "s_supermarket" [13] "s_convenience" "s_specialty" "s_farmers_market" "r_fastfood" &#...

Egrep & Fgrep

Recent Posts, Blog, Linux, Tech Tips
EGREP:             The Command egrep is the same as running grep –E. egrep is used to search for a pattern using extended regular expressions. Terry@f:~/FinderDing>cat testsort A line 1 a line 2 8 line 3 line 4 5 line 5 Terry@f:~/FinderDing>egrep '^[a-zA-Z]' testsort A line 1 a line 2 line 4 *Show lines that start with a letter from alphabet Terry@f:~/FinderDing>cat html <!DOCTYPE html> <html> <body> <h1>My First Heading</h1> <p>My first paragraph.</p> </body> </html> Terry@f:~/FinderDing>egrep "My|first" html <h1>My First Heading</h1> <p>My first paragraph.</p> `*Find lines with pattern My first from html file FGREP: The command fgrep is the same as running grep –F. The Command searches for fixed character strings in a...