[R] Loop for R

Jim Lemon jim at bitwrit.com.au
Wed Oct 23 23:07:32 CEST 2013


On 10/23/2013 09:51 PM, THIRU MANIAM wrote:
> Hi,
> I need kind help from you. I'm doing my assignment in IR and need to do script in R programming and using R studio tool.I don't have any knowledge in R but learning by Youtube. After so long,i successfully came out with below script for precision 10(P@)
> But i don know how to do loop for 105 system. below script was for 5 system but i define it  one by one.Can you help me ?
>
Hi Thiru,
Anyone who can learn statistics on YouTube instead of watching cat 
videos deserves at least a hint, even for homework.

You want to loop over systems as you have done starting with this:

   ###########################
   #start    system Number 1#
   ##########################
   systemNumber=1
   systemName="input.acsys9mw0"
   systemFilePath="D:\\UM 
Studies_Master_MCS\\Semester_2\\WMGA6320_Special Topics In 
IS\\Group_Project\\input.acsys9mw0"

Without looking too carefully at the code, I see the three things above 
that differentiate the systems. I assume that your systems are numbered 
1 to 105. Somewhere there will be the 105 system names that you want to 
run. If they happen to be in a character vector, you could think about 
picking them off one by one using the system number.

systemFilePath looks the same every time except for the systemName 
tacked on the end. Think about the paste function.

So, if you can index your loop with systemNumber, set systemName using 
that number and paste systemName onto a constant file path, I think 
you've got it. All this without having to watch me talking to a video 
camera.

Jim



More information about the R-help mailing list