### Re: [R] Modifying the embed-results

Again my example was't very clear: there were not enough same numbers in the VECTOR. What I need is something like this: VECTOR-c(0,3,6,3,11,2,11,4,3,4,7,7,6,4,8) MATRIX-c() for(i in 1:length(VECTOR)){ v-(unique(VECTOR[i:length(VECTOR)])[1:5]) MATRIX-rbind(MATRIX,v) }

### [R] Problem on Histogtam

Dear all, May be question seems trivial for most of the R users, but really at least for me, this comes out to be very problematic. Suppose I have the following data: r [1] -0.0008179960 -0.0277968529 -0.0105731583 -0.0254050262 0.0321847131 0.0328170674 [7] 0.0431894392 -0.0217614918

### Re: [R] generating an expression for a formula automatically

On Fri, 25 Aug 2006, Maria Montez wrote: Thank you for your answers yesterday. I now have another question! Suppose that instead of creating a formula for a regression model I simply wanted to add the variables. I believe I cannot use the as.formula anymore. Again I tried to use

### Re: [R] Memory usage decreases drastically after save workspace, quit, restart, load workspace

On Sat, 26 Aug 2006, Klaus Thul wrote: Dear all, I have the following problem: - I have written a program in R which runs out of physical memory on my MacBook Pro with 1.5 GB RAM How does R know about physical memory on a virtual-memory OS? I presume the symptom is swapping by your

### Re: [R] How to iteratively extract elements out of a list

sub.m - lapply(m, function(x)x[x2]) sub.m [[1]] [1] 3 4 [[2]] [1] 4 5 [[3]] [1] 4 sub.m[unlist(lapply(sub.m, function(x) length(x) == 2))] [[1]] [1] 3 4 [[2]] [1] 4 5 sub4.m - lapply(m, function(x)x[x4]) sub4.m[unlist(lapply(sub4.m, function(x) length(x) 0))] [[1]] [1] 5 Patrick

### Re: [R] issues with Sweave and inclusion of graphics in a document

On Fri, 25 Aug 2006 11:05:48 -0700 (PDT), Thomas Harte (TH) wrote: --- Prof Brian Ripley [EMAIL PROTECTED] wrote: savePlot is just an internal version of dev.copy, part of the support for the menus on the windows() graphics device. It is described in `An Introduction to R' (the

### Re: [R] Problem on Histogtam

try thie: r - rnorm(100,4,1) hist(r, freq=FALSE) r.f - function(x)dnorm(x, mean(r), sd(r)) curve(r.f, from=min(r), to=max(r), add=TRUE, col='red') On 8/26/06, stat stat [EMAIL PROTECTED] wrote: Dear all, May be question seems trivial for most of the R users, but really at least for me,

### Re: [R] Modifying the embed-results

You can replace the for with lapply like this: VECTOR - c(0, 3, 6, 3, 11, 2, 11, 4, 3, 4, 7, 7, 6, 4, 8) f - function(i) unique(tail(VECTOR, length(VECTOR)-i+1))[1:5] out - do.call(rbind, lapply(seq(along = VECTOR), f)) na.omit(rbind(rep(NA, 5), out)) Note that a matrix with zero rows is

### Re: [R] issues with Sweave and inclusion of graphics in a document

--- Friedrich Leisch [EMAIL PROTECTED] wrote: On Fri, 25 Aug 2006 11:05:48 -0700 (PDT), Thomas Harte (TH) wrote: i can get pretty close to this in linux by writing a function to save the plot to a pdf device: label=first.ar.1, results=hide= # no savePlot in Linux ... so

### [R] problems with loop

Dear all, I am trying to evaluate the optimisation behaviour of a function. Originally I have optimised a model with real data and got a set of parameters. Now I am creating simulated data sets based on these estimates. With these simulations I am estimating the parameters again to see how

### [R] Adding a footnote in plot-window in R

Dear all R users, Suppose, x = rnorm(1000) y = rt(1000,3) plot(range(1:1000),range(x,y),type=n,xlab=NA,ylab=NA) lines(x,col=red) lines(y,col=blue) Now I want to put a footnote in the plot window to tell that RED lines represents the random numbers from normal-dist and blue line represents

### Re: [R] Adding a footnote in plot-window in R

?legend __ R-help@stat.math.ethz.ch 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.

### Re: [R] issues with Sweave and inclusion of graphics in a document

On Sat, 26 Aug 2006 05:38:58 -0700 (PDT), Thomas Harte (TH) wrote: hallo, friedrich, and thanks for your reply. if i Stangle your code i get: sp- make.ar.1(alpha=.5, n=800) plot(sp, type=l, col=blue) whereas if i Stangle my code, i get: width- 20;

### Re: [R] How to iteratively extract elements out of a list

lapply(m,function(x)x[x2]) [[1]] [1] 3 4 [[2]] [1] 4 5 [[3]] [1] 4 __ R-help@stat.math.ethz.ch 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

### [R] Implementing EM Algorithm in R!

Hi All, I need some help in how one can implement maximumlikelihood estimation for models with discrete hidden variables in EM in R. Regards [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list

### Re: [R] How to iteratively extract elements out of a list

Thank you! On 8/26/06, Patrick Burns [EMAIL PROTECTED] wrote: sub.m - lapply(m, function(x)x[x2]) sub.m [[1]] [1] 3 4 [[2]] [1] 4 5 [[3]] [1] 4 sub.m[unlist(lapply(sub.m, function(x) length(x) == 2))] [[1]] [1] 3 4 [[2]] [1] 4 5 sub4.m - lapply(m, function(x)x[x4])

### Re: [R] problems with loop

I think it's a scoping problem. Your function NLL() looks for new in the environment in which NLL() was defined, but you generate your simulated datasets in a different environment (local to sim.estim()). There are a number of ways to deal with this: - pass the dataset as a parameter to NLL() -

### [R] for() loop question

Dear Lister, If I have a list of number, say x-c(0.1, 0.5, 0.6...), how to use a for() to loop through each number in x one by one? Thank you so much! wensui [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list

### Re: [R] issues with Sweave and inclusion of graphics in a document

--- Friedrich Leisch [EMAIL PROTECTED] wrote: On Sat, 26 Aug 2006 05:38:58 -0700 (PDT), Thomas Harte (TH) wrote: hallo, friedrich, and thanks for your reply. if i Stangle your code i get: sp- make.ar.1(alpha=.5, n=800) plot(sp, type=l, col=blue)

### Re: [R] for() loop question

On Sat, 2006-08-26 at 13:06 -0400, Wensui Liu wrote: Dear Lister, If I have a list of number, say x-c(0.1, 0.5, 0.6...), how to use a for() to loop through each number in x one by one? Thank you so much! wensui Two options: x - c(0.1, 0.5, 0.6) for (i in x) {print (i)} [1] 0.1 [1]

### Re: [R] for() loop question

let us know what you want to do because the beauty of R is that, in many cases, you may not have to loop. - Original Message - From: Wensui Liu [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Saturday, August 26, 2006 1:06 PM Subject: [R] for() loop question Dear Lister, If I

### [R] Can R compute the expected value of a random variable?

Dear All Can R compute the expected value of a random variable? Thanks in advance, Paul __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

### Re: [R] Can R compute the expected value of a random variable?

Yes. On 8/26/06, Paul Smith [EMAIL PROTECTED] wrote: Dear All Can R compute the expected value of a random variable? Thanks in advance, Paul __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

### Re: [R] fitting a gaussian to some x,y data

Success! The line I needed was: gcoeffs -nls(y~(a/b)*exp(-(x-c)^2/(2*b^2)),start=list (a=0.4,b=2,c=-10), trace=TRUE) I also needed to provide good guesses for a, b and c. The attached PNG should explain what I was going after, which is the line in the center of that curve. I am sorry for

### Re: [R] Implementing EM Algorithm in R!

Implementing the EM algorithm will be easy if you know what the algorithm is for your particular problem. This will be very specific to your problem. The trick is to augment your data to get something for which there is an easy ML estimate. I do not believe there is a unique recipe to perform the

### Re: [R] fitting a gaussian to some x,y data

Whoops, I forgot to add, many thanks to all who replied publicly and privately. I am very appreciative of all comments and suggestions. Mark Leeds was especially kind in terms of clarifying why my description of the situation was so confusing. Cheers, Michael On Aug 26, 2006, at 2:51 PM,

### [R] boxplot( ..args.., axes=FALSE, frame.plot=TRUE) doesn't frame the plot

I'm running R 2.3.1 on Windows. When calling boxplot(), shouldn't the axes and frame.plot arguments get passed down to bxp()? A specific example where the plot is not framed (but seems like it should be): X - data.frame(x=as.factor(rep(c(1,2,3), 10)), y=rnorm(30)) boxplot(y~x, data=X,

### [R] Type II and III sum of square in Anova (R, car package)

Hello everybody, I have some questions on ANOVA in general and on ANOVA in R particularly. I am not Statistician, therefore I would be very appreciated if you answer it in a simple way. 1. First of all, more general question. Standard anova() function for lm() or aov() models in R implements

### [R] Capture of iterative integration output

Hello, I am a novice R user and am having difficulty retrieving the values from 21 iterations of the R function integrate. The only way I have found is to do a write.table and then a read.table as shown in the code below. I would rather capture the 21 values inside the braces ( sapply might

### [R] Permanently changing gui preferences

Greetings, I made changes to my gui preferences and saved them. When I close and then open R, it reverts back to default preferences. How do I permanently change gui preferences? Thanks in advance. David -- David

### [R] Importing data from clipboard on Mac OSX

Dear R users, I am trying to get data from the clipboard into R on MacOSX. I tried the following, but got an error message: read.delim(clipboard) Error in file(file, r) : unable to open connection In addition: Warning message: unable to contact X11 display Obviously, I'm not running R using

### Re: [R] How to iteratively extract elements out of a list

On Sat, 26-Aug-2006 at 09:57AM +0100, Patrick Burns wrote: | sub.m - lapply(m, function(x)x[x2]) | sub.m | [[1]] | [1] 3 4 | | [[2]] | [1] 4 5 | | [[3]] | [1] 4 | | sub.m[unlist(lapply(sub.m, function(x) length(x) == 2))] | [[1]] | [1] 3 4 | | [[2]] | [1] 4 5 | | sub4.m - lapply(m,

### Re: [R] How to iteratively extract elements out of a list

On 8/26/06, Patrick Connolly [EMAIL PROTECTED] wrote: On Sat, 26-Aug-2006 at 09:57AM +0100, Patrick Burns wrote: | sub.m - lapply(m, function(x)x[x2]) | sub.m | [[1]] | [1] 3 4 | | [[2]] | [1] 4 5 | | [[3]] | [1] 4 | | sub.m[unlist(lapply(sub.m, function(x) length(x) == 2))] |

### Re: [R] Capture of iterative integration output

Thanks for the reply Sego, Landon H. The vector is created as you say. However, only the first iteration of integrate is captured. The other twenty vector values remain at 0. Integrate output includes several attributes and I only want the first one which is under $names and called value

### [R] how to create many objects with sequencial names?

Dear Lister, Is there a way to create many objects with sequencial names, say lm1, lm2...lm100? Thanks. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

### Re: [R] how to create many objects with sequencial names?

Yes there is with statements like: assign(paste('m', i, sep='', value) But I would suggest that you put the values in a list to make it easier to access since all the data is in a single object. You could do it in a loop: result - list() for(i in 1:100){ ..computation.

### Re: [R] how to create many objects with sequencial names?

Hi, Jim, It is you again. I couldn't remember how many times you answered my silly questions. ^_^ I am not sure assign() is what I want. Say, if I want to create 1000 linear model objects with names lm1, lm2lm1000, it seems assign can't solve it. But your second solution is close to what I

### [R] Simulations in R during power failure

Hi everyone, I recently ran a simulation on a computer using R that was hooked up to a UPS. There was one time when the power was out for length and the computer shut down. I was worried that I had lost the simulation, but upon booting the machine up, I heard the processor kick in. It

### [R] Students With Writing Difficulties?

If you have undergraduates who have trouble writing a decent term paper, or postgraduates who are having problems with their theses or publications, we may be able to help you. We offer a personalised, online, tuition service designed to help students and academics produce solid, well argued

### Re: [R] Modifying the embed-results

Thanks! I see, that do.call-function is used often in R-algorithms... Looking over some extra do.call-examples seems useful. This tail-function is also new for me. Is there some reason to use seq(along = VECTOR) instead of 1:length(VECTOR)? Atte You can replace the for with lapply like

### Re: [R] Permanently changing gui preferences

David Kaplan a écrit : Greetings, I made changes to my gui preferences and saved them. When I close and then open R, it reverts back to default preferences. How do I permanently change gui preferences? one way is using options() and also using your Rprofile.site file (in ~/etc). edit it.

### Re: [R] Simulations in R during power failure

[EMAIL PROTECTED] a écrit : Hi everyone, I recently ran a simulation on a computer using R that was hooked up to a UPS. There was one time when the power was out for length and the computer shut down. I was worried that I had lost the simulation, but upon booting the machine up, I heard

### Re: [R] Type II and III sum of square in Anova (R, car package)

1. First of all, more general question. Standard anova() function for lm() or aov() models in R implements Type I sum of squares (sequential), which is not well suited for unbalanced ANOVA. Therefore it is better to use Anova() function from car package, which was programmed by John Fox to use