#QUESTION 1
library(RCurl)
x <- getURL("https://raw.githubusercontent.com/fivethirtyeight/data/master/college-majors/majors-list.csv")
y <- data.frame(read.csv(text=x))
summary(y)
## FOD1P Major Major_Category
## Length:174 Length:174 Length:174
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
library(stringr)
y$Major[str_detect(y$Major,pattern="\\DATA|\\STATISTICS")]
## [1] "MANAGEMENT INFORMATION SYSTEMS AND STATISTICS"
## [2] "COMPUTER PROGRAMMING AND DATA PROCESSING"
## [3] "STATISTICS AND DECISION SCIENCE"
#QUESTION 2
df <- data.frame(c("bell pepper","bilberry","blackberry","blood orange","blueberry","cantaloupe","chili pepper","cloudberry","elderberry","lime" , "lychee" , "mulberry","olive" , "salal berry"))
x <- cat(paste(df,collapse=","))
## c("bell pepper", "bilberry", "blackberry", "blood orange", "blueberry", "cantaloupe", "chili pepper", "cloudberry", "elderberry", "lime", "lychee", "mulberry", "olive", "salal berry")
#QUESTION 3
example <- c("aaa","banana")
str_view(example,"(.)\\1\\1")
2.
Repeated pair of the same letters (aa), in between the same letter(s)-like a palindrome
example <- c("saas","banana")
str_view(example,"(.)(.)\\2\\1")
example <- c("saas","banana")
str_view(example,"(..)\\1")
4. Same letter appearing alternatively, thrice (example a in (b)‘anana’)
example <- c("hahaha","banana")
str_view(example,"(.).\\1.\\1")
5. Same letter appearing consecutively thrice, followed by a different letter, then the same initial letters appearing thrice again.
example <-c("rrrprrrttcuwjsoooo")
str_view(example,"(.)(.)(.).*\\3\\2\\1")
#QUESTION 4
example <- c("roar","eye","gig","grab")
str_view(example,"(.).*\\1")
2.Contain a repeated pair of letters (e.g. “church” contains “ch” repeated twice.)
example <- c("church","banana","grab")
str_view(example,"(..).*\\1")
3.Contain one letter repeated in at least three places (e.g. “eleven” contains three “e”s.)
example <- c("eleven","grab")
str_view(example,"(.).*\\1.*\\1")