- Home
- Interview Questions
- Data Science
There are various ways to do this-
It can be done using the match () function- match () function returns the
first appearance of a particular element.
The other is to use %in% which returns a Boolean value either true or
false.
Is.element () function also returns a Boolean value either true or false
based on whether it is present in a vector or not.
The multiplication of the two vectors will be performed and the output will be displayed with a warning message like – “Longer object length is not a multiple of shorter object length.” Suppose there is a vector a<-c (1, 2, 3) and vector b <- (2, 3) then the multiplication of the vectors a*b will give the resultant as 2 6 6 with the warning message. The multiplication is performed in a sequential manner but since the length is not same, the first element of the smaller vector b will be multiplied with the last element of the larger vector a.
A factor variable can be converted to numeric using the as.numeric() function
in R language. However, the variable first needs to be converted to character
before being converted to numberic because the as.numeric() function in R
does not return original values but returns the vector of the levels of the factor
variable.
X <- factor(c(4, 5, 6, 6, 4))
X1 = as.numeric(as.character(X))
Supervised Machine learning:
Supervised machine learning requires training labeled data.
Unsupervised Machine learning:
Unsupervised machine learning doesn’t required labeled data.