[R] help with LDA topic modelling..

2021-12-19 Thread akshay kulkarni
dear members, I am using LDA for topic modelling of news articles (topicmodels package). I am visualizing the accuracy with the LDAvis package. The visualization shows clusters as circles, probably intersecting. My question is, if a find the optimal number of topics, k,

Re: [R] Sum every n (4) observations by group

2021-12-19 Thread Avi Gross via R-help
Milu, Your data seems to be very consistent in that each value of ID has eight rows. You seem to want to just sum every four so that fits: ID Date Value 1 A 4140 0.000207232 2 A 4141 0.000240141 3 A 4142 0.000271414 4 A 4143 0.000258384 5 A 4144 0.000243640 6 A 4145

Re: [R] Sum every n (4) observations by group

2021-12-19 Thread Miluji Sb
Dear Peter, Thanks so much for your reply and the code! This is helpful. What I would like is the data.frame below - sum values for *4140, 4141, 4142, 4143 *and then for *4144, 4145, 4146, 4147 *for IDs A, B, and C. Does that make sense? Thanks again! Best. Milu results <- structure(list(ID =

Re: [R] Sum every n (4) observations by group

2021-12-19 Thread Peter Langfelder
I'm not sure I understand the task, but if I do, assuming your data frame is assigned to a variable named df, I would do something like sumNs = function(x, n) { if (length(x) %%n !=0) stop("Length of 'x' must be a multiple of 'n'.") n1 = length(x)/n ind = rep(1:n1, each = n) tapply(x,

[R] Sum every n (4) observations by group

2021-12-19 Thread Miluji Sb
Dear all, I have a dataset (below) by ID and time sequence. I would like to sum every four observations by ID. I am confused how to combine the two conditions. Any help will be highly appreciated. Thank you! Best. Milu ## Dataset structure(list(ID = c("A", "A", "A", "A", "A", "A", "A", "A",

Re: [R] Bug in list.files(full.names=T)

2021-12-19 Thread Duncan Murdoch
I don't know the answer to your question, but I see the same behaviour on MacOS, e.g. list.files("./") includes ".//R" in the results on my system. Both "./R" and ".//R" are legal ways to express that path on MacOS, so it's not a serious bug, but it does look ugly. Duncan Murdoch On

[R] Speed up studentized confidence intervals ?

2021-12-19 Thread varin sacha via R-help
Dear R-experts, Here below my R code working but really really slowly ! I need 2 hours with my computer to finally get an answer ! Is there a way to improve my R code to speed it up ? At least to win 1 hour ;=) Many thanks library(boot)

[R] Bug in list.files(full.names=T)

2021-12-19 Thread Mario Reutter
Dear everybody, I'm a researcher in the field of psychology and a passionate R user. After having updated to the newest version, I experienced a problem with list.files() if the parameter full.names is set to TRUE. A path separator "/" is now always appended to path in the output even if path %>%