Dear Sir, I really appreciate your suggestion. I was having the probelm of expressing my problem precisely. In fact in my earlier mail, I have tried to write my probelm in my initial few paras only. The rest content is my actual R code which I have written and its working fine except for the final output which I want to have in a particular form. I had produced the said R code as I thought it may be handy for someone who may be interested. For me another option was to attach the related R code but I understand we are not supposed to send the attachments. It was a difficult for me to express my problem effectively in few lines. Please trust me that I had drafted it 2-3 times. I once again try to resend it without the related R code. I thought it may be useful to have this R code handy. But truely I sincerely apologize for the same and do appreciate the time contraints all the R helpers have. Please Forgive me. Here is my probelm restated. ### PROBLEM I have some variables say ABC, DEF, PQR, LMN and XYZ. I am choosing any three varaibles at random at a time for my analysis and name these files as input1.csv, input2.csv and input3.csv. So if I choose variables say ABC, DEF and PQR, I am passing the specifications of these variables to input1.csv, input2.csv and input3.csv respectively. This means in another case even if I choose say LMN, DEF and XYZ in this order, then my input1.csv will have details of LMN, input2.csv will have detaisl of DEF and input3.csv will have details of XYZ. Thus, I am keeping the (input) file names constant but the contents of each of these input files may change from one case to another case. As an example, my input files are as given below. input1.csv name1 value1 DEF 10 input2.csv name2 value2 LMN 8 input3.csv name3 value3 PQR 7 ## __________________________________________________________________ ## The Problem name1 = read.csv('input1.csv')$name1 value1 = read.csv('input1.csv')$value1
name2 = read.csv('input2.csv')$name2 value2 = read.csv('input2.csv')$value2 name3 = read.csv('input3.csv')$name3 value3 = read.csv('input3.csv')$value3 # (Thus if 1st variable chosen is DEF, then name1 = DEF, value1 = 10. Had I chosen some otehr variable, then name1 and value1 will have different values). Then I carry out my analysis and get the output as given below. Scenario_and_range names values Sc_1 (DEF LMN PQR) name1 10.04 Sc_1 (DEF LMN PQR) name2 8.21 Sc_1 (DEF LMN PQR) name3 7.23 Sc_2 (DEF LMN PQR) name1 9.96 Sc_2 (DEF LMN PQR) name2 8.47 Sc_2 (DEF LMN PQR) name3 7.40 ......................................................................... ......................................................................... The values appearing in the third column are the random nos. generated using the base rate 10, 8 and 7 respectively. My probelm is I know name1 pertains to DEF, name2 pertains to LMN and name3 pertains to PQR. But in the output I am not able to replace name1 with DEF, name2 with LMN and so on i.e. I cannot hardcode the varaible names in data.frame as name1 = DEF, name2 = LMN etc as these names are going to change frome case to case. My objective is to get the names (in column 2 of above table) same as respective names (appearing in 1st column) in its order i.e. instead of name1, I should get DEF, in place of name2, I should get LMN and in place of name3, I should get PQR. Hence, my output should be like - Scenario_and_range names values Sc_1 (DEF LMN PQR) DEF 10.04 Sc_1 (DEF LMN PQR) LMN 8.21 Sc_1 (DEF LMN PQR) PQR 7.23 Sc_2 (DEF LMN PQR) DEF 9.96 Sc_2 (DEF LMN PQR) LMN 8.47 Sc_2 (DEF LMN PQR) PQR 7.40 ......................................................................... ......................................................................... Regards Amelia ##_________________________________________________________________________ --- On Wed, 2/10/10, Dieter Menne <dieter.me...@menne-biomed.de> wrote: From: Dieter Menne <dieter.me...@menne-biomed.de> Subject: Re: [R] Readjusting the OUTPUT csv file To: r-help@r-project.org Date: Wednesday, February 10, 2010, 8:02 AM Amelia wrote a few hundreds of lines .... This is too much reading. Please try to reduce you problem to 30 lines, and make the example self-contained (your data are not available). In 80% of the cases, the problem is self-resolved after it has been made self-contained. Dieter -- View this message in context: http://n4.nabble.com/Readjusting-the-OUTPUT-csv-file-tp1475448p1475478.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.