Re: [R] a simple reshape

2020-04-03 Thread Jim Lemon
Hi Ding, If you are still having trouble, perhaps: library(prettyR) stretch_df(test1,"vntr1","val") Jim On Sat, Apr 4, 2020 at 5:58 AM Yuan Chun Ding wrote: > > Hi R users, > > I want to do a data reshape from long to wide, I thought it was easy using > tidyverse spread function, but it did no

Re: [R] Label

2020-04-03 Thread Jim Lemon
Hi Val, A good suggestion. The revised code is below and it will be in the next version of plotrix. barlabels<-function(xpos,ypos,labels=NULL,cex=1,prop=0.5,miny=0,offset=0, nobox=FALSE,...) { if(is.data.frame(ypos)) ypos<-as.matrix(ypos) if(is.null(labels)) labels<-ypos # usually don't want

Re: [R] a simple reshape

2020-04-03 Thread Rui Barradas
Hello, That function is new (tidyr 1.0.0) and exists in packageVersion('tidyverse') #[1] ‘1.3.0’ packageVersion('tidyr') #[1] ‘1.0.2’ From the help page ?pivot_wider: Details pivot_wider() is an updated approach to spread(), designed to be both simpler to use and to handle more use cases. We

Re: [R] a simple reshape

2020-04-03 Thread Jeff Newmiller
Update your packages. If you still have issues post the output of sessionInfo(). On April 3, 2020 12:17:54 PM PDT, Yuan Chun Ding wrote: >Hi Rui, > >Thanks a lot, > >i got this error, I have library(tidyverse). > >Ding > >Error in pivot_wider(., id_cols = "vntr1", names_from = "group", >names_pre

Re: [R] a simple reshape

2020-04-03 Thread Yuan Chun Ding
Hi Rui, Thanks a lot, i got this error, I have library(tidyverse). Ding Error in pivot_wider(., id_cols = "vntr1", names_from = "group", names_prefix = "a", : could not find function "pivot_wider" From: Rui Barradas [ruipbarra...@sapo.pt] Sent: Fr

Re: [R] a simple reshape

2020-04-03 Thread Rui Barradas
Hello, It's a bit more complicated than you have coded it. I will use pivot_wider, it's now the natural way of doing it. test1 %>% group_by(vntr1) %>% mutate(group = row_number()) %>% ungroup() %>% pivot_wider( id_cols ="vntr1", names_from = "group", names_prefix = "a",

[R] a simple reshape

2020-04-03 Thread Yuan Chun Ding
Hi R users, I want to do a data reshape from long to wide, I thought it was easy using tidyverse spread function, but it did not work well. Can you help me? Thank you, Ding test1 data frame is long file and test2 is the wide file I want to get test1 <- data.frame (vntr1=c("v1","v1", "v2","v2"

Re: [R] Label

2020-04-03 Thread Val
Thank you Jim, Is it possible to format the label box? The labels(numbers) are surrounded by a big square and wanted to remove it. I just want display only the number. I searched up the documentation for "barlabels" and there is no such example barlabels(xpos,ypos,labels=NULL,cex=1,prop=0.5,min

Re: [R] ncol() vs. length() on data.frames

2020-04-03 Thread Greg Snow
As others have pointed out, ncol calls the length function, so you are pretty safe in terms of output of getting the same result when applied to the results of functions like read.csv (there will be a big difference if you ever apply those functions to a matrix or some other data structures). One

Re: [R] nls problem

2020-04-03 Thread William Dunlap via R-help
If you will be copying the printed coefficients into your function (instead of just using fitted() or predict()), then use dput(coef(m)) to get them printed to full precision. Also, if you regress on pH-7 instead of pH you don't have to worry so much about the roundoff or cancellation error. This

Re: [R] Question about nlminb function

2020-04-03 Thread J C Nash
This thread points out the important and often overlooked difference between "convergence" of an algorithm and "termination" of a program. I've been pushing this button for over 30 years, and I suspect that it will continue to come up from time to time. Sometimes it is helpful to put termination c

Re: [R] Question about nlminb function

2020-04-03 Thread Ivan Krylov
On Thu, 2 Apr 2020 10:26:07 + "Lim, Hwanggyu" wrote: > when n-1th estimates and nth estimates have absolute differences > less than 0.001 for all three parameters, the iteration must stop > I am using nlminb optimization function nlminb function uses the PORT library. According to [1], the