elp@r-project.org
Subject: Re: [R] R for loop stops after 4 iterations
There's a seeming inconsistency in this question -- namely, you provide an
example of a data frame with 4 columns but say it is 27x3
-- but I think your question comes from a misunderstanding of what
length(e) calculates.
Hi:
Here are a couple of ways, using the data snippet you provided as the
input data frame e.
Start by defining the function, which outputs a percentage:
f <- function(n, mean, sd) {
s <- rnorm(n, mean = mean, s = sd)
round(100 * sum(s > 0.42)/length(s), 4)
}
(1) Use the plyr packag
On 11-10-22 7:33 PM, Philip Robinson wrote:
I have a data frame called e, dim is 27,3, the first 5 lines look like this:
V1 V2 V3V4
1 1673 0.36 0.08 Smith
2 167 0.36 0.08 Allen
399 0.37 0.06 Allen
4 116 0.38 0.07 Allen
595 0.41 0.08 Allen
Oops!!
Meant pnorm(, lower.tail = FALSE) -- don't do qnorm or bad things will happen.
Sorry,
Michael
On Sat, Oct 22, 2011 at 8:28 PM, R. Michael Weylandt
wrote:
> There's a seeming inconsistency in this question -- namely, you
> provide an example of a data frame with 4 columns but say it is
There's a seeming inconsistency in this question -- namely, you
provide an example of a data frame with 4 columns but say it is 27x3
-- but I think your question comes from a misunderstanding of what
length(e) calculates. For a data frame it gives the number of columns
back. Hence if you have a 27
5 matches
Mail list logo