I have a folder of .txt files. One of the columns in each .txt files is called "Row." (That's confusing, I'm sorry.) "Row" column contains values A thru H.

I'm trying to write something that I can run through each .txt file to check to see all the values from A thru H are present in the file. I want this function to tell me which .txt file is incomplete (missing some of the values). I don't have to know what it's missing... I just have to know which .txt file doesn't have all the values from A to H.

Is there a way to do this?

Thank you in advance~

EDIT

Here is a sample of the data I'm working with. This is from the first data frame in a list of data frames. So this is after I already made each .txt file into a data frame.

      row col TOF  EXT time green yellow red         worm call50    norm.red stage
1      A   1  20   20    0     2      0   0 1.922668e-02 bubble 0.000000000    L1
2      A   1  32   45  358     6      6   3 9.637690e-01   worm 0.093750000    L1
3      A   1  24   30 1185     6      1   0 2.246214e-02 bubble 0.000000000    L1
4      A   1 139  230 2433    39     49  31 1.000000e+00   worm 0.223021583    L2
5      A   1  27   23 2433     3      4   2 8.262885e-01   worm 0.074074074    L1
6      A   1  24   25 3946     3      4   3 9.077824e-01   worm 0.125000000    L1
7      A   2  40   55    0    30     46  29 1.000000e+00   worm 0.725000000    L1
8      A   2  31   34 2793     3      2   0 1.100591e-01 bubble 0.000000000    L1
9      A   3  37   42    0     8      9   5 9.996614e-01   worm 0.135135135    L1
10     A   3  89  172  562    28     38  20 1.000000e+00   worm 0.224719101    L1
...
648    B   1 124  160    0    11      8   4 9.999695e-01   worm 0.032258065    L2
649    B   1 125  211   47    13     11   4 9.999610e-01   worm 0.032000000    L2
650    B   1  65  112  141     6      4   3 9.404593e-01   worm 0.046153846    L1
有帮助吗?

解决方案

Try:

ldf <- list(df1 = data.frame(row=LETTERS[1:8],col=1:8), df1 = data.frame(row=LETTERS[1:7],col=1:7))

> ldf
$df1
  row col
1   A   1
2   B   2
3   C   3
4   D   4
5   E   5
6   F   6
7   G   7
8   H   8

$df1
  row col
1   A   1
2   B   2
3   C   3
4   D   4
5   E   5
6   F   6
7   G   7


> lapply(ldf, function(x) sum(LETTERS[1:8] %in% x$row)!=8)
$df1
[1] FALSE

$df1
[1] TRUE

BUILD

Can also use: names(ldf) <- c("file1.txt", "file2.txt")

$file1.txt
[1] FALSE

$file2.txt
[1] TRUE

UPDATE

A nicer way would be:

lapply(ldf, function(x) all(LETTERS[1:8] %in%  x$row) & all(1:8 %in%  x$col))
$file1.txt
[1] TRUE

$file2.txt
[1] FALSE
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top