Skip to content

Commit

Permalink
Update styles and R snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosmro committed Jan 27, 2021
1 parent cff08c5 commit ee32a28
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
8 changes: 4 additions & 4 deletions phs-gdc-dashboard/src/components/AppContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const useStyles = makeStyles((theme) => ({
flexGrow: 1,
padding: "4vh",
},
paper: {
card: {
minHeight: "75vh",
padding: theme.spacing(2),
textAlign: 'center',
Expand Down Expand Up @@ -50,7 +50,7 @@ export default function AppContent() {
<div className={classes.root}>
<Grid container spacing={3}>
<Grid item md={4}>
<Card className={classes.paper}>
<Card className={classes.card}>
<Step1
title={"Select Index Variable"}
setPhsVariableName={setPhsVariableName}
Expand All @@ -64,7 +64,7 @@ export default function AppContent() {
</Card>
</Grid>
<Grid item md={4}>
<Card className={classes.paper}>
<Card className={classes.card}>
<Step2 title={"Select Data Commons Variables"}
setDcVariableNames={setDcVariableNames}
showDcVariableNamesError={showDcVariableNamesError}
Expand All @@ -73,7 +73,7 @@ export default function AppContent() {
</Card>
</Grid>
<Grid item md={4}>
<Card className={classes.paper}>
<Card className={classes.card}>
<Step3 title={"Export Data"}
phsVariableName={phsVariableName}
phsVariableValues={phsVariableValues}
Expand Down
Binary file modified r/.DS_Store
Binary file not shown.
27 changes: 17 additions & 10 deletions r/snippet-merge-csv/MergeSnippet.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@

# Please fill in the following constants according to your folder/file names
wd <- "~/Desktop/r_wd"
user_filename <- "user_data.csv"
dcw_filename <- "dcw_data.csv"
user_colname = "zip"
dcw_colname = "zipCode"
output_filename <- "merged_data.csv"

# Load the 'dplyr' package. If it's not installed, run install.packages("dplyr")
library(dplyr)

# (Optional) Set your working directory
setwd("/path_to/your_working_directory")
# Set working directory
setwd(wd)

# Read the user's data into a data frame
df1 <- read.csv("/path_to/your_data_file.csv", header = T)
# Read the user's data
df1 <- read.csv(user_filename, header = T)

# Read the downloaded Data Commons CSV file into a new data frame
df2 <- read.csv("/path_to/dcw_data.csv", header=T)
df2 <- read.csv(dcw_filename, header=T)

# Merge the two data frames using the appropriate column names
col1 = "zip"
col2 = "zipCode"
merged_df <- left_join(df1, df2, by=setNames(nm=col1, col2))
merged_df <- left_join(df1, df2, by=setNames(nm=user_colname, dcw_colname))

# (Optional) Export merged data to CSV
write.csv(merged_df, "/path_to/merged_data.csv", row.names = F)
# Export merged data to CSV
write.csv(merged_df, output_filename, row.names = F)

0 comments on commit ee32a28

Please sign in to comment.