read a txt file in r code example
Example: r read file
# In R there are many custom functions for reading files, but many of
# them are essentially wrappers for read.table() and can be ignored.
# Basic syntax using read.table():
data = read.table('/path/to/filename.extension', header=FALSE,
sep="delimiter", skip=integer, nrows=integer,
row.names=row_names, col.names=column_names)
# Where:
# - The above parameters are some of the most useful in read.table()
# - Only the '/path/to/filename.extension' argument is required. It
# can also be a complete URL to a file
# - The header default is TRUE
# - sep default is 'white space', which is one or more spaces, tabs,
# newlines or carriage returns but it can be used to specify any
# field delimiter e.g.: '\t' ',' '|' ';' and etc
# - skip is the number of rows to skip when reading the file
# - nrows is the maximum number of rows to read
# - row.names and col.names are optional vectors of names that can be
# used for the row or column names