Я полный новичок в R и пытаюсь выполнить домашнее задание.У меня возникают проблемы при удалении определенных строк в столбце в зависимости от количества вхождений.Я работаю с данными рейсов Нью-Йорка за 2014 год и должен удалить имена перевозчиков, которые встречаются ниже 1000 раз.
Мой код ниже:
# Import the csv file (NYC_Flights.csv) and explore it using str and summary functions.
#====================== Write R code HERE ==========================
library(ggplot2)
NYC_Flights <- read.csv("NYC_Flights.csv")
str(NYC_Flights)
summary(NYC_Flights)
View(NYC_Flights)
#===================================================================
#======= Question 1 (1 Point) =======
# Q1-1. Add a new variable, total_delay, which is the sum of dep_delay and arr_delay.
# Q1-2. Remove the columns "year" and "cancelled" from your data frame because it is all 2014 and there were no cancelled flights.
# Hint: Reassign a data frame excluding the variables. You might want to use negative indexs.
# Q1-3. Make a table of the number of flights by carrier, and then remove the carriers with less than 1000 flights in 2014.
#====================== Write R code HERE ==========================
NYC_Flights$total_delay <- sum(NYC_Flights$dep_delay + NYC_Flights$arr_delay)
View(NYC_Flights)
NYC_Flights <- NYC_Flights[,-1][,-7]
View(NYC_Flights)
library(stringr)
NYC_Flights <- NYC_Flights[order(NYC_Flights$carrier),]