LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-22-2018, 01:25 AM   #1
Aemm
LQ Newbie
 
Registered: Oct 2018
Posts: 19

Rep: Reputation: Disabled
Calling the R function within the bash script to be run on a cluster


Hi all,
I had a set of files which I split into two (.control and .case) using bash script. Now I want to run the R function "t.test" on it. Is there a way to run/call the R function within the bash script such that the names are stored in variable and I want to use the same name in R function as well. the script which I have right now is

Code:
cd $PBS_O_WORKDIR
for FileName in $(cat Artery_Aorta-ListOfScoreFilesForScript.txt); 
do 
cat "$FileName" | awk -v fn="$FileName" '{if ($3 == 1) {print $6 >>fn".control"} else if ($3 == 2) {print $6 >>fn".case"}}';
Rscript t.test($FileName.control, $FileName.case, alternative = "two.sided", paired = FALSE, var.equal = FALSE)
done;
I also want to output the result of the t.test into the same variable $FileName along with the .test extension.
 
Old 11-22-2018, 01:50 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by Aemm View Post
such that the names are stored in variable and I want to use the same name in R function as well.
Which names, and which name?

Quote:
Originally Posted by Aemm View Post
I also want to output the result of the t.test into the same variable $FileName along with the .test extension.
You mean that you want to output the result to a file named $FileName.test. Correct? If so, just use the greater sign “> $FileName.test” to redirect the output.
 
1 members found this post helpful.
  


Reply

Tags
bash scripting, linux, scripting



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Call a function within a function in Bash Script bluethundr Linux - Newbie 3 08-23-2018 03:08 PM
[SOLVED] bash question - calling a script within a script bradvan Linux - General 2 09-14-2016 08:24 AM
[SOLVED] Calling a method within a bash script is dropping the $system reference tj21 Programming 3 11-10-2015 01:19 AM
Calling a bash shell script from within another script dedman Linux - Software 7 04-24-2010 08:53 PM
calling a function from within another function in php jayakrishnan Programming 2 06-19-2007 08:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration