Chi square test in R without using the function idrectly

Can you please post more details about your data and what you are trying to do? The most helpful information is in the form of a Reproducible Example. Just posting data and the exact statistical question to be answered would help a lot.