We investigated CeCoIn5 and LaCoIn5 single crystals, which have the same HoCoGa5-type tetragonal crystal structure, using infrared spectroscopy. However, while CeCoIn5 has 4f electrons, LaCoIn5 does not. By comparing these two material systems, we can extract the electronic properties of these f electrons. We observed that the differences caused by the f electrons are more obvious in low-energy optical spectra at low temperatures. We introduced a complex optical resistivity and found that the difference in optical resistivity between the two material systems is a clear indicator of the f electron response, which is intimately associated with the Kondo (f-electron) phenomena. From the temperature-related difference in optical resistivity, we also found that the onset temperature of the Kondo effect is much higher than what was previously reported. A large effective mass of 4f electrons for CeCoIn5 is obtained by applying the extended Drude model formalism. The effective masses of the two material systems are sharply contrasted. From this approach using optical resistivity, we demonstrate that the temperature-dependent optical properties of f electron can be extracted via a comparative study between CeCoIn5 and LaCoIn5.