neo4j-rstats / neo4r

A Modern and Flexible Neo4J Driver
https://neo4j-rstats.github.io/user-guide/
Other
106 stars 29 forks source link

Useable output for calculation queries #51

Open gregleleu opened 5 years ago

gregleleu commented 5 years ago

Hi, I'm mainly using queries which output summaries, e.g. counts, averages etc. such as:

MATCH (u:User) 
RETURN u.status as status, count(u) as n_users

which produce hard-to-use outputs, a list of data frames with one column called value...

List of 2
 $ status :Classes ‘tbl_df’, ‘tbl’ and 'data.frame':    5 obs. of  1 variable:
  ..$ value: int [1:5] 0 9 8 14 3
  ..- attr(*, ".internal.selfref")=<externalptr> 
 $ n_users:Classes ‘tbl_df’, ‘tbl’ and 'data.frame':    5 obs. of  1 variable:
  ..$ value: int [1:5] 3819684 887574 16521 2367 58606
  ..- attr(*, ".internal.selfref")=<externalptr> 
 - attr(*, "class")= chr [1:3] "neo" "neo" "list"

You can always stitch them back together afterwards...

However queries which return a list for one field fail:

MATCH (u:User) 
RETURN labels(u) as labels, count(u) as n_users

yields

Error in .x[[i]] : subscript out of bounds

(Because they add an extra layer, so removing the NULLs fails)

Anyway, the expected output would be a clean dataframe:

  1. That fails at the same moment because it adds an extra layer like before (when getting nodes, it also adds an extra layer, but it doesn't fail because the meta part with each row is not NULL in the neo4j response...
  2. Add it's somewhat unnatural to format queries like that (it should fail still)

Hope it helps

gregleleu commented 5 years ago

The Error in .x[[i]] : subscript out of bounds error is an issue with modify_depth tidyverse/purrr#655