read.data {SemNetCleaner} | R Documentation |
Read in Common Data File Extensions
Description
A single function to read in common data file extensions. Note that this function is specialized for reading in text data in the format necessary for functions in SemNetCleaner
File extensions supported:
.Rdata
.rds
.csv
.xlsx
.xls
.sav
.txt
.mat
.dat
Usage
read.data(file = file.choose(), header = TRUE, sep = ",", ...)
Arguments
file |
Character.
A path to the file to load.
Defaults to interactive file selection using |
header |
Boolean.
A logical value indicating whether the file contains the
names of the variables as its first line.
If missing, the value is determined from the file format:
header is set to |
sep |
Character.
The field separator character.
Values on each line of the file are separated by this character.
If sep = "" (the default for |
... |
Additional arguments. Allows for additional arguments to be passed onto the respective read functions. See documentation in the list below:
|
Value
A data frame containing a representation of the data in the file. If file extension is ".Rdata", then data will be read to the global environment
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
References
# R Core Team
R Core Team (2019). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.
# readxl
Hadley Wickham and Jennifer Bryan (2019). readxl: Read Excel Files. R package version 1.3.1. https://CRAN.R-project.org/package=readxl
# R.matlab
Henrik Bengtsson (2018). R.matlab: Read and Write MAT Files and Call MATLAB from Within R. R package version 3.6.2. https://CRAN.R-project.org/package=R.matlab
Examples
# Use this example for your data
if(interactive())
{read.data()}
# Example for CRAN tests
## Create test data
test1 <- c(1:5, "6,7", "8,9,10")
## Path to temporary file
tf <- tempfile()
## Create test file
writeLines(test1, tf)
## Read in data
read.data(tf)
# See documentation of respective R functions for specific examples