Skip to content

Commit

Permalink
Fixed code for species summary #2
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfep committed Oct 10, 2022
1 parent 7f943c3 commit b381f48
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions R/Read-table-traits-per-species.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"id": "e7a36330-4a00-4a82-8566-71fa84b48ef9",
"metadata": {},
"outputs": [],
"source": [
"qry <- \n",
"'SELECT family, genus, \"speciesID\", \n",
"'SELECT family, genus, \"speciesID\" as spp, \n",
"count(distinct q.record_id) as nquadrat, \n",
"count(distinct g8.record_id) as germ8, \n",
"count(distinct r2.record_id) as rect2,\n",
Expand All @@ -132,8 +132,6 @@
"count(distinct s4.record_id) as surv4, \n",
"count(distinct s1.record_id) as surv1\n",
"FROM species.caps \n",
"LEFT JOIN species_traits s \n",
" ON \"speciesCode_Synonym\"=s.species_code::text \n",
"LEFT JOIN form.quadrat_samples q \n",
" ON \"speciesCode_Synonym\"=q.species_code::text \n",
"LEFT JOIN litrev.germ8 g8 ON \"speciesCode_Synonym\"=g8.species_code::text \n",
Expand All @@ -150,58 +148,58 @@
"LEFT JOIN litrev.surv4 s4 ON \"speciesCode_Synonym\"=s4.species_code::text \n",
"LEFT JOIN litrev.surv1 s1 ON \"speciesCode_Synonym\"=s1.species_code::text \n",
"\n",
"GROUP BY fam'"
"GROUP BY spp'"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 5,
"id": "906884e5-92c3-46c6-aba7-c5a7d6fada17",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"'data.frame':\t368 obs. of 17 variables:\n",
" $ fam : chr \"Acanthaceae\" \"Acrobolbaceae\" \"Actinidiaceae\" \"Adoxaceae\" ...\n",
" $ nspp : num 79 6 1 10 12 67 3 15 19 4 ...\n",
" $ litrev : num 16 0 0 3 1 30 1 5 0 0 ...\n",
" $ quadrat: num 1 0 0 1 0 0 1 0 0 0 ...\n",
" $ germ8 : num 0 0 0 0 0 0 0 0 0 0 ...\n",
" $ rect2 : num 2 0 0 0 0 2 0 0 0 0 ...\n",
" $ germ1 : num 2 0 0 0 0 1 0 0 0 0 ...\n",
" $ grow1 : num 0 0 0 0 0 0 0 0 0 0 ...\n",
" $ repr4 : num 0 0 0 0 0 0 0 0 0 0 ...\n",
" $ surv5 : num 4 0 0 0 0 4 0 0 0 0 ...\n",
" $ surv6 : num 0 0 0 0 0 0 0 0 0 0 ...\n",
" $ surv7 : num 0 0 0 0 0 0 0 0 0 0 ...\n",
" $ disp1 : num 12 0 0 3 0 26 1 5 0 0 ...\n",
" $ repr3a : num 2 0 0 0 0 0 0 0 0 0 ...\n",
" $ repr3 : num 1 0 0 0 0 2 0 0 0 0 ...\n",
" $ surv4 : num 4 0 0 0 0 0 0 0 0 0 ...\n",
" $ surv1 : num 16 0 0 3 1 29 1 4 0 0 ...\n"
"'data.frame':\t15732 obs. of 17 variables:\n",
" $ family : chr \"Brassicaceae\" \"Myrtaceae\" \"Myrtaceae\" \"Apiaceae\" ...\n",
" $ genus : chr \"Lepidium\" \"Eucalyptus\" \"Melaleuca\" \"Actinotus\" ...\n",
" $ spp : num 2358 2359 2360 2361 2362 ...\n",
" $ nquadrat: num 0 0 0 0 0 2 1 0 0 0 ...\n",
" $ germ8 : num 0 0 0 0 0 0 0 0 0 0 ...\n",
" $ rect2 : num 0 1 0 2 0 0 0 0 0 0 ...\n",
" $ germ1 : num 0 1 0 1 0 0 0 0 0 1 ...\n",
" $ grow1 : num 0 0 0 0 0 0 0 0 0 0 ...\n",
" $ repr4 : num 0 0 0 1 0 0 0 0 0 0 ...\n",
" $ surv5 : num 0 0 0 2 0 0 0 0 0 0 ...\n",
" $ surv6 : num 0 0 0 0 0 0 0 0 0 0 ...\n",
" $ surv7 : num 0 0 0 1 0 0 0 0 0 0 ...\n",
" $ disp1 : num 3 0 0 3 1 1 0 1 0 1 ...\n",
" $ repr3a : num 0 0 0 0 0 0 1 0 0 0 ...\n",
" $ repr3 : num 0 0 0 3 0 0 0 0 0 0 ...\n",
" $ surv4 : num 0 0 0 0 0 0 1 0 0 0 ...\n",
" $ surv1 : num 1 6 3 14 1 1 3 1 0 7 ...\n"
]
}
],
"source": [
"my.table<- dbGetQuery(con, qry)\n",
"str(my.table)"
"spp.table<- dbGetQuery(con, qry)\n",
"str(spp.table)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 6,
"id": "5b64901b-b582-402f-9ba9-c01ba064f135",
"metadata": {},
"outputs": [],
"source": [
"saveRDS(file='../data/Summary-traits-family.rds',my.table)"
"saveRDS(file='../data/Summary-traits-species.rds',spp.table)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 7,
"id": "f6c75c45-cf6c-4711-ba3e-1edede998c92",
"metadata": {},
"outputs": [
Expand Down

0 comments on commit b381f48

Please sign in to comment.