Code Monkey home page Code Monkey logo

readwriter's Introduction

ReadWriter

Functions to read and write table or text files conveniently. Complements the new CodeAndRoll2.

News

  • The underlying gdata removed read.xls, and this is resolved in v1.0.0 by using openxlsx.
  • As of 11/2023 you may need install_github(repo = "vertesy/ReadWriter@main") instead of install_github(repo = "vertesy/ReadWriter") to install the package on some platforms.



Installation

Install directly from GitHub via devtools with one R command:

# install.packages("devtools"); # If you don't have it.
require("devtools")
devtools::install_github(repo = "vertesy/Stringendo", upgrade = F)
devtools::install_github(repo = "vertesy/ReadWriter")

"As of 11/2023 you may need:"
devtools::install_github(repo = "vertesy/ReadWriter@main")

...then simply load the package:

require("ReadWriter")

Alternatively, you simply source it from the web. This way function help will not work, and you will have no local copy of the code on your hard drive.

source("https://raw.githubusercontent.com/vertesy/ReadWriter/main/R/ReadWriter.R")



Troubleshooting

If you encounter a bug, something doesn't work or unclear, please let me know by raising an issue on ReadWriter – Please check if it has been asked.

List of Functions (16)

Updated: 2023/11/24 16:40

  • 1 column.2.row.names()

Convert a Column to Row Names in a Tibble or DataFrame. Converts the first column (or a specified column) of a dataframe or tibble into row names. This function differs from tibble::column_to_rownames in that it takes column names or inices and it offers the option to sanitize row names using make.names, provides a warning if there are duplicated values in the row name column

  • 2 FirstCol2RowNames()

FirstCol2RowNames. Set First Col to Row Names

  • 3 FirstCol2RowNames.as.df()

FirstCol2RowNames.as.df. Set First Col to Row Names

  • 4 read.simple.vec()

read.simple.vec. Read each line of a file to an element of a vector (read in new-line separated values, no header!).

  • 5 read.simple()

read.simple. It is essentially read.table() with file/path parsing.

  • 6 read.simple_char_list()

read.simple_char_list. Read in a file.

  • 7 read.simple.table()

read.simple.table. Read in a file. default: header defines colnames, no rownames. For rownames give the col nr. with rownames, eg. 1 The header should start with a TAB / First column name should be empty.

  • 8 read.simple.tsv()

read.simple.tsv. Read in a file with excel style data: rownames in col1, headers SHIFTED. The header should start with a TAB / First column name should be empty.

  • 9 read.simple.csv()

read.simple.csv. Read in a file with excel style data: rownames in col1, headers SHIFTED. The header should start with a TAB / First column name should be empty.

  • 10 read.simple.ssv()

read.simple.ssv. Space separeted values. Read in a file with excel style data: rownames in col1, headers SHIFTED. The header should start with a TAB / First column name should be empty.

  • 11 read.simple.tsv.named.vector()

read.simple.tsv.named.vector. Read in a file with excel style named vectors, names in col1, headers SHIFTED. The header should start with a TAB / First column name should be empty.

  • 12 read.simple.xlsx()

Read a multi-sheet XLSX easily. Reads specified sheets from an XLSX file into a list of data frames. It allows customization of column names, row names, and trimming of white spaces.

  • 13 write.simple()

write.simple. Write out a matrix-like R-object to a file with as tab separated values (.tsv). Your output filename will be either the variable's name. The output file will be located in "OutDir" specified by you at the beginning of the script, or under your current working directory. You can pass the PATH and VARIABLE separately (in order), they will be concatenated to the filename.

  • 14 write.simple.vec()

write.simple.vec. Write out a vector-like R-object to a file with as newline separated values (.vec). Your output filename will be either the variable's name. The output file will be located in "OutDir" specified by you at the beginning of the script, or under your current working directory. You can pass the PATH and VARIABLE separately (in order), they will be concatenated to the filename.

  • 15 write.simple.tsv()

write.simple.tsv. Write out a matrix-like R-object WITH ROW- AND COLUMN- NAMES to a file with as tab separated values (.tsv). Your output filename will be either the variable's name. The output file will be located in "OutDir" specified by you at the beginning of the script, or under your current working directory. You can pass the PATH and VARIABLE separately (in order), they will be concatenated to the filename.

  • 16 write.simple.append()

write.simple.append. Append an R-object WITHOUT ROWNAMES, to an existing .tsv file of the same number of columns. Your output filename will be either the variable's name. The output file will be located in "OutDir" specified by you at the beginning of the script, or under your current working directory. You can pass the PATH and VARIABLE separately (in order), they will be concatenated to the filename.

readwriter's People

Contributors

vertesy avatar

Watchers

 avatar  avatar  avatar

readwriter's Issues

read.simple.tsv should return a DF not a tibble

Tibbles don't support rownames

rownames(mytibble)
NULL

# You can add rownames(
rownames(mytibble) <- LETTERS[1:4]

#But after subsetting they are gone
mytibble <- mytibble[ 1:4, ]

rownames(mytibble)
NULL

Input
Add any other context or screenshots about the feature request here.

Output

column.2.row.names in read.simple.csv

Description
Fail

 read.simple.csv(path_p13d8)
...
Rows: 25707 Columns: 2                                                                                                                         
── Column specification ────────────────────────────────────────────────────────────────────────────────────
Delimiter: ","
chr (1): barcode
dbl (1): frequencyUse `spec()` to retrieve the full column specification for this data.Specify the column types or set `show_col_types = FALSE` to quiet this message.
[1] "New variable dim:  25707 1"
Error in column.2.row.names(read_in, as_df = !asTibble) : 
  (converted from warning) tibble/df already has row names (now overwritten):

ReadWriter functions only work after require(ReadWriter)

Description

  • require(ReadWriter) loads the dependee Stringendo.
  • This may be a structural problem across repos. Investigated in vertesy/pipatorium#5

Expected and Buggy Behavior

# Does not work
> ReadWriter::write.simple(xxx)
'Error in kollapse(...) : could not find function "kollapse"'

# Works (it reproduces #8 )
require(ReadWriter)
write.simple(xxx)

Installation error in devtools::install_github(repo = "vertesy/ReadWriter", upgrade = F)

Description

Hi,
I am trying to install MarkdownReports as a dependency for another package (gruffi). But I have troubles already in installing ReadWriter

Buggy Behavior

When running the command devtools::install_github(repo = "vertesy/ReadWriter", upgrade = F) I get this error message:

Error: objectread.xlsis not exported by 'namespace:gdata'
Execution halted
ERROR: lazy loading failed for packageReadWriter

Is this a problem on my side? Can you help me with this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.