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
### Keybase proof | |
I hereby claim: | |
* I am csgallego on github. | |
* I am cgallego (https://keybase.io/cgallego) on keybase. | |
* I have a public key ASCE5miU5VPKybIgpNJ4_wF38-pUbBgb9knBrE-5tIgTfwo | |
To claim this, I am signing this object: |
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
#We create vector named "visitee" | |
visitee=paste(visits$visitee_namefirst,visits$visite_namelast) | |
visitee=tolower(iconv(visitee,to=“UTF-8”) | |
tail(sort(table(visitee)), 30) | |
#I am creating “POTUS” that gives me every visitors who visited the President of the United States | |
POTUS=visits[visitee==“potus ”,] | |
#I’m making sure I include all the versions of POTUS possible | |
POTUS = visits[ tolower(visits$visitee_namefirst) == "potus" | tolower(visits$visitee_namelast) == "potus" ,] |
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
#Cleaning the dates of the White House visitor logs | |
z = strptime(visits$APPT_START_DATE,format="%m/%d/%Y %H:%M") | |
class(z) | |
head(visits$APPT_START_DATE) | |
visits$APPT_START_DATE[z$year < 0] | |
gsub("/13 ","/2013 ",visits$APPT_START_DATE) | |
visits$CAPPT_START_DATE = gsub("/13 ","/2013 ",visits$APPT_START_DATE) | |
z = strptime(visits$CAPPT_START_DATE,format="%m/%d/%Y %H:%M") | |
is.na(z) |
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
#We start by opening the file drug12q4 (4th quaterly report from the year 2012) that lists the number or complaints for each drug. The information is separated by dollar signs so we add a separator. We noticed that there was a problem with one quotation mark and we solve this problem by adding quote. | |
drug12q4 = read.csv("aers_ascii_2012q4/ascii/drug12q4.txt",sep="$",as.is=TRUE,quote="") | |
#We want to look at all the drugs that are a form of Yaz/Yasmin/Ocella (they might be under different names) | |
Yaz12q4 = grepl("(^yaz.*)|(^yasm.*)|(^ocel.*)|(^safy*)|(beyaz)",drug12q4$DRUGNAME,ignore.case=TRUE) | |
#We create a table of Yaz12q4. | |
table(drug12q4$DRUGNAME[Yaz12q4]) | |
#We sum to see how many complaints there were against Yaz/Yasmin/Ocella in the 4th quarter of 2012. |
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
#We look at the 2012Q3 data | |
demo12Q3 = read.csv("aers_ascii_2012q3/ascii/DEMO12Q3.TXT",sep="$",as.is=TRUE,quote="") | |
drug12Q3 = read.csv("aers_ascii_2012q3/ascii/DRUG12Q3.TXT",sep="$",as.is=TRUE,quote="") | |
#We need to list the case numers in the demo file, by using the drug file so we merge the two dataframes. | |
data12Q3 = merge(demo12Q3,drug12Q3,by="ISR") | |
#We now want to list the column "CASE" associated with the "DRUGNAME" Yaz/Yasmin | |
yaz12Q3 = grepl("(^yaz.*)|(^yasm.*)|(^ocel.*)|(^safy*)|(beyaz)",data12Q3$DRUGNAME,ignore.case=TRUE) | |
xyaz12Q3 = data12Q3[yaz12Q3,] |
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
#U01358 and U01402 are big events, they are not related to the NSA revelations. Let’s at all the other UIN and see who they correspond to. | |
subset(June5,UIN=="U01627”) | |
#U01627 is the band for the event mention earlier, it is said in the description. | |
[I am checking if the UIN are given in increasing order: | |
POTUS$UIN[order(POTUS$time)] | |
unique(POTUS$UIN[order(POTUS$time)]) | |
sort(table(visits$UIN)) | |
This helps us find out that they are] |
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
#We created a subsrting of those who visited POTUS on June 5th: | |
POTUS[paste(POTUS$time$mon+1,POTUS$time$mday)=="6 5”,] | |
#Let’s look at only the full names: | |
POTUS[paste(POTUS$time$mon+1,POTUS$time$mday)=="6 5",c("NAMEFIRST","NAMELAST”)] | |
#Let’s look at only the 4 first columns: | |
POTUS[paste(POTUS$time$mon+1,POTUS$time$mday)=="6 5",1:4] | |
#We want to add the “column” description which gives us interesting information (it is the column 27): |
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
#I am creating “POTUS” that gives me every visitors who visited the President of the United States. | |
POTUS=visits[visitee==“potus ”,] | |
#I’m marking sure I include all the versions of POTUS possible: | |
POTUS = visits[ tolower(visits$visitee_namefirst) == "potus" | tolower(visits$visitee_namelast) == "potus" ,] | |
#We created a subsrting of those who visited POTUS on June 5th: | |
substr(POTUS$APPT_START_DATE, 1,5) | |
#Let’s make a histogram: |
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
z = strptime(visits$APPT_START_DATE,format="%m/%d/%Y %H:%M”) | |
class(z) | |
head(visits$APPT_START_DATE) | |
visits$APPT_START_DATE[z$year < 0] | |
gsub("/13 ","/2013 ",visits$APPT_START_DATE) | |
visits$CAPPT_START_DATE = gsub("/13 ","/2013 ",visits$APPT_START_DATE) | |
z = strptime(visits$CAPPT_START_DATE,format="%m/%d/%Y %H:%M”) | |
is.na(z) | |
sum(is.na(z)) | |
visits$CAPPT_START_DATE[is.na(z)] |
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
visitee=paste(visits$visitee_namefirst,visits$visite_namelast) | |
visitee=tolower(iconv(visitee,to=“UTF-8”) | |
tail(sort(table(visitee)), 30) |
NewerOlder