An economist for a US federal agency (USAID) explains how they analyzed millions of records from health institutions in countries around the world. They evaluate data such as HIV status, HIV treatment methods, and protection indicators in the President’s Emergency Plan for AIDS Relief unit. In 2015, their teams were largely using EXCEL, but later they realized that EXCEL was not suitable for large data and went beyond the limits of Excel to be more efficient in their analysis. They turned to taking advantage of R for “We have created our own ‘pit of success’ by providing analysts with the infrastructure and support needed to make it easier to learn and work with R,” says Eknomist. At this point, he talks about the importance of key point;
Packages,
Buy in,
Community
First of all, they created packages that make things easier for everyone to access and use. He explains that they achieved the creation of these packages by first creating scripts and then creating functions.
The second important point is that he invites people to buy and support their analysts to learn R. Although there is a need for a learning curve at this point, he emphasizes the value of learning curve time by emphasizing that routine work will accelerate and be of better quality after giving analysts enough time to learn.
The last important way is to build communities, he adds. While integrating R into internal use, they created a Slack group, where they saw the importance of people asking each other questions and sharing new information within the community.
He finishes his speech by emphasizing that they increase the quality of work and work efficiency.
(b)
Differences between R and Python:
R: In R, indices begin at 1. Additionally, it contains special data structures that are ideal for statistical analysis, such as factors, data frames, and vectors.
Python: Python indexes data with a base of 0. Moreover, it makes use of more conventional data structures like sets, dictionaries, and lists.
R: The syntax of R is designed with statistical data analysis in mind. R code is frequently written in a way that is more functional.
Python: Python is renowned for its readability and boasts a more versatile syntax. For code blocks, it employs indentation (whitespace).
R: R uses specific functions and expressions for string processing.
Python: Python provides built-in string methods and libraries for string processing.
Example:
In R:
::: {.cell}
text <-"Hello, World!"uppercase_text <-toupper(text)
:::
In Python:
::: {.cell}
text ="Hello, World!"uppercase_text = text.upper()
:::
(c)
library(dslabs)data("na_example")# Count NAsprint(paste("Total number of NAs in na_example:", sum(is.na(na_example)), "\n"))
[1] "Total number of NAs in na_example: 145 \n"
# Replace NAs with 0na_example_no_na <- na_examplena_example_no_na[is.na(na_example_no_na)] <-0# Print the new data (without NAs) and count NAs in the new dataprint(na_example_no_na)