%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Tufte-Style Book (Documentation Template)
% LaTeX Template
% Version 1.0 (5/1/13)
%
% This template has been downloaded from:
% http://www.LaTeXTemplates.com
%
% Original author:
% The Tufte-LaTeX Developers (tufte-latex.googlecode.com)
%
% License:
% Apache License (Version 2.0)
%
% IMPORTANT NOTE:
% In addition to running BibTeX to compile the reference list from the .bib
% file, you will need to run MakeIndex to compile the index at the end of the
% document.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----------------------------------------------------------------------------------------
% PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------
\documentclass{tufte-book}
\hypersetup{colorlinks}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{graphicx} % Needed to insert images into the document
\usepackage{listings} % Required for insertion of code
\graphicspath{{graphics/}} % Sets the default location of pictures
\setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio} % Improves figure scaling
\usepackage[all]{xy}
\usepackage{amsmath,amsthm,amssymb,graphicx,tikz,fancyhdr,hyperref,natbib}
\usepackage{graphicx,hyperref,fancyhdr,amsmath,amssymb,mathrsfs,color,xspace,pdflscape}
\usepackage{fancyvrb} % Allows customization of verbatim environments
\fvset{fontsize=\normalsize} % The font size of all verbatim text can be changed here
\newcommand{\hangp}[1]{\makebox[0pt][r]{(}#1\makebox[0pt][l]{)}} % New command to create parentheses around text in tables which take up no horizontal space - this improves column spacing
\newcommand{\hangstar}{\makebox[0pt][l]{*}} % New command to create asterisks in tables which take up no horizontal space - this improves column spacing
\usepackage{xspace} % Used for printing a trailing space better than using a tilde (~) using the \xspace command
\newcommand{\monthyear}{\ifcase\month\or January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi\space\number\year} % A command to print the current month and year
\newcommand{\openepigraph}[2]{ % This block sets up a command for printing an epigraph with 2 arguments - the quote and the author
\begin{fullwidth}
\sffamily\large
\begin{doublespace}
\noindent\allcaps{#1}\\ % The quote
\noindent\allcaps{#2} % The author
\end{doublespace}
\end{fullwidth}
}
\newcommand{\blankpage}{\newpage\hbox{}\thispagestyle{empty}\newpage} % Command to insert a blank page
\usepackage{units} % Used for printing standard units
\usepackage[usenames,dvipsnames]{color,xcolor}
\newcommand{\hlred}[1]{\textcolor{Maroon}{#1}} % Print text in maroon
\newcommand{\hangleft}[1]{\makebox[0pt][r]{#1}} % Used for printing commands in the index, moves the slash left so the command name aligns with the rest of the text in the index
\newcommand{\hairsp}{\hspace{1pt}} % Command to print a very short space
\newcommand{\ie}{\textit{i.\hairsp{}e.}\xspace} % Command to print i.e.
\newcommand{\eg}{\textit{e.\hairsp{}g.}\xspace} % Command to print e.g.
\newcommand{\na}{\quad--} % Used in tables for N/A cells
\newcommand{\measure}[3]{#1/#2$\times$\unit[#3]{pc}} % Typesets the font size, leading, and measure in the form of: 10/12x26 pc.
\newcommand{\tuftebs}{\symbol{'134}} % Command to print a backslash in tt type in OT1/T1
\providecommand{\XeLaTeX}{X\lower.5ex\hbox{\kern-0.15em\reflectbox{E}}\kern-0.1em\LaTeX}
\newcommand{\tXeLaTeX}{\XeLaTeX\index{XeLaTeX@\protect\XeLaTeX}} % Command to print the XeLaTeX logo while simultaneously adding the position to the index
\newcommand{\doccmdnoindex}[2][]{\texttt{\tuftebs#2}} % Command to print a command in texttt with a backslash of tt type without inserting the command into the index
\newcommand{\doccmddef}[2][]{\hlred{\texttt{\tuftebs#2}}\label{cmd:#2}\ifthenelse{\isempty{#1}} % Command to define a command in red and add it to the index
{ % If no package is specified, add the command to the index
\index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2}}% Command name
}
{ % If a package is also specified as a second argument, add the command and package to the index
\index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2} (\texttt{#1} package)}% Command name
\index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}% Package name
}}
\newcommand{\doccmd}[2][]{% Command to define a command and add it to the index
\texttt{\tuftebs#2}%
\ifthenelse{\isempty{#1}}% If no package is specified, add the command to the index
{%
\index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2}}% Command name
}
{%
\index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2} (\texttt{#1} package)}% Command name
\index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}% Package name
}}
% A bunch of new commands to print commands, arguments, environments, classes, etc within the text using the correct formatting
\newcommand{\docopt}[1]{\ensuremath{\langle}\textrm{\textit{#1}}\ensuremath{\rangle}}
\newcommand{\docarg}[1]{\textrm{\textit{#1}}}
\newenvironment{docspec}{\begin{quotation}\ttfamily\parskip0pt\parindent0pt\ignorespaces}{\end{quotation}}
\newcommand{\docenv}[1]{\texttt{#1}\index{#1 environment@\texttt{#1} environment}\index{environments!#1@\texttt{#1}}}
\newcommand{\docenvdef}[1]{\hlred{\texttt{#1}}\label{env:#1}\index{#1 environment@\texttt{#1} environment}\index{environments!#1@\texttt{#1}}}
\newcommand{\docpkg}[1]{\texttt{#1}\index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}}
\newcommand{\doccls}[1]{\texttt{#1}}
\newcommand{\docclsopt}[1]{\texttt{#1}\index{#1 class option@\texttt{#1} class option}\index{class options!#1@\texttt{#1}}}
\newcommand{\docclsoptdef}[1]{\hlred{\texttt{#1}}\label{clsopt:#1}\index{#1 class option@\texttt{#1} class option}\index{class options!#1@\texttt{#1}}}
\newcommand{\docmsg}[2]{\bigskip\begin{fullwidth}\noindent\ttfamily#1\end{fullwidth}\medskip\par\noindent#2}
\newcommand{\docfilehook}[2]{\texttt{#1}\index{file hooks!#2}\index{#1@\texttt{#1}}}
\newcommand{\doccounter}[1]{\texttt{#1}\index{#1 counter@\texttt{#1} counter}}
\usepackage{tcolorbox}
\newtcolorbox{mybox}{boxrule=0pt,width=(\linewidth), arc=0mm,colback=gray!20}
\usepackage{makeidx} % Used to generate the index
\makeindex % Generate the index which is printed at the end of the document
%
% This block contains a number of shortcuts used throughout the book
\newcommand{\vdqi}{\textit{VDQI}\xspace}
\newcommand{\ei}{\textit{EI}\xspace}
\newcommand{\ve}{\textit{VE}\xspace}
\newcommand{\be}{\textit{BE}\xspace}
\newcommand{\VDQI}{\textit{The Visual Display of Quantitative Information}\xspace}
\newcommand{\EI}{\textit{Envisioning Information}\xspace}
\newcommand{\VE}{\textit{Visual Explanations}\xspace}
\newcommand{\BE}{\textit{Beautiful Evidence}\xspace}
\newcommand{\TL}{Tufte-\LaTeX\xspace}
\usepackage{Sweave}
\usepackage[usenames,dvipsnames]{color,xcolor}
\usepackage{listings}
\usepackage{hyperref}
\usepackage{xepersian}
\settextfont{XB Zar}
\setdigitfont{XB Zar}
\setlatintextfont{Times New Roman}
%----------------------------------------------------------------------------------------
% BOOK META-INFORMATION
%----------------------------------------------------------------------------------------
\title{ با استفاده از نرم افزار \lr{R} }
\author{رضا هادی زاده}
\publisher{انتشارات علمی پارسیان}
%----------------------------------------------------------------------------------------
\begin{document }
\frontmatter
%----------------------------------------------------------------------------------------
% EPIGRAPH
%----------------------------------------------------------------------------------------
\thispagestyle{empty}
%\openepigraph{این کتاب آر است.}{رضا هادی زاده, {\itshape Design, Form, and Chaos}}
%\vfill
%\openepigraph{A designer knows that he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away.}{Antoine de Saint-Exup\'{e}ry}
%\vfill
%\openepigraph{\ldots the designer of a new system must not only be the implementor and the first large-scale user; the designer should also write the first user manual\ldots If I had not participated fully in all these activities, literally hundreds of improvements would never have been made, because I would never have thought of them or perceived why they were important.}{Donald E. Knuth}
%----------------------------------------------------------------------------------------
\maketitle % Print the title page
%----------------------------------------------------------------------------------------
% COPYRIGHT PAGE
%----------------------------------------------------------------------------------------
\newpage
\begin{fullwidth}
~\vfill
\thispagestyle{empty}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
Copyright \copyright\ \the\year\ \thanklessauthor
\par\smallcaps{Published by \thanklesspublisher}
\par\smallcaps{tufte-latex.googlecode.com}
\par Licensed under the Apache License, Version 2.0 (the ``License''); you may not use this file except in compliance with the License. You may obtain a copy of the License at \url{http://www.apache.org/licenses/LICENSE-2.0}. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \smallcaps{``AS IS'' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND}, either express or implied. See the License for the specific language governing permissions and limitations under the License.\index{license}
\par\textit{First printing, \monthyear}
\end{fullwidth}
%----------------------------------------------------------------------------------------
\tableofcontents
\listoffigures
\listoftables
%----------------------------------------------------------------------------------------
% DEDICATION PAGE
%----------------------------------------------------------------------------------------
\cleardoublepage
~\vfill
\begin{doublespace}
\noindent\fontsize{18}{22}\selectfont\itshape
\nohyphenation
Dedicated to those who appreciate \LaTeX{} and the work of \mbox{Edward R.~Tufte} and \mbox{Donald E.~Knuth}.
\end{doublespace}
\vfill
\vfill
%----------------------------------------------------------------------------------------
% INTRODUCTION
%----------------------------------------------------------------------------------------
\cleardoublepage
\chapter*{مقدمه}
\fancyhead[LE]{.... }
\fancyhead[RO]{مقدمه}
\mainmatter
%----------------------------------------------------------------------------------------
% CHAPTER 1
%----------------------------------------------------------------------------------------
\chapter{آشنایی با زبان برنامه نویسی نرم افزار \lr{R}}
\label{ch:فصل 1}
آرگومان \lr{format} براي مشخص كردن فرمت ورودى تاريخ اگر بصورت پيش فرض نباشد بكار مى رود.
توجه كنيد كه فرمت خروجي هميشه به شكل \lr{"YYYY-m-d"} بدون در نظر گرفتن فرمت ورودى است. براي تغيير دادن فرمت ورودى نمايش داده شده يك تاريخ از تابع \lr{format()} استفاده مى شود:
برخی از فرمت های تاریخ اطلاعات کافی را به واضح به عنوان یک شیء \lr{Date} ارائه نمی کنند. مثلاً،
جدول \ref{tab5} كدهاى فرمت هاى تاريخ استاندارد را ارائه مى دهد.
شبکه عبارتست از مجموعه یا سیستم درون پیوندی انسانی یا فیزیکی که دسترسی به قابلیت یا توانایی خاصی را در محدوده ای از مکان و زمان فراهم می کند و در حالت مطلوب محدودیت مکانی و زمانی ندارد. ساختار شبکه، بعنوان یک سیستم پیچیده شناخته می شود. بسیاری از سیستم های دنیای واقعی مانند سیستم های اجتماعی، سایبری و بیولوژیکی كه می تواند دارای پيچيدگی هايی باشد را از طريق شبكه مدل سازی كرد و به تجزيه و تحليل اين سيستم ها پرداخت.
\begin{latin}
\begin{lstlisting}[language=R]
> my.date = as.Date("1970/1/1")
> my.date
[1] "1970-01-01"
> class(my.date)
[1] "Date"
> as.numeric(my.date)
[1] 0
> myDates = c("2013-12-19", "2003-12-20")
> as.Date(myDates)
[1] "2013-12-19" "2003-12-20"
\end{lstlisting}
\end{latin}
به یاد بیاورید، تاریخ ها در داخل به عنوان تعداد (صحیح) روزها از 01-01-1970 ثبت شده است. در نتیجه، می توان یک شی \lr{Date} را از داده های صحیح ایجاد کرد. یکی از راه های تبدیل یک متغیر صحیح به یک شی\lr{Date}، استفاده از تابع \lr{class ()} است.
\end{document}