Last data update: 2014.03.03

R: Read in specified lines from a text file
get_linesR Documentation

Read in specified lines from a text file

Description

Read in specified lines from a text file

Usage

get_lines(filename, line_numbers)

Arguments

filename

character containing the filename of the file from which the lines should be read.

line_numbers

A vector containing the lines that should be read.

Details

Line numbers larger than the number of lines in the file are ignored. Missing values are returned for these.

Value

Returns a character vector with the specified lines.

See Also

See readLines to read in all lines a text file; sample_lines can be used to read in random lines.

Examples

writeLines(letters[1:20], con="tmp.csv")
get_lines("tmp.csv", c(1, 10))

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(LaF)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/LaF/get_lines.Rd_%03d_medium.png", width=480, height=480)
> ### Name: get_lines
> ### Title: Read in specified lines from a text file
> ### Aliases: get_lines
> 
> ### ** Examples
> 
> writeLines(letters[1:20], con="tmp.csv")
> get_lines("tmp.csv", c(1, 10))
[1] "a" "j"
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>