Type: | Package |
Title: | Import Origin(R) Project Files |
Version: | 0.3-6 |
Description: | Read the data from Origin(R) project files ('*.opj') https://www.originlab.com/doc/User-Guide/Origin-File-Types. No write support is planned. |
License: | GPL (≥ 3) |
Depends: | R (≥ 3.1) |
Imports: | Rcpp (≥ 0.12.9) |
LinkingTo: | Rcpp |
BugReports: | https://codeberg.org/aitap/Ropj/issues |
NeedsCompilation: | yes |
Packaged: | 2025-03-14 13:30:31 UTC; ivan |
Author: | Miquel Garriga [aut], Stefan Gerlach [aut], Ion Vasilief [aut], Alex Kargovsky [aut], Knut Franke [ctb], Alexander Semke [ctb], Tilman Benkert [ctb], Kasper Peeters [ctb], Russell Standish [ctb], Mehdi Chinoune [ctb], Ivan Krylov [cre] |
Maintainer: | Ivan Krylov <ikrylov@disroot.org> |
Repository: | CRAN |
Date/Publication: | 2025-03-15 22:50:05 UTC |
Import Origin(R) Project Files
Description
Read the data from Origin(R) project files ('*.opj') <https://www.originlab.com/doc/User-Guide/Origin-File-Types>. No write support is planned.
Details
This package exports a single function, read.opj
,
that tries to read an OPJ file and return a list of objects that it
consists of.
No write support seems to be planned in the foreseeable future.
References
https://sourceforge.net/projects/liborigin/: the liborigin
implementation used by this package. Seems to be maintained as of 2021.
Examples
## Not run: x <- read.opj('data.opj')
Parse Origin(R) project file into a list of objects
Description
This function parses an OPJ file into a list of objects it consists
of. Items understood by read.opj
include spreadsheets, matrices,
and notes.
Usage
read.opj(file, encoding = 'latin1', tree = FALSE, ...)
Arguments
file |
Path to the OPJ file to parse. Only file paths are supported, not R connections. Path is not expanded automatically. The path must be representable in the native encoding of the R session. Unfortunately, a Unicode path that doesn't fit in the ANSI encoding will not work on Windows older than version 10, November 2019. |
encoding |
Encoding of the strings inside the file being opened. This should
correspond to the ANSI code page of Windows installation used to
produce the file. The default of |
tree |
Control the structure of the returned list. When |
... |
The rest of the arguments is passed to |
Value
A named list
containing objects stored in the file.
Spreadsheets are presented as
data.frame
s, with additionalattributes
:-
comment
contains the fields Long name, Units, and Comment, joined by\r\n
, if present. Due to a possible bug inliborigin
, these values are sometimes followed by@
and some text that wasn't present in the original document. (In versions prior to v0.2-2 it was calledcomments
, which should be still supported until v1.0.) -
commands
contains the formula that was used to create the values of the column (e.g.col(A) * 2 + 1
).
-
Multi-sheet spreadsheets are stored as named lists of
data.frame
s described above.Matrices are presented as
list
s ofmatrix
objects containing numeric data.dimnames
are also assigned. The list also has attributes:-
commands
contains the formula that was used to compute the values in the matrix.
-
Notes are stored as plain strings.
When tree = FALSE
, the list is flat, its names are short names
of the objects, and the comment
attribute of the list
contains the long names of the objects
stored in the file.
When tree = TRUE
, the list names are long names (if present;
short otherwise) and the list itself represents the folder structure
of the project.
Note
The new Unicode file format (OPJU
) is not supported.
While Origin(R) and its scripting language seem to rely on the
short names of the objects being unique across a project,
neither long names nor folder names are guaranteed to
avoid collisions. Tree-like lists returned by read.opj(..., tree =
TRUE)
might be easier to navigate interactively but present problems
if someone gives multiple folders or objects the same long name.
Examples
x <- read.opj(system.file('test.opj', package = 'Ropj'))
head(x$Book2, 7)
comment(x$Book2)
attr(x$Book2, 'commands')
with(x$Book1, head(Sheet2 - Sheet1))
x$MBook1$MSheet1[1:4,1:4]
x$Note1
if ('CP1251' %in% iconvlist()) {
# encoding names aren't guaranteed to be supported across all platforms
x <- read.opj(system.file('test.opj', package = 'Ropj'), 'CP1251')
print(x$cyrillic)
}
str(read.opj(system.file('tree.opj', package = 'Ropj'), tree = TRUE))