Skip to content

Commit 7b0a098

Browse files
committed
Adds ts repr. Fixes #105
1 parent 1a5fd19 commit 7b0a098

15 files changed

Lines changed: 82 additions & 30 deletions

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@ Collate:
5656
'repr_plotly.r'
5757
'repr_recordedplot.r'
5858
'repr_spatial.r'
59+
'repr_ts.r'
5960
'repr_vega.r'
6061
RoxygenNote: 6.1.1

NAMESPACE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ S3method(repr_html,numeric)
3636
S3method(repr_html,packageIQR)
3737
S3method(repr_html,shiny.tag)
3838
S3method(repr_html,shiny.tag.list)
39+
S3method(repr_html,ts)
3940
S3method(repr_javascript,default)
4041
S3method(repr_jpg,default)
4142
S3method(repr_jpg,recordedplot)
@@ -54,6 +55,7 @@ S3method(repr_latex,list)
5455
S3method(repr_latex,logical)
5556
S3method(repr_latex,matrix)
5657
S3method(repr_latex,numeric)
58+
S3method(repr_latex,ts)
5759
S3method(repr_markdown,"function")
5860
S3method(repr_markdown,Date)
5961
S3method(repr_markdown,character)
@@ -66,6 +68,7 @@ S3method(repr_markdown,list)
6668
S3method(repr_markdown,logical)
6769
S3method(repr_markdown,matrix)
6870
S3method(repr_markdown,numeric)
71+
S3method(repr_markdown,ts)
6972
S3method(repr_pdf,default)
7073
S3method(repr_pdf,recordedplot)
7174
S3method(repr_plotly1,default)
@@ -85,6 +88,7 @@ S3method(repr_text,packageIQR)
8588
S3method(repr_text,recordedplot)
8689
S3method(repr_text,shiny.tag)
8790
S3method(repr_text,shiny.tag.list)
91+
S3method(repr_text,ts)
8892
S3method(repr_vdom1,default)
8993
S3method(repr_vega4,default)
9094
S3method(repr_vegalite2,default)
@@ -118,6 +122,8 @@ importFrom(grDevices,png)
118122
importFrom(grDevices,replayPlot)
119123
importFrom(grDevices,svg)
120124
importFrom(htmltools,renderTags)
125+
importFrom(stats,.preformat.ts)
126+
importFrom(stats,ts)
121127
importFrom(tools,Rd2HTML)
122128
importFrom(tools,Rd2latex)
123129
importFrom(tools,Rd2txt)

R/generics.r

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@ repr_text.default <- function(obj, ...) {
4040
#' @param ... parameters of the specific \code{repr_*} functions
4141
#'
4242
#' @seealso \link{repr_text} for the only repr that is always defined
43-
#' @aliases
44-
#' repr_html repr_html.default
45-
#' repr_markdown repr_markdown.default
46-
#' repr_latex repr_latex.default
47-
#' repr_json repr_json.default
48-
#' repr_javascript repr_javascript.default
49-
#' repr_pdf repr_pdf.default
50-
#' repr_png repr_png.default
51-
#' repr_jpg repr_jpg.default
52-
#' repr_svg repr_svg.default
5343
#' @name repr-generics
5444
NULL
5545

@@ -177,7 +167,6 @@ repr_vega4.default <- function(obj, ...) NULL
177167
#' names(mime2repr)
178168
#' names(format2repr)
179169
#'
180-
#' @aliases mime2repr format2repr
181170
#' @name *2repr
182171
#' @export
183172
mime2repr <- list(

R/repr_factor.r

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#' @param obj The factor to create a representation for
44
#' @param ... ignored
55
#'
6-
#' @aliases repr_markdown.factor repr_latex.factor repr_html.factor
76
#' @name repr_*.factor
87
#' @include repr_vector.r
98
#' @include utils.r

R/repr_function.r

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#' @param fenced Should a fenced code block instead of an indented one be used?
66
#' @param ... ignored
77
#'
8-
#' @aliases repr_html.function repr_latex.function repr_markdown.function
98
#' @name repr_*.function
109
#' @include utils.r
1110
NULL

R/repr_help_files_with_topic.r

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#' @param obj Help topic to create a representation for
66
#' @param ... ignored
77
#'
8-
#' @aliases repr_text.help_files_with_topic repr_html.help_files_with_topic repr_latex.help_files_with_topic
98
#' @name repr_*.help_files_with_topic
109
NULL
1110

R/repr_list.r

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#' @param obj The list to create a representation for
44
#' @param ... ignored
55
#'
6-
#' @aliases repr_html.list repr_markdown.list repr_latex.list
76
#' @name repr_*.list
87
#' @include utils.r
98
NULL

R/repr_matrix_df.r

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#' Tabular data representations
22
#'
3-
#' HTML and LaTeX representations of Matrix-like objects
3+
#' HTML, LaTeX, and Markdown representations of Matrix-like objects
44
#'
55
#' @param obj The matrix or data.frame to create a representation for
66
#' @param ... ignored
77
#' @param colspec The colspec for the LaTeX table. The default is given by the option \code{repr.matrix.latex.colspec}
88
#'
99
#' @seealso \link{repr-options} for \code{repr.matrix.latex.colspec}
1010
#'
11-
#' @aliases repr_html.matrix repr_html.data.frame repr_latex.matrix repr_latex.data.frame
1211
#' @name repr_*.matrix/data.frame
1312
#' @include utils.r
1413
NULL

R/repr_recordedplot.r

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ plot_title <- function(p, default = NULL) {
4747
#'
4848
#' repr_text(p)
4949
#'
50-
#' @aliases repr_text.recordedplot repr_png.recordedplot repr_jpg.recordedplot repr_svg.recordedplot repr_pdf.recordedplot
5150
#' @name repr_*.recordedplot
5251
#' @export
5352
repr_text.recordedplot <- function(obj, ...) {

R/repr_ts.r

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#' Time series representations
2+
#'
3+
#' HTML, LaTeX, and Markdown representations of \link[stats]{ts} objects.
4+
#'
5+
#' @param obj The \link[stats]{ts} object to create a representation for
6+
#' @param ... ignored
7+
#' @param colspec The colspec for the LaTeX table. The default is given by the option \code{repr.matrix.latex.colspec}
8+
#'
9+
#' @seealso \link{repr-options} for \code{repr.matrix.latex.colspec}
10+
#'
11+
#' @importFrom stats ts .preformat.ts
12+
#' @name repr_*.ts
13+
NULL
14+
15+
repr_ts_generic <- function(obj, repr_func, ...) {
16+
m <- .preformat.ts(obj)
17+
# set rows and cols so the whole thing is always displayed
18+
repr_func(m, ..., rows = nrow(m), cols = ncol(m))
19+
}
20+
21+
#' @name repr_*.ts
22+
#' @export
23+
repr_html.ts <- function(obj, ...) repr_ts_generic(obj, repr_html.matrix, ...)
24+
25+
#' @name repr_*.ts
26+
#' @export
27+
repr_latex.ts <- function(obj, ...) repr_ts_generic(obj, repr_latex.matrix, ...)
28+
29+
#' @name repr_*.ts
30+
#' @export
31+
repr_markdown.ts <- function(obj, ...) repr_ts_generic(obj, repr_markdown.matrix, ...)
32+
33+
#' @name repr_*.ts
34+
#' @export
35+
repr_text.ts <- function(obj, ...) repr_ts_generic(obj, repr_text.matrix, ...)

0 commit comments

Comments
 (0)