similar to: par mfrow in "function" problem

Displaying 20 results from an estimated 1000 matches similar to: "par mfrow in "function" problem"

2009 Sep 02
2
Howto fit normal curve into histogram using GGPLOT2
Currently, I am doing it this way. x <- mtcars$mpg h<-hist(x, breaks=10, col="red", xlab="Miles Per Gallon", main="Histogram with Normal Curve") xfit<-seq(min(x),max(x),length=40) yfit<-dnorm(xfit,mean=mean(x),sd=sd(x)) yfit <- yfit*diff(h$mids[1:2])*length(x) lines(xfit, yfit, col="blue", lwd=2) But since, ggplot2 has more appealing
2005 Oct 14
1
lattice with predicted values
Dear lattice wizards, I am trying to figure out how to plot predicted values in xyplot, where the intercept, but not the slope, varies among conditioning factor levels. I am sure it involves the groups, but I have been unsuccessful in my search in Pinhiero and Bate, in the help files, or in the archive, or in my attempts on my own. My example follows: FACT is a factor with levels a,b,c
2010 Feb 19
1
"Legend" question
Hi, I want to get a histogram with the legend for my data. I drew a normal density curve and kernel density curve in the histogram, and I also label mean and median in the X axis. From the code, I got two legend: One shows "Normal Density" and "Kernel Density" and their corresponding lines, the other shows "Mean = value" and "Median = value" and their
2007 Jun 07
2
Nonlinear Regression
Hello I followed the example in page 59, chapter 11 of the 'Introduction to R' manual. I entered my own x,y data. I used the least squares. My function has 5 parameters: p[1], p[2], p[3], p[4], p[5]. I plotted the x-y data. Then I used lines(spline(xfit,yfit)) to overlay best curves on the data while changing the parameters. My question is how do I calculate the residual sum of squares.
2004 Feb 23
2
deleting elements from an array/object
Hello, I created a simple histogram with: myHist<-hist(myData) the object myHist now has two arrays (among the others): myHist$mids myHist$counts Since myHist$counts contains some "0", and I want to calculate the linear fit among myHist$mids and log(myHist$counts), I want remove the elements of both arrays where these "0" occurs. which are the possible solutions to
2004 Aug 24
0
additional examples for R-intro.texi (PR#7195)
Here are some patches to expand some of the examples in R-intro.texi. -- Brian Gough Network Theory Ltd, Publishing the R Reference Manuals --- http://www.network-theory.co.uk/R/ --- R-intro.texi~ Tue Aug 24 11:21:37 2004 +++ R-intro.texi Tue Aug 24 11:21:37 2004 @@ -6288,6 +6288,21 @@ use @example +> help(package = "@var{name}") +@end example + +A complete list of the
2001 Oct 13
2
hist and normal curve
Dear R people: I would like to superimpose a normal curve on a histogram. I've seen this example in a book, somewhere. I know that you draw the hist, get the mean and sd of the data set, but then I'm stuck. Could you help, please? Thanks! Erin hodgess at uhddx01.dt.uh.edu -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read
1999 Dec 09
1
nlm() problem or MLE problem?
I am trying to do a MLE fit of the weibull to some data, which I attach. fitweibull<-function() { rt<-scan("r/rt/data2/triam1.dat") rt<-sort(rt) plot(rt,ppoints(rt)) a<-9 b<-.27 fn<-function(p) -sum( log(dweibull(rt,p[1],p[2])) ) cat("starting -log like=",fn(c(a,b)),"\n") out<-nlm(fn,p=c(a,b), hessian=TRUE)
2005 Sep 25
4
hist(x, ...) with normal distribution curve
. I am looking for a histogram or box plot with the adding normal distribution curve I think that must be possible, but I am not able to find out how to do. Regards Knut
2004 Feb 28
1
Basic general statistical problem.
Hello everyone, I'd like to have suggestions about a common basic statistical approach, hope to be useful also for other R beginners. When you first get some data (i.e length of river) you may want to look at its distribution. Then you probably want to find which law follows this distribution, and to test the goodness of the fit. For doing this simple analysis I am writing some code
2000 Nov 09
2
simple mixture
Dear All, I am trying to do some simple mixture analyses. For instance, I have a sample of n observations and I suspect they come from two different exponential distributions with parameters rate1 and rate2, respectively. So, I want to estimate rate1, rate2, and the proportions of both kinds of individuals in the sample. I had a look at the packages mda and mclust, but they do not seem to do this
2009 Oct 09
1
Substituting the extracted coefficients into the formula, exctracted from the result of nls()
Dear all, Here I come with another stupid question. Suppose I want to use nls() to fit a series of data (here modelled by generated points), then plot the points and the fitting curve. I figured out some way of doing it: x <- runif(1:20, 0, 10) y <- 0.1*x^2 - rep(3, length(x)) + rnorm(length(x), sd = 0.5) yfit <- nls(y ~ a*x^2 + b*x + c, start = list(a = 1, b = 1, c = 1),
2009 Jun 21
2
Help on qpcR package
I am using R on a Windows XP professional platform. The following code is part of a bigger one CODE press=function(y,x){ library(qpcR) models.press=numeric(0) cat("\n") dep=y print(dep) indep=log(x) print(indep) yfit=dep-PRESS(lm(dep~indep))[[2]] cat("\n yfit\n") print(yfit) yfit.orig=yfit presid=y-yfit.orig press=sum(presid^2)
2005 Oct 14
2
Help with lattice, regressions and respective lines
# Dear R list, # # I'm needing help with lattice, regression and respective lines. # My data is below: bra = gl(2, 24, label = c('c', 's')) em = rep(gl(3, 8, label = c('po', 'pov', 'ce')), 2) tem = rep(c(0, 0, 30, 30, 60, 60, 90, 90), 6) tem2 = tem^2 r = rep(1:2, 24) y = c(40.58, 44.85, 32.55, 35.68, 64.86, 51.95, 42.52, 52.21,
2005 Aug 12
6
evaluating string variables
Hello!!! I have a folder (C:/R/) with matrix files, named by number, i.e. 0.mat, 1.mat,...,1250.mat. In this case, they are 5x5 simetric matrices. I would like to compute a property for each matrix and put calculated values into a data frame for posterior ploting and printing. Below there is an example for 7 matrices (0.mat..6.mat) #define data frame L <- data.frame(frame=numeric(7),
2004 Oct 11
2
question on function argument
dear all, i've looked at the r-intro (chapter 10, writing your own functions) and searched the r-help archives but am still stuck at the following. i have a simple function, something like: myhist<-function(yvar) { y<-subset(myframe,yvar>1 & yvar<=150000,select=yvar) attach(y) hist(yvar) } calling it as follows: myhist(x1) gives the following error: Error in
2010 Apr 25
1
How to save as PDF when I used par(ask=T)
====================================================== y=c(9,9,17,11,7,8,15,5) treat=c("A","C","B","C","D","A","B","D") block=c(1,1,2,2,2,3,3,3) q1.mod=aov(y~as.factor(treat)+as.factor(block)) q1.mod summary(q1.mod) par(ask=T) plot(TukeyHSD(q1.mod)) ======================================================= This way,
2008 Jun 16
4
Superimposing Line over Histogram in Density Plot
Hi, Currently I have a density plot generated with this snippet. Is there a way I can add a line curve on top of it? I mean in one figure __BEGIN__ myhist <- hist(x col="blue", main = "Density Plot", xlab = "Exp Level", ) __END__ - Gundala Viswanath Jakarta - Indonesia
2010 Nov 20
3
how to add frequencies to barplot
Hi, I have count data x2=rep(c(0:3),c(13,80,60,27)) x2 0 1 2 3 13 80 60 27 I want to graph to be ploted as barplot(table(x2),density=4) how do I add relative frequency to it, like in hist(x2,labels=T) above the 'bar's Thanks. casper -- View this message in context: http://r.789695.n4.nabble.com/how-to-add-frequencies-to-barplot-tp3051923p3051923.html Sent from the R help
2010 Nov 28
4
how to divide each column in a matrix by its colSums?
Hi, I have a matrix, say m=matrix(c( 983,679,134, 383,416,84, 2892,2625,570 ),nrow=3 ) i can find its row/col sum by rowSums(m) colSums(m) How do I divide each row/column by its rowSum/colSums and still return in the matrix form? (i.e. the new rowSums/colSums =1) Thanks. Casper -- View this message in context: