The error Fatal error: cannot create 'R_TempDir' is solved now by changing the /tmp write permissions. However, the main issue which is to create tempdir in /mnt/tmp instead of /tmp still persists.
I tried as root, shiny and ubunutu user. When it tried as shiny user or root, it creates tempdir at /tmp instead of at /mnt/tmp, below is the output:
$ sudo su - shiny
$ R
> tempdir()
[1] "/tmp/Rtmp1THYua"
##When tried as root user it creates tempdir at /tmp instead of at /mnt/tmp###
$ sudo su - root
root@webgqt:~# R
> tempdir()
[1] "/tmp/RtmpP3WO2k"
###As ubuntu user it works as expected###
$ sudo su - ubuntu
ubuntu@webgqt$ R
> tempdir()
[1] "/mnt/tmp/RtmpdEUXLT"
Here are the permissions for /tmp and /mnt/tmp:
$ ls -ld /tmp
drwxrwxrwx 5 root root 12288 Jul 3 17:05 /tmp
$ ls -ld /mnt/tmp/
drwxrwxrwx 2 root root 4096 Jul 3 17:05 /mnt/tmp/
How can i change the tempdir to /mnt/tmp?