\documentclass[hyperref={dvips,colorlink,bookmarks}]{beamer}
\mode {
\definecolor{one}{rgb}{0.2,0.5,0.9} %0.1
\usecolortheme[named=one]{structure}
\usetheme{Madrid} %CambridgeUS Szeged
\useinnertheme{rectangles}
%\usecolortheme{rose}
\usepackage{multimedia}
\usepackage{amssymb,graphicx,listings}
\useoutertheme{infolines} %miniframes infolines
}
\title{Demo R}
\author{Advanced stat TA}
\institute{NTU AGEC}
\date{\today}
\begin{document}
\lstset{numbers=left,tabsize=5,numberstyle=\tiny,
keywordstyle=\color{blue!80},
commentstyle=\color{black!40!green!100},
basicstyle=\scriptsize,stepnumber=1,numbersep=5pt, language={R}}
\frame{\titlepage}
\frame{\frametitle{Demo 1}
\begin{block}{Ex1.1-4}
EX1.1-3 The $National \; geographic$
reported the following litter sizes for 20 lions.
\end{block}
\begin{itemize}
\item Construct a freq table. (\textcolor{blue}{stem() ,table(),length()})
\item Draw a freq histogram. (\textcolor{blue}{barplot()} )
\item Draw a relative freq histogram.
\item Is there a typical litter size.
\end{itemize}
Making yourself R
\begin{enumerate} []
\item locate your data file. (\textcolor{blue}{setwd()})
\item import data from the working space.(\textcolor{blue}{scan()})
\item coding…
\end{enumerate}
}
\begin{frame}[fragile]
\frametitle{Demo1 code}
\begin{block}{}
\begin{lstlisting}
setwd("c:/data/advsta")
one<-scan("Exercise 1_1-03.txt",sep=",")
#Q1-1
stem(one)
t1=table(one)
t2=t1/length(one)
#Q1-2~4
par(mfrow=c(1,2),bg="white",col.axis="black")
barplot(t1,ylab="Freq")
text(2,9,"<=typical little size",col="blue",cex=1,adj = c(-0.4,0))
barplot(t2,ylab="Density",col="lightblue")
\end{lstlisting}
\end{block}
\end{frame}
\begin{frame}
\frametitle{Demo2}
\begin{block}{Ex1.1-4}
Some ornithologists were interested in the clutch size of the common gallinule.
Thye observed the number of eggs in each of 117 nests.
\end{block}
\begin{itemize}
\item Construct a freq table.
\item Draw a histogram.
\item What is the mode?
\end{itemize}
\end{frame}
\end{document}