Merge branch 'fgetl' into fix-handleData
This commit is contained in:
commit
07a95c6f8b
3 changed files with 73 additions and 0 deletions
27
R/fgetl-fopen.R
Normal file
27
R/fgetl-fopen.R
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#' @title Read line from file, removing newline characters
|
||||||
|
#' @description Equivalent function to its homonymous Matlab equivalent.
|
||||||
|
#' @param file character vector to be read, usually an output of `fopen()`
|
||||||
|
#' @return If the file is nonempty, then fgetl returns tline as a character vector. If the file is empty and contains only the end-of-file marker, then fgetl returns tline as a numeric value -1.
|
||||||
|
#' @author Waldir Leoncio
|
||||||
|
#' @seealso fopen
|
||||||
|
#' @export
|
||||||
|
fgetl <- function(file) {
|
||||||
|
# ==========================================================================
|
||||||
|
# Validation
|
||||||
|
# ==========================================================================
|
||||||
|
if (length(file) <= 1) return(-1)
|
||||||
|
# ==========================================================================
|
||||||
|
# Returning file minus the first line
|
||||||
|
# ==========================================================================
|
||||||
|
out <- file[-1]
|
||||||
|
return(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @title Open file
|
||||||
|
#' @description Open a text file
|
||||||
|
#' @param filename Path and name of file to be open
|
||||||
|
#' @return The same as `readLines(filename)`
|
||||||
|
#' @author Waldir Leoncio
|
||||||
|
#' @seealso fgetl
|
||||||
|
#' @export
|
||||||
|
fopen <- function(filename) readLines(filename)
|
||||||
23
man/fgetl.Rd
Normal file
23
man/fgetl.Rd
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
% Generated by roxygen2: do not edit by hand
|
||||||
|
% Please edit documentation in R/fgetl.R
|
||||||
|
\name{fgetl}
|
||||||
|
\alias{fgetl}
|
||||||
|
\title{Read line from file, removing newline characters}
|
||||||
|
\usage{
|
||||||
|
fgetl(file)
|
||||||
|
}
|
||||||
|
\arguments{
|
||||||
|
\item{file}{character vector to be read, usually an output of `fopen()`}
|
||||||
|
}
|
||||||
|
\value{
|
||||||
|
If the file is nonempty, then fgetl returns tline as a character vector. If the file is empty and contains only the end-of-file marker, then fgetl returns tline as a numeric value -1.
|
||||||
|
}
|
||||||
|
\description{
|
||||||
|
Equivalent function to its homonymous Matlab equivalent.
|
||||||
|
}
|
||||||
|
\seealso{
|
||||||
|
fopen
|
||||||
|
}
|
||||||
|
\author{
|
||||||
|
Waldir Leoncio
|
||||||
|
}
|
||||||
23
man/fopen.Rd
Normal file
23
man/fopen.Rd
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
% Generated by roxygen2: do not edit by hand
|
||||||
|
% Please edit documentation in R/fgetl.R
|
||||||
|
\name{fopen}
|
||||||
|
\alias{fopen}
|
||||||
|
\title{Open file}
|
||||||
|
\usage{
|
||||||
|
fopen(filename)
|
||||||
|
}
|
||||||
|
\arguments{
|
||||||
|
\item{filename}{Path and name of file to be open}
|
||||||
|
}
|
||||||
|
\value{
|
||||||
|
The same as `readLines(filename)`
|
||||||
|
}
|
||||||
|
\description{
|
||||||
|
Open a text file
|
||||||
|
}
|
||||||
|
\seealso{
|
||||||
|
fgetl
|
||||||
|
}
|
||||||
|
\author{
|
||||||
|
Waldir Leoncio
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue