[R] Directory operations

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Jan 9 20:24:03 CET 2010



On 09.01.2010 19:04, anupam sinha wrote:
> Hi Jim,
>              Thanks for your suggestion. I tried scripting but gives me an
> error. Can you tell me what am I doing wrong here ?
>
>
> *>  list.files()->org_xml_dirs

Please do turn that arrow around....

>> for (i in org_xml_dirs){
> + setwd("/home/anupam/Research/Anupam_data/ORG_XML_FILES/i")}


There is no directory .../i
Your probably want:
setwd(file.path("/home/anupam/Research/Anupam_data/ORG_XML_FILES/", i))

Uwe Ligges



>
>    Error in setwd("/home/anupam/Research/Anupam_data/ORG_XML_FILES/i") :
>    cannot change working directory
> *
>
>
> On Fri, Jan 8, 2010 at 11:37 PM, jim holtman<jholtman at gmail.com>  wrote:
>
>> ?list.files
>> ?file.info
>> ?setwd
>>
>> You can get a list of all the files in a directory (list.files) and then do
>> a file.info to determine which ones are the directories you want to
>> search.  A list.files on that directory will give you the list of file names
>> that you can then process.
>>
>>
>>
>>
>> On Fri, Jan 8, 2010 at 12:41 PM, anupam sinha<anupam.contact at gmail.com>wrote:
>>
>>> Dear all,
>>>               I have this directory structure :
>>>
>>> Dir1       Dir2       Dir3      Dir4  .........................
>>> A.xml     D.xml    G.xml
>>> B.xml     E.xml     H.xml
>>> C.xml     F.xml     I.xml
>>>
>>> Within each of these directories (Dir1, Dir2 etc) there are a num of xml
>>> files (A.xml, B.xml etc).
>>>
>>> What I want to do is to enter into the first directory read all the xml
>>> files do certain operations come out  of the directory and do the same
>>> thing
>>> for another directory. Can anyone help me out ? Thanks in advance for any
>>> suggestions.
>>>
>>> Regards,
>>>
>>> Anupam Sinha
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help at 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<http://www.r-project.org/posting-guide.html>
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>>
>> --
>> Jim Holtman
>> Cincinnati, OH
>> +1 513 646 9390
>>
>> What is the problem that you are trying to solve?
>>
>
>
>



More information about the R-help mailing list