Now would be an excellent time to read the help page for ?ave. You can specify
multiple grouping variables.
--
Sent from my phone. Please excuse my brevity.
On October 28, 2016 7:28:44 PM PDT, Ashta wrote:
>Hi all thank you very much for your help. Worked very well for that
>data set. I just f
Hi all thank you very much for your help. Worked very well for that
data set. I just found out that one of the data sets have another
level and do the same thing, I want to calculate the difference
between successive row values (num) to the first row value within
city and year.
city, year, num
1,
Haven't seen a solution using ave...
d$diff <- ave( d$num, d$year, FUN = function( v ) { v - v[ 1 ] } )
--
Sent from my phone. Please excuse my brevity.
On October 28, 2016 12:46:15 PM CDT, William Dunlap via R-help
wrote:
>You could use match() to find, for each row, the index of the first
>r
My apologize, it has been solved. Just include w inside of select, such as:
select = c(w, x, y)
On Fri, Oct 28, 2016 at 12:06 PM, lily li wrote:
> Hi R users,
>
> I have the dataframe as below:
>
> w=c(5,6,7,8)
> x=c(1,2,3,4)
> y=c(1,2,3)
> length(y)=4
> z=data.frame(w,x,y)
>
> z$mean1 <- rowMea
Hi R users,
I have the dataframe as below:
w=c(5,6,7,8)
x=c(1,2,3,4)
y=c(1,2,3)
length(y)=4
z=data.frame(w,x,y)
z$mean1 <- rowMeans(subset(z, select = c(x, y)), na.rm = T)
z$mean2 <- rowMeans(subset(z, select = c(x, y)), na.rm=F)
w x y mean1 mean2
1 5 1 1 1 1
2 6 2 2 2 2
3
You could use match() to find, for each row, the index of the first
row with the give row's year:
> d <- data.frame(year=c(rep(2001, 3), rep(2002, 3)),
num=c(25,75,150,30,85,95))
> indexOfFirstOfYear <- with(d, match(year, year))
> indexOfFirstOfYear
[1] 1 1 1 4 4 4
> d$diff <- d
I read the problem incorrectly; I did not see that you wanted the
difference from the first entry; trying again:
> require(dplyr)
> input <- read.table(text = "Year Num
+ 200125
+ 200175
+ 2001 150
+ 200230
+ 200285
+ 200295", header = TRUE)
>
> input %>%
+ group_by(Yea
Here are a couple of other ways using 'dplyr' and 'data.table'
> require(dplyr)
> input <- read.table(text = "Year Num
+ 200125
+ 200175
+ 2001 150
+ 200230
+ 200285
+ 200295", header = TRUE)
>
> input %>%
+ group_by(Year) %>%
+ mutate(diff = c(0, diff(Num)))
Source
> I have created a document term matrix from corpus.I would like to apply
> Cosine similarity to find similar documents,when I apply cosine(w.mt) I get "
> Error in x[,i] : Subscript out of bounds"
> Can anyone let me know how to overcome this error?
Not specifically, from the information you have
Anusha,
You have written to r-help multiple times and are still using HTML and failing
to provide a reproducible example of your problem. Please read and comply with
the posting guide.
Mark
R. Mark Sharp, Ph.D.
msh...@txbiomed.org
> On Oct 28, 2016, at 7:07 AM, Indhira, Anusha
> wrote:
>
Hi,
I have created a document term matrix from corpus.I would like to apply Cosine
similarity to find similar documents,when I apply cosine(w.mt) I get " Error in
x[,i] : Subscript out of bounds"
Can anyone let me know how to overcome this error?
Thanks,
alily
This e-mail (including attachments
Hi,
To find similar documents in a Corpus using cosine similarity, Is it necessary
to calculate tf-idf weights while creating term document matrix or just term
frequency is fine? Can anyone let me know what are advantages and disadvantages
for both ways?
Thanks,
Anusha
This e-mail (including
recently, I bought Portfolio optimization with R/Rmetrics
and i have some problem doing it (fPortfolio Package)
*group.1 = c("minsumW[ sec1 ] = 0.215688 " , "maxsumW[ sec1 ] = 0.3126 "
) groupConstraints = c(group.1) portfolioConstraints(ret, mv,
groupConstraints)*
it works, but
*x = 0.2
Thanks Ulrik,
Using 'reactive timer ' i was partially reached to my
achievement/requirement as when ever reactive timer triggered my graph
getting blinking (PFA for same) but real streaming graph should not be
like that though at this moment i'm okay with this blinking.Here i have one
more reqi
Hi,
You could use an anonymous function to operate on each `year-block' of
your dataset, then assign the result as a new column:
d <- data.frame(year=c(rep(2001, 3), rep(2002, 3)),
num=c(25,75,150,30,85,95))
d$diff <- unlist(by(d$num, d$year, function(x) x - x[1]))
d
year n
15 matches
Mail list logo