read.csv.print {quickcode} | R Documentation |
Read a CSV and preview first X rows and columns
Description
The purpose of this function is combine the functionality of
read.csv and print, which are often used together.
The purpose of this function is to read data from a file into a variable and
simultaneously display a preview of the data, showing either the first few rows or
columns based on the user's specification. It is important to emphasize that the
function expects the user to assign the result of the read operation to a variable
in order to achieve its intended purpose. eg. Use var1 = read.csv.print(file1) instead of
read.csv.print(file1)
Usage
read.csv.print(
file,
header = TRUE,
sep = ",",
quote = "\"",
dec = ".",
fill = TRUE,
comment.char = "",
...,
dim = c(10L, 5L)
)
Arguments
file |
the name of the file which the data are to be read from.
Each row of the table appears as one line of the file. If it does
not contain an absolute path, the file name is
relative to the current working directory,
Alternatively,
|
header |
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: |
sep |
the field separator character. Values on each line of the
file are separated by this character. If |
quote |
the set of quoting characters. To disable quoting
altogether, use |
dec |
the character used in the file for decimal points. |
fill |
logical. If |
comment.char |
character: a character vector of length one
containing a single character or an empty string. Use |
... |
Further arguments to be passed to |
dim |
dimension of CSV content to show |
Details
Read a dataset of type csv and show x rows and y columns with one function call
Value
read csv content and a print out of the data head
Examples
## Not run:
# Example: read a csv file and print the first 10 lines
# declare file
new.file <- "test.csv"
# read file and preview default
dth3 <- read.csv.print(file = new.file)
# read file and preview 10 rows and all columns
dth1 <- read.csv.print(file = new.file, dim = 10)
# read file and preview 10 rows and 5 columns
dth2 <- read.csv.print(file = new.file, dim = c(10,5))
## End(Not run)