```r
# Set the directory path where your files are located
directory_path <- "../output/"

# Define the regular expression pattern to match your files
file_pattern <- "F.*coverage\\.txt"

# Get the list of files that match the pattern in the specified directory
file_list <- list.files(path = directory_path, pattern = file_pattern, full.names = TRUE)

# Function to read and merge files
merge_files <- function(file_paths) {
  # Initialize an empty data frame
  merged_table <- data.frame()

  # Loop through each file and merge it with the existing data
  for (file_path in file_paths) {
    # Read the file into a data frame
    table <- read.table(file_path, header = FALSE, sep = "\t")
    
    # Assign column names to the data frame
    colnames(table) <- c("Chr", "Start", "End", "ID", "Dot", "Strand", "Value")
    
    # Get the base filename without the extension
    base_filename <- tools::file_path_sans_ext(basename(file_path))

    # Add a new column with the base filename to the data frame
    table$Filename <- base_filename

    # Merge the data frame with the existing data
    merged_table <- rbind(merged_table, table)
  }

  # Return the final merged data frame
  return(merged_table)
}

# Call the function to merge all the files
merged_coverage <- merge_files(file_list)

# Print the merged data frame
head(merged_coverage)
```

```
##           Chr Start    End                   ID Dot Strand Value
## 1 NC_047559.1  9838  11386 ID=gene-LOC117693020   .      +   872
## 2 NC_047559.1 14113  15804 ID=gene-LOC109621113   .      +  1088
## 3 NC_047559.1 16866  19160 ID=gene-LOC117687066   .      -  1682
## 4 NC_047559.1 60035  74623 ID=gene-LOC117689737   .      -  2989
## 5 NC_047559.1 80320  86124 ID=gene-LOC117687025   .      +    40
## 6 NC_047559.1 97819 126387 ID=gene-LOC105333279   .      +   532
##           Filename
## 1 F052n01.coverage
## 2 F052n01.coverage
## 3 F052n01.coverage
## 4 F052n01.coverage
## 5 F052n01.coverage
## 6 F052n01.coverage
```