R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

x <- 12

x <- c(15,40,10,25,26,33)

x
## [1] 15 40 10 25 26 33
print(x)
## [1] 15 40 10 25 26 33
plot(x)

x<-c(15,40,10,25,26,33) 

prod(x)
## [1] 128700000
n <- 6
prod(x)^(1/n)
## [1] 22.46966
summary(x)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   10.00   17.50   25.50   24.83   31.25   40.00
cons_pessoal <- data.frame(ano=c(1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992, + 1993,1994,1995,1996),dcp=c(3081.5,3240.6,3407.6,3566.5,3708.7,3822.3,3972.7,4064.6,4132.2, + 4105.8,4219.8,4343.6,4486.0,4595.3,4714.1),pib=c(4620.3,4803.7,5140.1,5323.5,5487.7,5649.5, + 5865.2,6062.0,6136.3,6079.4,6244.4,6389.6,6610.7,6742.1,6928.4))
print(cons_pessoal)
##     ano    dcp    pib
## 1  1982 3081.5 4620.3
## 2  1983 3240.6 4803.7
## 3  1984 3407.6 5140.1
## 4  1985 3566.5 5323.5
## 5  1986 3708.7 5487.7
## 6  1987 3822.3 5649.5
## 7  1988 3972.7 5865.2
## 8  1989 4064.6 6062.0
## 9  1990 4132.2 6136.3
## 10 1991 4105.8 6079.4
## 11 1992 4219.8 6244.4
## 12 1993 4343.6 6389.6
## 13 1994 4486.0 6610.7
## 14 1995 4595.3 6742.1
## 15 1996 4714.1 6928.4
summary(cons_pessoal)
##       ano            dcp            pib      
##  Min.   :1982   Min.   :3082   Min.   :4620  
##  1st Qu.:1986   1st Qu.:3638   1st Qu.:5406  
##  Median :1989   Median :4065   Median :6062  
##  Mean   :1989   Mean   :3964   Mean   :5872  
##  3rd Qu.:1992   3rd Qu.:4282   3rd Qu.:6317  
##  Max.   :1996   Max.   :4714   Max.   :6928
attach(cons_pessoal)

reg<-lm(dcp~pib) 

reg
## 
## Call:
## lm(formula = dcp ~ pib)
## 
## Coefficients:
## (Intercept)          pib  
##   -184.0780       0.7064
 lm(formula = dcp ~ pib)
## 
## Call:
## lm(formula = dcp ~ pib)
## 
## Coefficients:
## (Intercept)          pib  
##   -184.0780       0.7064
 summary(reg)
## 
## Call:
## lm(formula = dcp ~ pib)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -39.330  -8.601   1.761  14.769  31.306 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -1.841e+02  4.626e+01  -3.979  0.00157 ** 
## pib          7.064e-01  7.827e-03  90.247  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 20.29 on 13 degrees of freedom
## Multiple R-squared:  0.9984, Adjusted R-squared:  0.9983 
## F-statistic:  8145 on 1 and 13 DF,  p-value: < 2.2e-16
 plot(pib,dcp)  
 abline(lm(dcp~pib),col="red",lwd=2)