Skip to content

Instantly share code, notes, and snippets.

@steam228
Created January 26, 2024 16:30
Show Gist options
  • Save steam228/de86773afd076d8da0f54ac607b600d0 to your computer and use it in GitHub Desktop.
Save steam228/de86773afd076d8da0f54ac607b600d0 to your computer and use it in GitHub Desktop.
This R script is designed to analyze and summarize data from two distinct datasets related to Distributed Design projects. The first dataset, 'DatasetSurvey1ProjectsCollection', contains detailed information about various design projects, including abstracts and evaluations. The script calculates scores for each project based on predefined Dist…
# Install and load necessary packages
if (!require("readxl")) install.packages("readxl")
if (!require("dplyr")) install.packages("dplyr")
if (!require("stringr")) install.packages("stringr")
if (!require("writexl")) install.packages("writexl")
if (!require("tidyr")) install.packages("tidyr")
library(readxl)
library(dplyr)
library(stringr)
library(writexl)
library(tidyr)
# Read the datasets
# Replace 'path/to/your_first_dataset.xlsx' with the path to your dataset
dataset <- read_excel("path/to/your_first_dataset.xlsx")
# Replace 'path/to/your_second_dataset.xlsx' with the path to your voting dataset
votes_dataset <- read_excel("path/to/your_second_dataset.xlsx")
# Define keywords for each DD value
keywords <- list(
# Add your keywords here
)
# Function to calculate score based on keywords
calculate_score <- function(abstract, keywords) {
# Function definition here
}
# Analyze each project and calculate scores
dataset <- dataset %>%
rowwise() %>%
# Add scoring analysis here
ungroup()
# Function to find top 3 scoring projects in each category and overall
top_projects_with_justification <- function(data, score_column) {
# Function definition here
}
# Applying the function for each score category
categories <- c("score_open", "score_collaborative", "score_regenerative", "score_ecosystemic", "score_production_paradigm", "total_score")
top_projects_list <- lapply(categories, function(category) top_projects_with_justification(dataset, category))
# Combine results into a single text output
output_text <- ""
# Add output generation code here
# Write the output to a text file
# Replace 'path/to/your_output_file.txt' with the desired output file path
writeLines(output_text, "path/to/your_output_file.txt")
# Summary of DatasetSurvey1ProjectsCollection
summary_survey <- dataset %>%
# Add summary code here
# Write summary to a file
# Replace 'path/to/your_summary_file.csv' with the desired summary file path
write_csv(summary_survey, "path/to/your_summary_file.csv")
# Summary of votesCuration
summary_votes <- votes_dataset %>%
# Add summary code here
# Write summary to a file
# Replace 'path/to/your_votes_summary_file.csv' with the desired summary file path
write_csv(summary_votes, "path/to/your_votes_summary_file.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment