[R] problems editing R console

Carlos Andrade carlosviansi at gmail.com
Mon Jun 8 02:19:43 CEST 2015


Rosa,

Why not just re-load the .txt file (which I imagine be a data frame) and
then edit?

See: http://www.inside-r.org/r-doc/utils/read.table

*I would imagine something along the lines:*

simulation_results <-  read.table("path_to_text_file_of_simulation")
#Double check the parameters on the function documentation, I don't know
how your data looks like, specially header and column separator.

*For doing something like: *

x.erro = 1.4X+erro



*you would just need to use:*
simulation_results$x.erro <- 1.4*simulation_results$X + simulation$erro

*then save the simulation_results variable again.*

Also see...
http://stackoverflow.com/questions/8345759/how-to-save-a-data-frame-in-r




Carlos Andrade
http://carlosandrade.co

On Sun, Jun 7, 2015 at 12:58 PM, Rosa Oliveira <rosita21 at gmail.com> wrote:

> Dear Mark,
>
>
> I’ll try to explain better.
>
> Imagine I write:
>
> library(foreign)
> library(nlme)
>
> set.seed(1000)
> n.sample<-10000 #sample size
> M <- 5
> DP_x <- 2
> x <- rnorm(n.sample,M,DP_x)
> p <- pnorm(-3+x)
> y <- rbinom(n.sample,1,p)
> dp_erro <- 0.01
> erro <- rnorm(n.sample,0,dp_erro)
> x.erro <- x+erro
>
> but with a function, with 2000 simulations.
> I save my “output” and I get X.erro in a .txt file. (text edit file).
>
> I do another setting with DP_x=3 and save, and so on.
>
> For some reason I realize I’ve done my simulation the wrong way and I have
> to apply a correction, for example:
>
> x.erro = 1.4X+erro, i.e. in the truth I could use my first X and erro
> values in each setting, but as it is in a .txt file I can’t use them any
> more. Is there a way to save the results in a  format that I can use the
> values? Just apply my corrections and don’t have to do the 2000 simulations
> for each setting again?
>
> My problem is that the function I use takes 3 days running, and just 500
> simulations :(
>
> Best,
> RO
>
>
> Atenciosamente,
> Rosa Oliveira
>
> --
>
> ____________________________________________________________________________
>
>
> Rosa Celeste dos Santos Oliveira,
>
> E-mail: rosita21 at gmail.com
> Tlm: +351 939355143
> Linkedin: https://pt.linkedin.com/in/rosacsoliveira
>
> ____________________________________________________________________________
> "Many admire, few know"
> Hippocrates
>
> > On 07 Jun 2015, at 23:03, Mark Sharp <msharp at txbiomed.org> wrote:
> >
> > I cannot understand your request as stated. Can you provide a small
> example?
> >
> > Mark
> >
> > R. Mark Sharp, Ph.D.
> > msharp at TxBiomed.org
> >
> >> On Jun 7, 2015, at 2:49 PM, Rosa Oliveira <rosita21 at gmail.com> wrote:
> >>
> >> Dear all,
> >>
> >> I’m doing simulations on R, and as my code is being changed and
> improved I need to, sometimes, work in finished simulations, i.e,
> >>
> >> After my simulation is  over I need to settle another setting.
> >> The problem is that I need to get back to the previous result.
> >>
> >> When I save the result it saves as txt, so I can’t edit that result any
> more.
> >>
> >> Imagine I save a setting and save the mean, nonetheless, in another
> setting the mean as problems, so I have to ask the median.
> >>
> >> As I have to have the same statistics to all settings, nowadays I have
> to run my first setting again.
> >>
> >> My advisor told me that I could save another way so I can “edit” my
> first result. Is it possible?
> >>
> >> I tried to save as "save my workplace", … but after I don’t know what
> to do with it.
> >>
> >> Can you please help me?
> >> I know is a naive question, but I have to go through this every 3 days
> (time each simulation takes long). And my work is being delayed :(
> >>
> >>
> >> Best,
> >> RO
> >>
> >>
> >>
> >> Atenciosamente,
> >> Rosa Oliveira
> >>
> >> --
> >>
> ____________________________________________________________________________
> >>
> >>
> >> Rosa Celeste dos Santos Oliveira,
> >>
> >> E-mail: rosita21 at gmail.com
> >> Tlm: +351 939355143
> >> Linkedin: https://pt.linkedin.com/in/rosacsoliveira
> >>
> ____________________________________________________________________________
> >> "Many admire, few know"
> >> Hippocrates
> >>
> >> ______________________________________________
> >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> 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.
> >
> >
> >
> >
> >
> >
> >
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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]]



More information about the R-help mailing list