R COPR repository
This will make your R experience on Fedora much easier
Unfortunately, CRAN does not provide binaries for Linux. That is why, by default install.packages() will compile any package you install from source. Many packages require developer libraries to be installed on the system for compilation. The lack of these packages is why you got the error.
Overall, compiling packages yourself is far from ideal. All packages will take a longer time to install. Especially when you do them infrequently, updates will take an eternity. Also, finding out which system developer packages to install alongside can be time consuming as well, particularly for beginners.
Luckily, there is a COPR repository for Fedora that provides up-to-date binaries for all CRAN packages. All you have to do is run these few lines in the system terminal (not R console):
sudo dnf install 'dnf-command(copr)'
sudo dnf copr enable iucar/cran
sudo dnf install R-CoprManager
Afterwards install.packages() in R will install the desired packages through the system package manager. This also means that you will receive R package updates whenever you run dnf update or update the system with your desktop environments software management GUI.
You can find further documentation about this on the CRAN website.