SCIBD
SCIBD
# 8. Extract element from 2nd row and 3rd column of a 3x4 matrix.
matrix_3x4 <- matrix(1:12, nrow = 3, ncol = 4)
element_2_3 <- matrix_3x4[2, 3]
element_2_3
# 12. Access element in the 1st row, 2nd column, and 2nd matrix of the array.
element_3D <- array_3D[1, 2, 2]
element_3D
# 21: Create a data frame with columns Name, Age, and Gender
df <- data.frame(
Name = c("Ram", "Sham", "Yash"),
Age = c(40, 12, 39),
Gender = c("F", "M", "M")
)
# 22: Add a new column Country = c("USA", "UK", "Canada") to the existing data
frame df
df$Country <- c("USA", "UK", "Canada")
# 24: Select only the Name and Age columns from the data frame
name_age_df <- df[, c("Name", "Age")]
# 25: Calculate the average (mean) of the Age column in the data frame
average_age <- mean(df$Age)
yyy
print(numeric_f)
print(my_list)
print(df)
print(filtered_df)
print(name_age_df)
print(average_age)