Re: [R] Alter a line in a file.

From: Patrick Connolly <p_connolly_at_slingshot.co.nz>
Date: Mon, 09 May 2011 18:58:37 +1200

On Thu, 05-May-2011 at 06:13AM -0700, Joel wrote:

|>
|> jholtman wrote:
|> >
|> > a <- readLines(textConnection('setting1="value1"
|> > setting2="value2"
|> > setting3="value3"
|> > setting4="value4"'))
|> > closeAllConnections()
|> > # change values
|> > ac <- sub('setting4="value4"', 'setting4="value5"', a)
|> > writeLines(ac, con='myFile.txt')
|> >
|>
|> Problem is that I dont know the value on all the settings that I wanna
|> change otherwise that looks like something to continue on.
|>
|>
|>
|> Petr Pikal wrote:
|> >
|> > What file, what is its structure, is it some R object or separate file?
|> > What did you try and what went wrong?
|> >
|> > Regards
|> > Petr
|> >
|>
|> Just a normal textfile nothing fancy
|> Ive tried diffrent kind of ways of useing my OS witch is linux by
|> the system command to do it for me but Im not good enought on
|> regexp to get it to work properly.

R is great for lots of things. I even use it for things that someone more skilled would do using Perl, but in your case, it would be much easier to use a text editor. If you can't use Emacs or vi, use nano. You don't need to know anything about text editors to use the menu options it has for everything.

HTH

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___    Patrick Connolly   
 {~._.~}                   Great minds discuss ideas    
 _( Y )_  	         Average minds discuss events 
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)  	                      ..... Eleanor Roosevelt
	  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 09 May 2011 - 10:49:39 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 09 May 2011 - 10:50:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive