Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to join tables on organisation #4

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

JornGitHub
Copy link
Contributor

Linked to #3.

Add script to join tables on organisation.

@JornGitHub JornGitHub requested a review from tin900 July 3, 2024 10:18
@JornGitHub JornGitHub self-assigned this Jul 3, 2024
@JornGitHub JornGitHub linked an issue Jul 3, 2024 that may be closed by this pull request
3 tasks
dfTeacher <- readr::read_delim(unz(sMostrecent_zip, "teacher.csv"))
dfGenericTopic <- readr::read_delim(unz(sMostrecent_zip, "genericTopic.csv"))

## Join the two data frames
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for creating three separate tables?
Can we not combine into a single table?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason for creating three separete tables. We can indeed combine into a single table.

@Tomeriko96
Copy link
Member

Hi @JornGitHub ,

Please rename the pull request, to make its purpose clear.

@JornGitHub JornGitHub changed the title test: test push to branch with first file Add script to join tables on organisation Jul 3, 2024
@Tomeriko96
Copy link
Member

Hi @JornGitHub ,

A few comments:

  1. The joins produce column names with .x and .y suffixes.
    You can check these by running the function identify_join_suffixes from the vusa package.:
> vusa::identify_join_suffixes(dfOrganisationJoined)
 [1] "name.x"         "code.x"         "externalId.x"   "id.y"           "name.y"         "description.x"  "externalId.y"  
 [8] "archived.x"     "id.y.y"         "name.x.x"       "code.y"         "externalId.x.x" "archived.y"     "id.y.y.y"      
[15] "name.y.y"       "description.y"  "externalId.y.y"

And to prevent these suffixes, see example below:

## Join the two data frames
dfQuestion <- dfQuestionScaleValue %>%
  left_join(dfQuestionScale, by = c("questionScaleHash" = "hash"), suffix = c(".value", ".scale"))
  1. You should consider changing the order of the joins

Currently, the organisation table is used as base. However, it seems to be more like a type of mapping table.
You should probably use one of the more granular tables as base instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Join tables on organisation
2 participants