R total line text file

# Set the file path
file_path <- "your_file.txt"

# Read all lines from the text file
all_lines <- readLines(file_path)

# Get the total number of lines
total_lines <- length(all_lines)

# Print the total number of lines
cat("Total lines in the file:", total_lines)