Commit aba266e0 authored by Guilherme Hathy's avatar Guilherme Hathy

primeira versão do bookdown

parent 54f8c467
^.*\.Rproj$
^\.Rproj\.user$
.Rproj.user
.Rhistory
.RData
.Ruserdata
# Filosofia e conceitos iniciais sobre software livre e R
# Essencial
## Instalação e interfaces
## Funções e argumentos
## Objetos e suas classes
## Valores perdidos e especiais
## Manipulação de dados: Indexação e seleção condicional
\ No newline at end of file
# Dados
## Importação e exportação de dados
## Lendo dados de uma URL
\ No newline at end of file
# Analise exploratória de dados
## Funções para resumos de dados
## Gráficos exploratórios
## Sistemas Gráficos
## Gráficos Básicos
## Sistema de cores
## Gráficos com o pacote Lattice
## Gráficos com o pacote ggplot2
\ No newline at end of file
# Estatística
## Geração de números aleatórios
## Distribuição de probabilidade
## Intervalos de confiança e teste de hipótese
## Regressão linear e ANOVA
\ No newline at end of file
#Programação
##Estruturas de controle e repetição
##Criando funções
Assim como em outras linguagens de programação, no R é possível criar funções, que são muito úteis para executar um bloco de código que será repetido varias vezes, economizando linhas de códigos. A sintaxe para definir funções no R é:
```{r pressure, echo=TRUE}
Nome_funcao <- function(argumento1, argumento2, ... ){
Comandos
}
```
**Nome_funcao**
Para criar uma função é preciso primeiramente definir um nome seguido do comando *function()*, depois de pronta, a função será executada usando o nome que foi atribuido.
##A família de funções apply()
\ No newline at end of file
# Linguagens de marcação
## LaTeX
##Markdown
\ No newline at end of file
Package: placeholder
Title: Does not matter.
Version: 0.0.1
Imports: bookdown
Remotes: rstudio/bookdown
CC0 1.0 Universal
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator and
subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for the
purpose of contributing to a commons of creative, cultural and scientific
works ("Commons") that the public can reliably and without fear of later
claims of infringement build upon, modify, incorporate in other works, reuse
and redistribute as freely as possible in any form whatsoever and for any
purposes, including without limitation commercial purposes. These owners may
contribute to the Commons to promote the ideal of a free culture and the
further production of creative, cultural and scientific works, or to gain
reputation or greater distribution for their Work in part through the use and
efforts of others.
For these and/or other purposes and motivations, and without any expectation
of additional consideration or compensation, the person associating CC0 with a
Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
and publicly distribute the Work under its terms, with knowledge of his or her
Copyright and Related Rights in the Work and the meaning and intended legal
effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not limited
to, the following:
i. the right to reproduce, adapt, distribute, perform, display, communicate,
and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or likeness
depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data in
a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation thereof,
including any amended or successor version of such directive); and
vii. other similar, equivalent or corresponding rights throughout the world
based on applicable law or treaty, and any national implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention of,
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
and Related Rights and associated claims and causes of action, whether now
known or unknown (including existing as well as future claims and causes of
action), in the Work (i) in all territories worldwide, (ii) for the maximum
duration provided by applicable law or treaty (including future time
extensions), (iii) in any current or future medium and for any number of
copies, and (iv) for any purpose whatsoever, including without limitation
commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
the Waiver for the benefit of each member of the public at large and to the
detriment of Affirmer's heirs and successors, fully intending that such Waiver
shall not be subject to revocation, rescission, cancellation, termination, or
any other legal or equitable action to disrupt the quiet enjoyment of the Work
by the public as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason be
judged legally invalid or ineffective under applicable law, then the Waiver
shall be preserved to the maximum extent permitted taking into account
Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
is so judged Affirmer hereby grants to each affected person a royalty-free,
non transferable, non sublicensable, non exclusive, irrevocable and
unconditional license to exercise Affirmer's Copyright and Related Rights in
the Work (i) in all territories worldwide, (ii) for the maximum duration
provided by applicable law or treaty (including future time extensions), (iii)
in any current or future medium and for any number of copies, and (iv) for any
purpose whatsoever, including without limitation commercial, advertising or
promotional purposes (the "License"). The License shall be deemed effective as
of the date CC0 was applied by Affirmer to the Work. Should any part of the
License for any reason be judged legally invalid or ineffective under
applicable law, such partial invalidity or ineffectiveness shall not
invalidate the remainder of the License, and in such case Affirmer hereby
affirms that he or she will not (i) exercise any of his or her remaining
Copyright and Related Rights in the Work or (ii) assert any associated claims
and causes of action with respect to the Work, in either case contrary to
Affirmer's express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or warranties
of any kind concerning the Work, express, implied, statutory or otherwise,
including without limitation warranties of title, merchantability, fitness
for a particular purpose, non infringement, or the absence of latent or
other defects, accuracy, or the present or absence of errors, whether or not
discoverable, all to the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without limitation
any person's Copyright and Related Rights in the Work. Further, Affirmer
disclaims responsibility for obtaining any necessary consents, permissions
or other rights required for any use of the Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to this
CC0 or use of the Work.
For more information, please see
<http://creativecommons.org/publicdomain/zero/1.0/>
\documentclass[]{book}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\else % if luatex or xelatex
\ifxetex
\usepackage{mathspec}
\else
\usepackage{fontspec}
\fi
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\usepackage[margin=1in]{geometry}
\usepackage{hyperref}
\hypersetup{unicode=true,
pdftitle={Apostila R},
pdfauthor={PET- Estatistica},
pdfborder={0 0 0},
breaklinks=true}
\urlstyle{same} % don't use monospace font for urls
\usepackage{natbib}
\bibliographystyle{apalike}
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{248,248,248}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{{#1}}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{{#1}}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{{#1}}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{{#1}}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{{#1}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{{#1}}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{{#1}}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{{#1}}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{{#1}}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{{#1}}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{{#1}}}
\newcommand{\ImportTok}[1]{{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{{#1}}}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{{#1}}}}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{{#1}}}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{{#1}}}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{{#1}}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{{#1}}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{{#1}}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{{#1}}}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.81,0.36,0.00}{\textbf{{#1}}}}
\newcommand{\BuiltInTok}[1]{{#1}}
\newcommand{\ExtensionTok}[1]{{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{{#1}}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.77,0.63,0.00}{{#1}}}
\newcommand{\RegionMarkerTok}[1]{{#1}}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{{#1}}}}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{{#1}}}}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.94,0.16,0.16}{{#1}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.64,0.00,0.00}{\textbf{{#1}}}}
\newcommand{\NormalTok}[1]{{#1}}
\usepackage{longtable,booktabs}
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{5}
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
%%% Use protect on footnotes to avoid problems with footnotes in titles
\let\rmarkdownfootnote\footnote%
\def\footnote{\protect\rmarkdownfootnote}
%%% Change title format to be more compact
\usepackage{titling}
% Create subtitle command for use in maketitle
\newcommand{\subtitle}[1]{
\posttitle{
\begin{center}\large#1\end{center}
}
}
\setlength{\droptitle}{-2em}
\title{Apostila R}
\pretitle{\vspace{\droptitle}\centering\huge}
\posttitle{\par}
\author{PET- Estatistica}
\preauthor{\centering\large\emph}
\postauthor{\par}
\predate{\centering\large\emph}
\postdate{\par}
\date{2016-11-30}
\usepackage{booktabs}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\begin{document}
\maketitle
{
\setcounter{tocdepth}{1}
\tableofcontents
}
\chapter{Filosofia e conceitos iniciais sobre software livre e
R}\label{filosofia-e-conceitos-iniciais-sobre-software-livre-e-r}
\chapter{Essencial}\label{essencial}
\section{Instalação e interfaces}\label{instalacao-e-interfaces}
\section{Funções e argumentos}\label{funcoes-e-argumentos}
\section{Objetos e suas classes}\label{objetos-e-suas-classes}
\section{Valores perdidos e
especiais}\label{valores-perdidos-e-especiais}
\section{Manipulação de dados: Indexação e seleção
condicional}\label{manipulacao-de-dados-indexacao-e-selecao-condicional}
\chapter{Dados}\label{dados}
\section{Importação e exportação de
dados}\label{importacao-e-exportacao-de-dados}
\section{Lendo dados de uma URL}\label{lendo-dados-de-uma-url}
\chapter{Analise exploratória de
dados}\label{analise-exploratoria-de-dados}
\section{Funções para resumos de
dados}\label{funcoes-para-resumos-de-dados}
\section{Gráficos exploratórios}\label{graficos-exploratorios}
\section{Sistemas Gráficos}\label{sistemas-graficos}
\section{Gráficos Básicos}\label{graficos-basicos}
\section{Sistema de cores}\label{sistema-de-cores}
\section{Gráficos com o pacote
Lattice}\label{graficos-com-o-pacote-lattice}
\section{Gráficos com o pacote
ggplot2}\label{graficos-com-o-pacote-ggplot2}
\chapter{Estatística}\label{estatistica}
\section{Geração de números
aleatórios}\label{geracao-de-numeros-aleatorios}
\section{Distribuição de
probabilidade}\label{distribuicao-de-probabilidade}
\section{Intervalos de confiança e teste de
hipótese}\label{intervalos-de-confianca-e-teste-de-hipotese}
\section{Regressão linear e ANOVA}\label{regressao-linear-e-anova}
\chapter{Programação}\label{programacao}
\section{Estruturas de controle e
repetição}\label{estruturas-de-controle-e-repeticao}
\section{Criando funções}\label{criando-funcoes}
Assim como em outras linguagens de programação, no R é possível criar
funções, que são muito úteis para executar um bloco de código que será
repetido varias vezes, economizando linhas de códigos. A sintaxe para
definir funções no R é:
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{Nome_funcao <-}\StringTok{ }\NormalTok{function(argumento1, argumento2, ... )\{}
\NormalTok{Comandos}
\NormalTok{\}}
\end{Highlighting}
\end{Shaded}
\textbf{Nome\_funcao}
Para criar uma função é preciso primeiramente definir um nome seguido do
comando \emph{function()}, depois de pronta, a função será executada
usando o nome que foi atribuido.
\section{A família de funções apply()}\label{a-familia-de-funcoes-apply}
\chapter{Linguagens de marcação}\label{linguagens-de-marcacao}
\section{LaTeX}\label{latex}
\section{Markdown}\label{markdown}
\bibliography{referencias.bib}
\end{document}
book_filename: "bookdown-demo"
language:
label:
fig: 'Figura '
tab: 'Tabela '
eq: 'Equação '
thm: 'Teorema '
lem: 'Lemma '
def: 'Definition '
cor: 'Corollary '
prp: 'Proposition '
ex: 'Exemplo '
proof: 'Proof. '
remark: 'Remark. '
ui:
chapter_name: "Capítulo "
#!/bin/sh
Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::gitbook')"
#!/bin/sh
set -e
[ -z "${GITHUB_PAT}" ] && exit 0
[ "${TRAVIS_BRANCH}" != "master" ] && exit 0
git config --global user.email "xie@yihui.name"
git config --global user.name "Yihui Xie"
git clone -b gh-pages https://${GITHUB_PAT}@github.com/${TRAVIS_REPO_SLUG}.git book-output
cd book-output
cp -r ../_book/* ./
git add --all *
git commit -m"Update the book" || true
git push origin gh-pages
bookdown::pdf_book:
includes:
in_header: preamble.tex
latex_engine: xelatex
citation_package: natbib
keep_tex: yes
bookdown::epub_book: default
bookdown::gitbook:
css: style.css
config:
toc:
before: |
<li><a href="./">A Minimal Book Example</a></li>
after: |
<li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>
edit: https://github.com/rstudio/bookdown-demo/edit/master/%s
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: knitr
LaTeX: pdfLaTeX
AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
BuildType: Website
This diff is collapsed.
---
output:
pdf_document:
toc: yes
html_document:
toc: true
toc_float: true
number_sections: true
number_sections: yes
toc: yes
toc_float: yes
---
.
......
---
title: "Apostila R"
author: "PET- Estatistica"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
output: bookdown::gitbook
documentclass: book
bibliography: [referencias.bib]
biblio-style: apalike
link-citations: yes
github-repo: rstudio/bookdown-demo
---
\usepackage{booktabs}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\ No newline at end of file
@article{kahneman1979prospect,
title={Prospect theory: An analysis of decision under risk},
author={Kahneman, Daniel and Tversky, Amos},
journal={Econometrica: Journal of the econometric society},
pages={263--291},
year={1979},
publisher={JSTOR}
}
@article{barber2014day,
title={Do day traders rationally learn about their ability?},
author={Barber, Brad M and Lee, Yi-Tsung and Liu, Yu-Jane and Odean, Terrance},
journal={Available at SSRN 2535636},
year={2014}
}
@article{list2004neoclassical,
title={Neoclassical theory versus prospect theory: Evidence from the marketplace},
author={List, John A},
journal={Econometrica},
volume={72},
number={2},
pages={615--625},
year={2004},
publisher={Wiley Online Library}
}
@article{shefrin1985disposition,
title={The disposition to sell winners too early and ride losers too long: Theory and evidence},
author={Shefrin, Hersh and Statman, Meir},
journal={The Journal of finance},
volume={40},
number={3},
pages={777--790},
year={1985},
publisher={Wiley Online Library}
}
@book{james2013introduction,
title={An introduction to statistical learning},
author={James, Gareth and Witten, Daniela and Hastie, Trevor and Tibshirani, Robert},
volume={6},
year={2013},
publisher={Springer}
}
p.caption {
color: #777;
margin-top: 10px;
}
p code {
white-space: inherit;
}
pre {
word-break: normal;
word-wrap: normal;
}
pre code {
white-space: inherit;
}
#TOC ul,
#TOC li,
#TOC span,
#TOC a {
margin: 0;
padding: 0;
position: relative;
}
#TOC {
line-height: 1;
border-radius: 5px 5px 0 0;
background: #141414;
background: linear-gradient(to bottom, #333333 0%, #141414 100%);
border-bottom: 2px solid #0fa1e0;
width: auto;
}
#TOC:after,
#TOC ul:after {
content: '';
display: block;
clear: both;
}
#TOC a {
background: #141414;
background: linear-gradient(to bottom, #333333 0%, #141414 100%);
color: #ffffff;
display: block;
padding: 19px 20px;
text-decoration: none;
text-shadow: none;
}
#TOC ul {
list-style: none;
}
#TOC > ul > li {
display: inline-block;
float: left;
margin: 0;
}
#TOC > ul > li > a {
color: #ffffff;
}
#TOC > ul > li:hover:after {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
left: 50%;
bottom: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #0fa1e0;
margin-left: -10px;
}
#TOC > ul > li:first-child > a {
border-radius: 5px 0 0 0;
}
#TOC.align-right > ul > li:first-child > a,
#TOC.align-center > ul > li:first-child > a {
border-radius: 0;
}
#TOC.align-right > ul > li:last-child > a {
border-radius: 0 5px 0 0;
}
#TOC > ul > li.active > a,
#TOC > ul > li:hover > a {
color: #ffffff;
box-shadow: inset 0 0 3px #000000;
background: #070707;
background: linear-gradient(to bottom, #262626 0%, #070707 100%);
}
#TOC .has-sub {
z-index: 1;
}
#TOC .has-sub:hover > ul {
display: block;
}
#TOC .has-sub ul {
display: none;
position: absolute;
width: 200px;
top: 100%;
left: 0;
}
#TOC .has-sub ul li a {
background: #0fa1e0;
border-bottom: 1px dotted #31b7f1;
filter: none;
display: block;
line-height: 120%;
padding: 10px;
color: #ffffff;
}
#TOC .has-sub ul li:hover a {
background: #0c7fb0;
}
#TOC ul ul li:hover > a {
color: #ffffff;
}
#TOC .has-sub .has-sub:hover > ul {
display: block;
}
#TOC .has-sub .has-sub ul {
display: none;
position: absolute;
left: 100%;
top: 0;
}
#TOC .has-sub .has-sub ul li a {
background: #0c7fb0;
border-bottom: 1px dotted #31b7f1;
}
#TOC .has-sub .has-sub ul li a:hover {
background: #0a6d98;
}
#TOC ul ul li.last > a,
#TOC ul ul li:last-child > a,
#TOC ul ul ul li.last > a,
#TOC ul ul ul li:last-child