" I did not pick up on by() doing the splitting for me when I read the
help..."
>From ?by:
"A data frame is split by row into data frames subsetted by the values of
one or more factors, and function FUN is applied to each subset in turn."
I do not understand how it could be more clearly stated t
On Mon, 17 Sep 2018, Bert Gunter wrote:
I cannot think of a way of proving a sample of data; if a sample for a
Typo: s/proving/providing/
Rich
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/li
Inline.
Bert
On Mon, Sep 17, 2018 at 11:54 AM Rich Shepard
wrote:
>My dataframe has 113K rows split by a factor into 58 separate
> data.frames,
> with a different numbers of rows (see error output below).
>
>I cannot think of a way of proving a sample of data; if a sample for a
> MWE
On Mon, 17 Sep 2018, MacQueen, Don wrote:
I'm also going to guess that maybe your object rainfall_by_site has
already been split into separate data frames (because of its name). But
by() does the splitting internally, so you should be passing it the
original unsplit data frame.
Don,
I did n
I'm also going to guess that maybe your object
rainfall_by_site
has already been split into separate data frames (because of its name).
But by() does the splitting internally, so you should be passing it the
original unsplit data frame.
You could supply example data by providing the first few
Try changing it to
by(rainfall_by_site, rainfall_by_site[, 'name'],
function(x) {mean.rain <- mean(x[, 'prcp'])
})
Inside the function, so to speak, the function sees an object named "x",
because that's how the function is defined: function(x).
So you have to operate on x inside
>
> by(rainfall_by_site, rainfall_by_site[, 'name'], function(x) {
>
+ mean.rain <- mean(rainfall_by_site[, 'prcp'])
+ })
Note that you define a function of x which does not use x in it.
Hence, even if the function gave a value, it would give the same
value for each group. To see what the 'x' in
My dataframe has 113K rows split by a factor into 58 separate data.frames,
with a different numbers of rows (see error output below).
I cannot think of a way of proving a sample of data; if a sample for a MWE
is desired advice on produing one using dput() is needed.
To summarize each group
8 matches
Mail list logo