@mariaangelesjs welcome to the KNIME forum.
If you encounter problems with R and KNIME and MacOSX there are more articles and hints to explore:
The error sounds like some paths might be missing. Did you follow all the hints from the official KNIME and R guide and can you check which versions of the named packages you have.
You can check your installation here. If the code does not work in KNIME/R maybe you try to check the versions in RStudio.