Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 2218
1
\documentclass{article}\usepackage[]{graphicx}\usepackage[]{color}
2
%% maxwidth is the original width if it is less than linewidth
3
%% otherwise use linewidth (to make sure the graphics do not exceed the margin)
4
\makeatletter
5
\def\maxwidth{ %
6
\ifdim\Gin@nat@width>\linewidth
7
\linewidth
8
\else
9
\Gin@nat@width
10
\fi
11
}
12
\makeatother
13
14
\definecolor{fgcolor}{rgb}{0.345, 0.345, 0.345}
15
\newcommand{\hlnum}[1]{\textcolor[rgb]{0.686,0.059,0.569}{#1}}%
16
\newcommand{\hlstr}[1]{\textcolor[rgb]{0.192,0.494,0.8}{#1}}%
17
\newcommand{\hlcom}[1]{\textcolor[rgb]{0.678,0.584,0.686}{\textit{#1}}}%
18
\newcommand{\hlopt}[1]{\textcolor[rgb]{0,0,0}{#1}}%
19
\newcommand{\hlstd}[1]{\textcolor[rgb]{0.345,0.345,0.345}{#1}}%
20
\newcommand{\hlkwa}[1]{\textcolor[rgb]{0.161,0.373,0.58}{\textbf{#1}}}%
21
\newcommand{\hlkwb}[1]{\textcolor[rgb]{0.69,0.353,0.396}{#1}}%
22
\newcommand{\hlkwc}[1]{\textcolor[rgb]{0.333,0.667,0.333}{#1}}%
23
\newcommand{\hlkwd}[1]{\textcolor[rgb]{0.737,0.353,0.396}{\textbf{#1}}}%
24
\let\hlipl\hlkwb
25
26
\usepackage{framed}
27
\makeatletter
28
\newenvironment{kframe}{%
29
\def\at@end@of@kframe{}%
30
\ifinner\ifhmode%
31
\def\at@end@of@kframe{\end{minipage}}%
32
\begin{minipage}{\columnwidth}%
33
\fi\fi%
34
\def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep
35
\colorbox{shadecolor}{##1}\hskip-\fboxsep
36
% There is no \\@totalrightmargin, so:
37
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
38
\MakeFramed {\advance\hsize-\width
39
\@totalleftmargin\z@ \linewidth\hsize
40
\@setminipage}}%
41
{\par\unskip\endMakeFramed%
42
\at@end@of@kframe}
43
\makeatother
44
45
\definecolor{shadecolor}{rgb}{.97, .97, .97}
46
\definecolor{messagecolor}{rgb}{0, 0, 0}
47
\definecolor{warningcolor}{rgb}{1, 0, 1}
48
\definecolor{errorcolor}{rgb}{1, 0, 0}
49
\newenvironment{knitrout}{}{} % an empty environment to be redefined in TeX
50
51
\usepackage{alltt}
52
\usepackage[utf8]{inputenc}
53
\usepackage[T1]{fontenc}
54
\usepackage{url}
55
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
56
\begin{document}
57
58
% learn more about knitr: https://yihui.name/knitr/
59
60
61
62
\title{Knitr dans CoCalc}
63
64
\author{Juanito Alima\~na}
65
66
\maketitle
67
68
Comme SageTeX, mais avec R. Le principe est essentiellement le même.
69
70
\medskip
71
72
\begin{center}
73
\begin{knitrout}
74
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}
75
\begin{tabular}{l|r}
76
\hline
77
Min. & 1.000000\\
78
\hline
79
1st Qu. & 2.000000\\
80
\hline
81
Median & 2.000000\\
82
\hline
83
Mean & 2.555556\\
84
\hline
85
3rd Qu. & 3.000000\\
86
\hline
87
Max. & 5.000000\\
88
\hline
89
\end{tabular}
90
91
92
\end{knitrout}
93
\end{center}
94
95
\begin{figure}[h!]
96
\centering
97
\begin{knitrout}
98
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}
99
\includegraphics[width=.4\linewidth]{figure/histogram-plot-1}
100
101
\end{knitrout}
102
\caption{Voici l'histogramme}
103
\end{figure}
104
105
Sum of 2 + 3 + 4 + 5 + 1 + 2 + 3 + 2 + 1 is 23.
106
107
\medskip
108
109
Voyons une tableau
110
111
112
\begin{knitrout}
113
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}
114
\begin{tabular}{l|r|r|r|r}
115
\hline
116
& Estimate & Std. Error & t value & Pr(>|t|)\\
117
\hline
118
(Intercept) & 0.05 & 0.11 & 0.45 & 0.65\\
119
\hline
120
x & 2.01 & 0.10 & 19.45 & 0.00\\
121
\hline
122
\end{tabular}
123
124
125
\end{knitrout}
126
127
\end{document}
128
129
130
131