The XLSX package can be used to read the Excel data, and the reporters package can be used to output the word report directly, both of which are dependent on the Rjava package, so the Rjava must be installed first.
(1) View Java information for your Mac
Java version:
> java–version
Java path:
>which Java
Java HOME:
>/usr/libexec/java_home
(2) Adding environment variables
Operation Steps:
1. Open Terminal
2. Input: VI ~/.bash_profile
3. Set Path:
Export java_home= "/usr/libexec/java_home-v 1.8"
Export Ld_library_path= $JAVA _home/jre/lib/server
4. Input: Wq Save Exit VI
5. Modification takes effect immediately: source ~/.bash_profile.
6. View environment variables: Echo $PATH
Attention:
Where the MAC configures environment variables
1./etc/profile (it is not recommended to modify this file)
A global (public) configuration that reads the file when logged on, regardless of the user.
2./ETC/BASHRC (typically add system-level environment variables to this file)
Global (public) configuration, which will be read by the bash shell, regardless of the way it is executed.
3.~/.bash_profile (typically add user-level environment variables to this file)
Each user can use the file to enter shell information dedicated to their own use, and when the user logs in, the file executes only once!
If you add a new environment variable or modify the value of an environment variable, you need a source to take effect immediately. If you delete an environment variable, you must enter exit to logout the current shell, and then reopen a new shell and login to take effect.
(3) The terminal executes the following statement:
>sudo R CMD javareconf
command line to open R, install Rjava:
Install.packages (' Rjava ', type= ' source ')
(4) Establish a link. Allow Rstudio to connect to Libjvm.dylib To/usr/local/lib via finder/spotlight:
sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
-f
(5) If you still cannot install reporters in R through the above steps, you need to download the latest in the Oracle website JDK . Then rerun the sudo R CMD javareconf
Install Rjava,xlsx,reporters package under Mac