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

Update createSiteTypeVector() function #26

Open
BexMillard opened this issue Jul 20, 2022 · 0 comments
Open

Update createSiteTypeVector() function #26

BexMillard opened this issue Jul 20, 2022 · 0 comments

Comments

@BexMillard
Copy link
Contributor

Note to self to revisit this and remove for loop.
Possibly a better name for function createSiteTypeVector() would be createSiteTypeMatrix() and have # Save site ID, # Get site type vectors and # Format type vector in this chunk executed within the function as the intermediate steps aren't of importance for code readability.

source('code/aquanet_functions/CreateSiteTypeVector.R')
# Create list of all possible site types
type_list <- c("smallhatch", "largehatch",
"smallrestock", "mediumrestock", "largerestock",
"smalltable", "mediumtable", "largetable",
"smallongrow", "mediumongrow", "largeongrow",
"smallfish", "mediumfish", "largefish")
# Save site ID
type_vector <- vertex_attr(graph_full, "siteID")
type_vector <- as.numeric(type_vector)
# Get site type vectors
for(i in 1:length(type_list)){
t_vector <- createSiteTypeVector(graph_full,
type_list[i])
type_vector <- rbind(type_vector, t_vector)
}
# Format type vector
type_vector <- t(type_vector)
colnames(type_vector) <- c("site_code", type_list)

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

No branches or pull requests

1 participant