Delete Row Data in R: Quick Guide
In R language, you can use the subset() function to remove a row of data. Below is an example code of how to use the subset() function to delete a row of data.
# 创建一个示例数据框
data <- data.frame(
id = c(1, 2, 3, 4, 5),
name = c("John", "Alice", "Bob", "Charlie", "Emma"),
age = c(25, 30, 35, 40, 45)
)
# 删除id为3的行数据
new_data <- subset(data, id != 3)
# 输出新的数据框
print(new_data)
After running the above code, the row data with ID 3 will be removed, and a new data frame will be outputted.