I have a file like the one below. I would like to print the rows for which the value in the last column is higher than 90. I am not sure how to specify the correct column.
29974 A1CF NM_138932 9606 hsa-miR-4711-3p 3 25 32 -0.018 -0.095 -0.108 0.003 0.017 -0.448 99
29974 A1CF NM_138933 9606 hsa-miR-4711-3p 3 25 32 -0.018 -0.095 -0.108 0.003 0.017 -0.448 99
29974 A1CF NM_014576 9606 hsa-miR-4711-3p 3 25 32 -0.018 -0.095 -0.108 0.003 0.017 -0.448 99
29974 A1CF NM_001198820 9606 hsa-miR-4711-3p 3 25 32 -0.018 -0.095 -0.108 0.003 0.017 -0.448 69
29974 A1CF NM_001198819 9606 hsa-miR-4711-3p 3 25 32 -0.018 -0.095 -0.108 0.003 0.017 -0.448 89
29974 A1CF NM_001198818 9606 hsa-miR-4711-3p 3 25 32 -0.018 -0.095 -0.108 0.003 0.017 -0.448 90
print(df[which(df[,ncol(df)]>90),])
df是数据框对象的名称。
Through awk.
$ awk '$NF>90' file
29974 A1CF NM_138932 9606 hsa-miR-4711-3p 3 25 32 -0.018 -0.095 -0.108 0.003 0.017 -0.448 99
29974 A1CF NM_138933 9606 hsa-miR-4711-3p 3 25 32 -0.018 -0.095 -0.108 0.003 0.017 -0.448 99
29974 A1CF NM_014576 9606 hsa-miR-4711-3p 3 25 32 -0.018 -0.095 -0.108 0.003 0.017 -0.448 99
Awk process the input file, record by record ie, row by row. NF
is a special variable in awk which stores the last column number. So $NF
contains the value of last column. So $NF>90
will check for the value of last column is greater than 90 or not. If it's true then awk prints the corresponding row.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.