## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----eval=FALSE--------------------------------------------------------------- # # Install lbugr from GitHub # remotes::install_github("your-github-repo/lbugr") # # # # Install the ladybug Python package # reticulate::py_install("ladybug", pip = TRUE) ## ----eval=FALSE--------------------------------------------------------------- # library(lbugr) # # # Create an in-memory database connection # con <- lb_connection(":memory:") ## ----eval=FALSE--------------------------------------------------------------- # lb_execute(con, paste("CREATE NODE TABLE Person(name STRING, age INT64,", # "PRIMARY KEY (name))")) # lb_execute(con, "CREATE REL TABLE Knows(FROM Person TO Person, since INT64)") ## ----eval=FALSE--------------------------------------------------------------- # # Create a data frame of persons # persons_df <- data.frame( # name = c("Alice", "Bob", "Carol"), # age = c(35, 45, 25) # ) # # # Create a data frame of relationships # knows_df <- data.frame( # from_person = c("Alice", "Bob"), # to_person = c("Bob", "Carol"), # since = c(2010, 2015) # ) # # # Load data into Ladybug # lb_copy_from_df(con, persons_df, "Person") # lb_copy_from_df(con, knows_df, "Knows") ## ----eval=FALSE--------------------------------------------------------------- # # Execute a query # result <- lb_execute(con, paste("MATCH (a:Person)-[k:Knows]->(b:Person)", # "RETURN a.name, b.name, k.since")) # # # Convert the result to a data frame # df <- as.data.frame(result) # print(df) # #> a.name b.name since # #> 1 Alice Bob 2010 # #> 2 Bob Carol 2015