[code language=”R”]
first_names = c(‘Alex’, ‘randle?’, ‘Joseph’, ‘Michael?’, ‘david’, ‘Charlie’)
grep(‘[[:alpha:]]’, first_names)
grep(‘^[[:lower:]]’, first_names)
explicit_words = c(‘v1agra’, ‘vi@gra’, ‘viagra’)
grep(‘^[a-z]+[1-@][a-z]+’, explicit_words)
first_names
grep(‘^[[:alpha:]]+\\?’,first_names)
length(grep(‘-[[:alpha:]]+\\-‘, data$name))
data$AF50CR = 0
identified = which(data$landmass == 4 & data$population > 5 & data$religion == 1)
data$AF50CR[identified] = 1
data$AM20CHR = 0
identified = which((data$landmass == 1|data$landmass == 2)& data$population > 20 & data$religion == 1)
data$AM20CHR[identified] = 1
test_data = data[,c(1,31,32)]
test_data
test_rows = which(test_data$AF50CR == 1 | test_data$AM20CHR == 1)
test_rows
country_name = test_data[32,]
country_name
country_name_two = test_data[184,]
country_name_two
population_data = data[,c(1,5,31,32)]
population_data
population_rows = which(population_data$AF50CR == 1 | population_data$AM20CHR == 1)
population_rows
population_size = data[c(32,184),5]
population_size
sum(population_size)
[/code]