-
-
Save NekoMisero/4992c1bd4ef77cafeb038b464f83ee42 to your computer and use it in GitHub Desktop.
Out of pocket, data_filtering
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
# Data Filtering Code | |
library(dplyr) | |
# Sample Data | |
sample_data <- data.frame( | |
Country = c("CountryA", "CountryA", "CountryB", "CountryB", "CountryB"), | |
Code = c("A", "A", "B", "B", "B"), | |
Year = c(2010, 2011, 2010, 2011, 2012), | |
`Out-of-pocket expenditure (% of current health expenditure)` = c(10, 12, 8, 9, 11) | |
) | |
# Data Manipulation for Sample Data | |
filtered_data <- sample_data %>% | |
# Your data manipulation code here | |
# Assuming dataset is loaded into a data frame named df | |
# You can load it using: df <- read.csv("share-of-out-of-pocket-expenditure-on-healthcare.csv") | |
# Count the number of years each country has data for | |
years_per_country <- df %>% | |
group_by(Country) %>% | |
summarize(NumYears = n()) | |
# Identify countries with less than 10 years of data | |
countries_to_remove <- years_per_country$Country[years_per_country$NumYears < 10] | |
# Filter the dataset to exclude countries with less than 10 years of data | |
filtered_df <- df[!(df$Country %in% countries_to_remove), ] | |
# Now, filtered_df contains the dataset with countries providing at least 10 years of data | |
# Print the Result | |
print(filtered_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test the dataset with sample data only.