我有一个60000行的数据框.在其中一列中,值在"着陆"和"起飞"之间交替.
Movements | Flight number | Destination |
---|---|---|
take-off | 011 | Paris |
landing | 011 | Paris |
take-off | 053 | Ibiza |
landing | 053 | Ibiza |
take-off | 067 | Mans |
take-off | 123 | Geneva |
landing | 123 | Geneva |
但也有一些错误,就像这里的第5排.在这个例子中,我有起飞排,但没有降落排.
在R或Excel中有什么方法可以突出显示或 Select 这些行吗? 具体地说:航班号并不是唯一的,在整个过程中会多次出现.
谢谢!
我试过这个:
data() <- read.csv("Flight data.csv")
# Tried to find the positions where values don't alternate correctly
incorrect_positions <- which(data$event[-1] == data$event[-length(data$event)]) + 1
if (length(incorrect_positions) == 0) {
print("The values in the 'event' column alternate correctly.\n")
} else {
print("The values in the 'event' column do not alternate correctly at positions:", incorrect_positions, "\n")
}
它没有给我一个错误,但显然不符合我想要的-当我知道事实并非如此时,它一直打印所有值正确交替.