Hi lily,
If you want to use aggregate, supply the name of the function:
aggregate(flow~year, data=df, "sum")
You can also use "by" like this
by(df$flow,df$year,FUN=sum)
I assume that you don't have to worry about missing months in a year.
Jim
:
On Thu, Dec 1, 2016 at 3:06 PM, lily li wrote:
> On 1 Dec 2016, at 05:06, lily li wrote:
>
> Hi R users,
>
> I'm trying to manipulate dataset, but met some difficulties.
>
> df
> year month flow
> 2006 33.5
> 2006 43.8
> 2006 521
> 2006 632
> 2007 34.1
> 2007 44.4
## Use the split argument to summary.aov
## This tests the levels of tension within each level of wool using a common
## Residuals sum of squares.
sapply(warpbreaks, levels)
model2 <- aov(breaks ~ wool/tension, data = warpbreaks)
colnames(model.matrix(model2))
## [1] "(Intercept)""woolB"
Hi R users,
I'm trying to manipulate dataset, but met some difficulties.
df
year month flow
2006 33.5
2006 43.8
2006 521
2006 632
2007 34.1
2007 44.4
...
I want to calculate total flow for each year, and use the code bel
Dear All,
Suppose I do :-
head(warpbreaks)
model1<- aov(breaks ~ wool*tension,data = warpbreaks)
summary(model1)
There is significant interaction. So I need to test for simple effects of
wool at each level of tension and vice versa. I can do a subset and then
do a one way anova for each level o
Hello,
I have been toying with the survey package's withReplicates function, which
lets users easily extend the survey package to support any weighted statistic.
There are a number of ML algorithms in various packages that accept weights,
and it is fairly easy to use them with withReplicates. B
On Tue, 29 Nov 2016 17:22:47 + (UTC)
Elham - via R-help wrote:
> Is there another way (I prefer a way with Excel)?
Search on "friends don't let friends use excel for statistics."
Spreadsheets are an inherently perilous way to do statistics and Excel
specifically is notoriously poor. In fact
A dot is treated differently if it has a number on no, one, or both sides.
> stri_extract_all_words("me.com", simplify = TRUE)
[,1]
[1,] "me.com"
> stri_extract_all_words("me1.com", simplify = TRUE)
[,1] [,2]
[1,] "me1" "com"
> stri_extract_all_words("me1.2com", simplify = TRUE)
[,
Hello!
library(stringi)
stri_extract_all_words("me.com", simplify = TRUE) # returns with a dot
stri_extract_all_words("watch32.com", simplify = TRUE) # removes the dot
Why is the dot removed only in the second case?
How is it possible to ask it NOT to remove the dot in the second case?
Hello,
I am working with the naïve bayes function inlibrary(e1071).
The function calls are:
transactions.train.nb = naiveBayes(as.factor(DealerID) ~
as.factor(Manufacturer)
+ as.factor(RangeDesc)
Hello,
I'm runnig a meta-analysis, correcting for clustering of standard errors
with the robumetacommand. R gives the following warning:
If df < 4, do not trust the results
In some cases my df is in fact <4. What does this tell me then? Does it
simply mean that the number of included studies is
Hi all,
If we execute an R script directly in R prompt in Linux environment, it
takes around 30 mins to complete.
The same R script if we execute from java using RConnection, eval and
Rserve for each line it takes thrice the time.
Basically the performance is very bad. And in most of the occasio
The tidyr::separate function modifies data frames. You did not give it a data
frame. Re-read your preferred R introductory material on what a data frame is
(R comes with "Introduction to R").
You also did not give a reproducible example... e.g. does not execute as-is in
a clean R work space.
Well, if i understand correctly, there's really no need to use special
packages for such simple tasks. The strsplit() function in base R does
nicely (see ?strplit):
Here is a reproducible example, --which you did not provide; please do
so in future:
> testdat <- c("abc;def;hij","qq;sdff;kuqw","op
Thank to Ulrik for the hint.
However, I don't comprehend the function until now:
For example I made up an array "input":
input
kop
[1,] "w;d;e;f"
[2,] "w;d;e;f"
[3,] "w;d;e;f"
[4,] "w;d;e;f"
[5,] "w;d;e;f"
and tried to break it into four cols with commmand:
output<-separate(into,kop
15 matches
Mail list logo