Last active
August 29, 2015 14:08
-
-
Save miltonlab/719a27824b6a110c56b6 to your computer and use it in GitHub Desktop.
Tips and Notes about coding with R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## dplyr package notes | |
# dplyr use plyr and haver relation with data.table | |
library(dplyr) | |
# Example | |
ddply(df, ~date, summarise, totalSteps=sum(steps)) | |
## *Complete dni ecuatorian numbers with '0'. If length == 9 | |
## Sometimes usefull when Spreadsheet cut that number at start | |
# ========================================================================================= | |
> head(reporte) | |
CEDULA APELLIDOS NOMBRES CARRERA | |
1 0707063459 CRIOLLO PINGOS HENRY PAUL ADMINISTRACION DE EMPRESAS | |
2 1104757594 MACAS CABRERA KEVIN SANTIAGO ADMINISTRACION DE EMPRESAS | |
3 1104304827 JIMENEZ ZAPATA ADRIANA DEL CISNE ADMINISTRACION DE EMPRESAS | |
4 1900801711 MAZA CHALCO JONATHAN VINICIO ADMINISTRACION DE EMPRESAS | |
5 1900667872 CORREA TORRES JHULIANA ANABEL ADMINISTRACION DE EMPRESAS | |
6 0922453089 MIZHQUERO CAÑAR TATIANA ELIZABETH ADMINISTRACION DE EMPRESAS | |
> reporte[,'CEDULA'] <- sapply(reporte[,'CEDULA'], function(x) if (nchar(x) == 9) paste0('0',x) else x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment