'How do I apply GAM to an ecological dataset?

I want to make a GAM of counts of each family by Depth for each region. Region is giving me issues because it's a character.

I've tried:

gam(count~ Region s(Depth, by=Region), offset=log(Distance), family= negbin)

This is what one row of my dataset looks like

Region Depth Distance Family
Hawaii 340 100 0.05
r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source