Function unifies most common reading data functions. It guesses the file extenstion and fits best function to load. Usually knowing types of parameters as: separator, decimal, header is not necessary, but function allows to put them by hand. Supported extensions: "txt", "csv", "xls", "xlsx", "tsv", "rda", "rdata", "json".

hugo_read_data(path, file_extension = NA, header = NA, separator = NA,
  decimal = NA, file_name_to_save = NULL)

Arguments

path

the name of the path 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 path name is relative to the current working directory, getwd(). path can also be a complete URL.

file_extension

the type of file which is loaded. Usually don't needed, because Hugo guesses it.

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: header is set to TRUE if and only if the first row contains one fewer field than the number of columns.

separator

the field separator character. Values on each line of the file are separated by this character. If sep = "" the separator is 'white space', that is one or more spaces, tabs, newlines or carriage returns.

decimal

the character used in the file for decimal points.

file_name_to_save

the name of the file where the data will be saved.

Value

Returns data.frame, tibble or a list.

Examples

# NOT RUN {
### simple loading most common types of extensions
#loading csv
path <- "http://insight.dev.schoolwires.com/HelpAssets/C2Assets/C2Files/C2SectionRobotSample.csv"
data <- hugo_read_data(path)
head(data)

#loading rda
path <- system.file("extdata", "example.rda", package = "hugo")
data <- hugo_read_data(path)
head(data)

#loading json
path <- "https://raw.githubusercontent.com/corysimmons/colors.json/master/colors.json"
data <- hugo_read_data(path)
head(data)


### specifying our own parameters
#loading csv
path <- "http://insight.dev.schoolwires.com/HelpAssets/C2Assets/C2Files/C2SectionRobotSample.csv"
data <- hugo_read_data(path, separator = ",", decimal = ".", header = TRUE)
head(data)


### interaction with user
# loading file without extension
path <- system.file("extdata", "no_extension", package = "hugo")
# input "txt"
data <- hugo_read_data(path)
head(data)

# providing your own parameters
path <- system.file("extdata", "example2.txt", package = "hugo")
data <- hugo_read_data(path, decimal = ".")
# an error occured, but you have an information to put ALL parameters
data <- hugo_read_data(path, header = TRUE, separator = ",", decimal = ".")
head(data)


### more examples
# for more examples please put an extension in <extension> below
# and try other avaliable sample files attached to package
# path <- system.file("extdata", "example.<extension>", package = "hugo")
# data <- hugo_read_data(path)
# head(data)

# }