export csv in dataframe, remove specific rows and column in r

main.r
# read csv file using read.csv function
df <- read.csv("filename.csv")

# remove rows based on a condition
df <- df[!df$column_name == "value_to_remove",]

# remove columns by name or index
df <- subset(df, select = -c(column_name1, column_name2))
df <- df[, -c(column_index1, column_index2)]

# write to csv file using write.csv function
write.csv(df, "new_filename.csv", row.names = FALSE)
392 chars
13 lines

Note: Replace column_name with the name of the column you want to remove and value_to_remove with the specific value you want to remove from that column. Replace column_name1 and column_name2 with the names of the columns you want to remove and column_index1 and column_index2 with the indexes of the columns you want to remove.

gistlibby LogSnag