Example 1: Access Vector Element in R
In R, we can access elements of a vector using the index number (1, 2, 3 …). For example,
# a vector of string type
languages [Read more...]
The length of a vector means the total number of elements present in a given vector.
In R, we can use the length() function to find the total number of elements present in a vector.
Example: Length of a Vector in R Using length()
# create a vec... [Read more...]
Here we will be using the
%in% operator
match() function
any() function.
Example 1: Check if Element Exists in R Vector Using %in%
# create two strings
vowel_letters [Read more...]
The length of a string means the total number of characters present in a given string.
For example, the string "Programiz" has the length 9.
In R, there are two ways to find the length of a string. We can use the nchar() function
or the str_len... [Read more...]
Concatenate means joining multiple strings into one. In R, we use the paste() function to concatenate two or more strings.
Example 1: Concatenate Strings in R
# create two strings
string1 [Read more...]
R print() Function
In R, we use the print() function to print any values and variables. For example,
# print values
print("R is fun")
# print variables
x [Read more...]
Comments are portions of a computer program that are used to describe a piece of code. For example,
# declare variable
age = 24
# print variable
print(age)
Here, # declare variable and # print variable are two comments used in the code.
Comments... [Read more...]