# Introducing filters

# Create a test vector

z<-c(5,2,-3,8)

# Assign as elements to w all elements of z
# for which z*z is greather than 8

w<-z[z*z > 8]

# Display w

w

# Doing the same with a loop

# Create empty vector w

w<-NULL

# Main loop

for (i in seq(z)) {
  
  # Calculate z[i]*z[i], check to see if it is 
  # than 8 and, if it is, copy it to w
  
  if ((z[i]*z[i])>8) w<-c(w,z[i])
}

# Display w

w