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
cars

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.

Otro código recogido de algo hecho previamente

edad <-c(25, 14, 39, 18)

edad[4]
## [1] 18
edad[1:2]
## [1] 25 14
names(edad)<-c("Luis","Juan","Manu","Paco")

edad["Juan"]
## Juan 
##   14
edad[1:4]
## Luis Juan Manu Paco 
##   25   14   39   18
str(edad)
##  Named num [1:4] 25 14 39 18
##  - attr(*, "names")= chr [1:4] "Luis" "Juan" "Manu" "Paco"

Carga de fichero CSV

direccion<-"C:/Users/manuel.rial/Desktop/r"
setwd(direccion)
datos<-read.csv2("codigos.csv")
datos

Graficando un poco

str(cars)
## 'data.frame':    50 obs. of  2 variables:
##  $ speed: num  4 4 7 7 8 9 10 10 10 11 ...
##  $ dist : num  2 10 4 22 16 10 18 26 34 17 ...
 hist(cars$speed, col="blue", main="Velocidad de los vehículos", xlab="velocidad", ylab="frecuencia")
 abline(v=(mean(cars$speed, linetype='dashed', col = 'red')))