gpt4 book ai didi

r - 使用 R 删除特定变量中不包含 .(点)的行

转载 作者:行者123 更新时间:2023-12-02 16:18:25 26 4
gpt4 key购买 nike

我有一个防火墙日志文件,其中包括日期、小时、src_address、dest_address 和 all_attemps、max_byte、avg_byte 和事件率。我想删除 r 中 src_address 列上不包含 .(dot) 的行,这是我的文件;

    src_address  dest_address all_attemps max_byte avg_byte activity_rate
2 1.11.201.19 172.16.16.100 1 60 60 0.005434783
3 1.119.43.90 172.16.16.100 1 60 60 0.005434783
4 1.119.43.90 172.16.16.153 1 60 60 0.005434783
5 1.119.43.90 192.168.1.112 1 60 60 0.005434783
6 1.171.43.133 172.16.16.5 2 52 48 0.010869565
7 1.179.191.82 172.16.16.5 1 60 60 0.005434783
8 1.179.191.82 192.168.1.111 2 60 60 0.010869565
9 1.179.191.82 192.168.1.112 2 60 60 0.010869565
10 1.180.72.186 172.16.16.153 2 60 60 0.010869565
11 1.202.165.40 172.16.16.153 1 60 60 0.005434783
12 1.203.84.52 172.16.16.5 1 60 60 0.005434783
13 1.203.84.52 192.168.1.112 1 60 60 0.005434783
14 1.209.171.4 192.168.1.111 1 60 60 0.005434783
15 1.214.34.114 172.16.16.100 2 60 60 0.010869565
16 1.214.34.114 172.16.16.153 2 60 60 0.010869565
37 101.53.137.245 172.16.16.5 2 60 60 0.010869565
47 101100148143 192.168.1.111 2 60 60 0.010869565
48 101100148143 192.168.1.112 2 60 60 0.010869565
49 101231185170 172.16.16.100 1 60 60 0.005434783
50 101231185170 172.16.16.153 1 60 60 0.005434783
51 101231185170 192.168.1.112 1 60 60 0.005434783
52 103.1.94.102 192.168.1.112 1 52 52 0.005434783
53 103.12.195.158 172.16.16.5 1 52 52 0.005434783

这是我的期望;

         src_address  dest_address all_attemps max_byte avg_byte activity_rate
2 1.11.201.19 172.16.16.100 1 60 60 0.005434783
3 1.119.43.90 172.16.16.100 1 60 60 0.005434783
4 1.119.43.90 172.16.16.153 1 60 60 0.005434783
5 1.119.43.90 192.168.1.112 1 60 60 0.005434783
6 1.171.43.133 172.16.16.5 2 52 48 0.010869565
7 1.179.191.82 172.16.16.5 1 60 60 0.005434783
8 1.179.191.82 192.168.1.111 2 60 60 0.010869565
9 1.179.191.82 192.168.1.112 2 60 60 0.010869565
10 1.180.72.186 172.16.16.153 2 60 60 0.010869565
11 1.202.165.40 172.16.16.153 1 60 60 0.005434783
12 1.203.84.52 172.16.16.5 1 60 60 0.005434783
13 1.203.84.52 192.168.1.112 1 60 60 0.005434783
14 1.209.171.4 192.168.1.111 1 60 60 0.005434783
15 1.214.34.114 172.16.16.100 2 60 60 0.010869565
16 1.214.34.114 172.16.16.153 2 60 60 0.010869565
37 101.53.137.245 172.16.16.5 2 60 60 0.010869565
52 103.1.94.102 192.168.1.112 1 52 52 0.005434783
53 103.12.195.158 172.16.16.5 1 52 52 0.005434783

最佳答案

我们可以在此处使用 grepl 作为基本 R 选项:

df <- df[grepl("\\.", df$src_address), ]

关于r - 使用 R 删除特定变量中不包含 .(点)的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50216571/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com