Re: [R] Help with the Error Message in R "Error in 1:nchid : result would be too long a vector"

2020-09-21 Thread David Winsemius
@Rahul; You need to learn to post in plain text and attachments may not be xls or xlsx. They need to be text files. And even if they are comma separated files and text, they still need to be named with a txt extension. I'm the only one who got the xlsx file. I got the error regardless of

Re: [R] How to model multiple categorical variable in r, using gee model

2020-09-21 Thread Jim Lemon
Hi Augustinius, You have been set a problem that requires a lot more information than is in your request. Also, you have flagged it as a "homework" problem, so you are unlikely to get much help on this list. Sadly, this sort of problem sometimes arises when being nice to the instructor is more

Re: [R] How to model multiple categorical variable in r, using gee model

2020-09-21 Thread augustinus ntjamba
Thanks for coming through sir. I will check it out. On Tue, Sep 22, 2020 at 2:47 AM Jim Lemon wrote: > Hi Augustinius, > You are probably familiar with some of these: > > http://finzi.psych.upenn.edu/R/library/geepack/html/geeglm.html > >

Re: [R] How to model multiple categorical variable in r, using gee model

2020-09-21 Thread Jim Lemon
Hi Augustinius, You are probably familiar with some of these: http://finzi.psych.upenn.edu/R/library/geepack/html/geeglm.html https://faculty.washington.edu/heagerty/Courses/b571/homework/geepack-paper.pdf https://rdrr.io/cran/geex/f/vignettes/articles/mestimation_bib.Rmd Good luck with it. Jim

Re: [R] Help with the Error Message in R "Error in 1:nchid : result would be too long a vector"

2020-09-21 Thread Rahul Chakraborty
Hello David and everyone, I am really sorry for not abiding by the specific guidelines in my prior communications. I tried to convert the present email in plain text format (at least it is showing me so in my gmail client). I have also converted the xlsx file into a csv format with .txt

[R] date

2020-09-21 Thread Val
Hi All, I am trying to sort dates within a group. My sample data is df <-read.table(text="ID date A1 09/17/04 A1 01/27/05 A1 05/07/03 A2 05/21/17 A2 09/12/16 A3 01/25/13 A4 09/27/19",header=TRUE,stringsAsFactors=F) df$date2 = as.Date(strptime(df$date,format="%m/%d/%y")) df$date

[R] open file on R GUI results in spinning wheel and frozen R - Mac OS

2020-09-21 Thread Gonçalo Ferraz
Hello, I’ve been using R-studio for a while and today I needed to try something directly on the R-GUI. But when I try to open any *.R file I get a spinning wheel and R freezes. I can only shut it down with ‘force quit’. I have deleted and re-installed R three times, each time trying to run a

Re: [R] formula wrangling

2020-09-21 Thread John Fox
Dear Roger, This is an interesting puzzle and I started to look at it when your second message arrived. I can simplify your code slightly in two places, here: if (exists("fqssnames")) { mff <- m ffqss <- paste(fqssnames, collapse = "+") mff$formula <-

Re: [R] open file on R GUI results in spinning wheel and frozen R - Mac OS

2020-09-21 Thread Bert Gunter
You might do better on r-sig-mac for this. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Sep 21, 2020 at 11:24 AM Gonçalo Ferraz wrote:

Re: [R] aggregate semi-hourly data not 00-24 but 9-9

2020-09-21 Thread Eric Berger
Hi Stefano, If you mean from 9am on one day to 9am on the following day, you can do a trick. Simply subtract 9hrs from each timestamp and then you want midnight to midnight for these adjusted times, which you can get using the method you followed. I googled and found that lubridate::hours() can

Re: [R] Is there a simple way to analyse all the data using dplyr?

2020-09-21 Thread Chris Evans
Thanks Eric, That's very neat! Sort of fits my belief about base R and telegrams (that's not knocking it, I really do respect it, my wetware is just not good at it). For many reasons, particularly the convenience for formatting and passing on results from the real function I'm applying, I am

Re: [R] aggregate semi-hourly data not 00-24 but 9-9

2020-09-21 Thread Jeff Newmiller
The base R as.difftime function is perfectly usable to create this offset without pulling in lubridate. On September 21, 2020 8:06:51 AM PDT, Eric Berger wrote: >Hi Stefano, >If you mean from 9am on one day to 9am on the following day, you can >do a trick. Simply subtract 9hrs from each

Re: [R] Quadratic programming

2020-09-21 Thread Abby Spurdle
Hi, Sorry, for my rushed responses, last night. (Shouldn't post when I'm about to log out). I haven't used the quadprog package for nearly a decade. And I was hoping that an expert using optimization in finance in economics would reply. Some comments: (1) I don't know why you think bvec should

Re: [R] Help with the Error Message in R "Error in 1:nchid : result would be too long a vector"

2020-09-21 Thread David Winsemius
If you had included output of summary(mydata) we might be more capable of giving a fact-based answer but I'm guessing that you have a lot of catagorical variables with multiple levels and some sort of combinatoric explosion is resulting in too many levels of a constructed factor. -- David.

[R] Help with the Error Message in R "Error in 1:nchid : result would be too long a vector"

2020-09-21 Thread Rahul Chakraborty
Hello everyone, I am using *mlogit* to analyse my choice experiment data. I have *3 alternatives* for each individual and for each individual I have *9 questions*. I have a response from *516 individuals*. So it is a panel of 9*516 observations. I have arranged the data in long format (it

Re: [R] Help with the Error Message in R "Error in 1:nchid : result would be too long a vector"

2020-09-21 Thread Rahul Chakraborty
Hello, Here is the result of summary(mydata) summary(mydata) INDBlockQES STR ALT Min. : 1.0 Min. :1.000 Min. :1 Min. : 101 Min. :1 1st Qu.:129.8 1st Qu.:1.000 1st Qu.:3 1st Qu.:12978 1st Qu.:1 Median :258.5 Median

Re: [R] Help with the Error Message in R "Error in 1:nchid : result would be too long a vector"

2020-09-21 Thread Rahul Chakraborty
Hello, I tried to reduce the size of my dataframe. Now I have 57 columns of which 29 are already dummy coded. If I run *mldata1<- mlogit.data(mydata1, shape = "long", alt.var = "Alt_name", choice = "Choice_binary", id.var = "IND") *it still gives me the same error message-* Error in 1:nchid :

Re: [R] date

2020-09-21 Thread Sarah Goslee
Hi, Nice reproducible example. rev(df$date2) isn't doing what you think it's doing - try looking at it by itself. Some digging into ?order will get you what you are after: df[order(df$ID, df$date2, decreasing=c(FALSE, TRUE), method="radix"),] > df[order(df$ID, df$date2, decreasing=c(FALSE,

Re: [R] open file on R GUI results in spinning wheel and frozen R - Mac OS

2020-09-21 Thread Berend Hasselman
> On 21 Sep 2020, at 20:24, Gonçalo Ferraz wrote: > > Hello, > > I’ve been using R-studio for a while and today I needed to try something > directly on the R-GUI. > > But when I try to open any *.R file I get a spinning wheel and R freezes. I > can only shut it down with ‘force quit’. >

Re: [R] date

2020-09-21 Thread Duncan Murdoch
Another way to do this is to use the xtfrm() function. That function creates numerical values from many different starting types, so you can just change the sign to change the sort order: df[order(df$ID, -xtfrm(df$date2)),] I never did figure out where the name came from. Duncan Murdoch On

Re: [R] Quadratic programming

2020-09-21 Thread Abby Spurdle
I was wondering if you're trying to fit a curve, subject to monotonicity/convexity constraints... If you are, this is a challenging topic, best of luck... On Tue, Sep 22, 2020 at 8:12 AM Abby Spurdle wrote: > > Hi, > > Sorry, for my rushed responses, last night. > (Shouldn't post when I'm about

[R] Quadratic programming

2020-09-21 Thread Maija Sirkjärvi
Hi! I was wondering if someone could help me out. I'm minimizing a following function: \begin{equation} $$\sum_{j=1}^{J}(m_{j} -\hat{m_{j}})^2,$$ \text{subject to} $$m_{j-1}\leq m_{j}-\delta_{1}$$ $$\frac{1}{Q_{j-1}-Q_{j-2}} (m_{j-2}-m_{j-1}) \leq \frac{1}{Q_{j}-Q_{j-1}}

[R] formula wrangling

2020-09-21 Thread Koenker, Roger W
I need some help with a formula processing problem that arose from a seemingly innocuous request that I add a “subset” argument to the additive modeling function “rqss” in my quantreg package. I’ve tried to boil the relevant code down to something simpler as illustrated below. The formulae

Re: [R] Quadratic programming

2020-09-21 Thread Abby Spurdle
Are you using the quadprog package? If I can take a random shot in the dark, should bvec be -bvec? On Mon, Sep 21, 2020 at 9:28 PM Maija Sirkjärvi wrote: > > Hi! > > I was wondering if someone could help me out. I'm minimizing a following > function: > > \begin{equation} >

Re: [R] Quadratic programming

2020-09-21 Thread Maija Sirkjärvi
Thank you for your response! Bvec is supposed to be a matxit. I'm following the solve.QP ( https://www.rdocumentation.org/packages/quadprog/versions/1.5-8/topics/solve.QP ). I'm not sure what would be the best way to solve a quadratic programming problem in R. ma 21. syysk. 2020 klo 13.20 Abby

Re: [R] Mapping 2D to 3D

2020-09-21 Thread Abby Spurdle
Hi H, I probably owe you an apology. I was just reading the geom_contour documentation. It's difficult to follow. Base R functions, my functions, and pretty much everyone's functions, take a matrix as input. But as far as I can tell, geom_contour wants a data.frame with three {x, y and z}

Re: [R] Quadratic programming

2020-09-21 Thread Abby Spurdle
Sorry, ignore the last part. What I should have said, is the inequality has the opposite sign. >= bvec (not <= bvec) On Mon, Sep 21, 2020 at 10:05 PM Abby Spurdle wrote: > > Are you using the quadprog package? > If I can take a random shot in the dark, should bvec be -bvec? > > > On Mon, Sep

Re: [R] Quadratic programming

2020-09-21 Thread Abby Spurdle
One more thing, is bvec supposed to be a matrix? Note you may need to provide a reproducible example, for better help... On Mon, Sep 21, 2020 at 10:09 PM Abby Spurdle wrote: > > Sorry, ignore the last part. > What I should have said, is the inequality has the opposite sign. > >= bvec (not <=

Re: [R] formula wrangling

2020-09-21 Thread Koenker, Roger W
Here is a revised snippet that seems to work the way that was intended. Apologies to anyone who wasted time looking at the original post. Of course my interest in simpler or more efficient solutions remains unabated. if (exists("fqssnames")) { mff <- m mff$formula <- Terms

[R] [R-pkgs] ascii package returns to CRAN

2020-09-21 Thread Mark Clements
The ascii package provides formatted tables and lists in a number of markup formats (Asciidoc, Org mode, Pandoc markdown, ReStructured text, Txt2tags and Textile). Documents in Rmarkdown and Org mode can include R code blocks that produce markup output. Sweave drivers are also available for all

[R] How to model multiple categorical variable in r, using gee model

2020-09-21 Thread augustinus ntjamba
Good morning. I'm a student at present working on my final year project. Kindly asking for help on how to model longitudinal categorical data. In my data set I have the following variables :type of crime,year, month, date and time.treating type of crime as the response variable and there's 12

Re: [R] Is there a simple way to analyse all the data using dplyr?

2020-09-21 Thread Eric Berger
Hi, I am not sure if the request is about a 'simple way' or requires dplyr. Here's an approach without using dplyr that is just 2 lines (not counting creating the data or outputting the result). n <- 500 myDf <- data.frame( gender=sample(c("Man","Woman","Other"), n, replace = TRUE),

[R] aggregate semi-hourly data not 00-24 but 9-9

2020-09-21 Thread Stefano Sofia
Dear R-list members, I have semi-hourly snowfall data. I should sum the semi-hourly increments (only the positive ones, but this is not described in my example) day by day, not from 00 to 24 but from 9 to 9. I am able to use the diff function, create a list of days and use the function

[R] Is there a simple way to analyse all the data using dplyr?

2020-09-21 Thread Chris Evans
I am sure the answer is "yes" and I'm also sure the question may sound mad. Here's a reprex that I think captures what I'm doing n <- 500 gender <- sample(c("Man","Woman","Other"), n, replace = TRUE) GPC_score <- rnorm(n) scaleMeasures <- runif(n) bind_cols(gender = gender, GPC_score =

Re: [R-es] pedido de ayuda

2020-09-21 Thread Proyecto R-UCA
Buenas Emilio, Ana y erreros: Llevo mucho tiempo sin recibir los mensajes de esta cuenta debido a un problema con mi cliente de correo. Mucha gracias Emilio por recomendar nuestro paquete y nuestro material. Con respecto a la recomendación que te hiciero de R-Studio, por probar no pasa nada.

Re: [R-es] TOMAR ID (número de orden de las filas) DE DATAFRAME Y CONVERTIRLO EN UNA COLUMNA (VARIABLE) NUEVA

2020-09-21 Thread Juan Carlos Lopez Mesa
Hola data %>% mutate(nueva_variable = row_number()) El dom., 20 sept. 2020 a las 11:47, Jesus MARTIN F. () escribió: > Buenas tardes, > > Consulto cómo tomar el ID (número de orden de las filas) de un DATAFRAME > y hacer un "mutate" a una variable nueva que contenga ese valor (número de >