Error in if (dim(input)[1] == dim(input)[2]) { : argument is of length zero

This is telling you that if isn't seeing anything with dim(input)[1] == dim(input)[2]) as its argument. Since there's no if statement in the snippet, check the function signature the most recent function, bridge to see what it's argument should be. It's possible that prcdu_cor and community_structure could be misaligned.

For better help, include a reprex.