Re: [R] Dplyr question

2022-06-21 Thread Jeff Newmiller
dplyr != tidyverse. And questions that presuppose a solution method demonstrate closed-mindedness, and reduce the chance that novel solutions will be put forth, or that the questioner will actually learn something instead of using the list as a glorified search engine. It is not that answers s

Re: [R] A Request

2022-06-21 Thread Jim Lemon
Hi Chishti, Try this: dim(x)[2] length(dn) >From your error message, the two will be different. They should be the same. A wild guess is that the offending line of code should be: dimnames[2]<-1:dn Jim On Tue, Jun 21, 2022 at 11:10 PM Muhammad Zubair Chishti wrote: > > Hi, Dear Professor, > W

Re: [R] Dplyr question

2022-06-21 Thread Rui Barradas
Hello, Right, intuitive is (very) relative. I was thinking of base function stats::reshape. Its main difficulty is, imho, to reshape to both wide and long formats. Compared to it, tidyr::pivot_* are (much?) easier to understand. Here is a stats::reshape solution. df_long <- reshape( data

Re: [R] Dplyr question

2022-06-21 Thread Jeff Newmiller
Beware of being too specific about how you want something solved... not just here, but in all contexts. Your question is like "how do I slice this apple with this potholder"... dplyr actually doesn't do that, and you can benefit from learning how to do things in general, not just in your preferr

Re: [R] Dplyr question

2022-06-21 Thread Ebert,Timothy Aaron
I do not see how to do this with exclusively dplyr commands. I might be able to make it work by including commands outside of dplyr, but at that point I would use pivot_longer() from the tidyr package. Tim -Original Message- From: R-help On Behalf Of Thomas Subia Sent: Tuesday, June 21

Re: [R] A Request

2022-06-21 Thread Marc Girondot
Hi, you should post a reproducible example if you want to have an answer. This error is generated when you try to copy an object in another of the wrong size. > a <- data.frame(A=1:2) > dimnames(a) [[1]] [1] "1" "2" [[2]] [1] "A" > dn <- list(c("3", "4"), c("B", "D")) > dimnames(a) <- dn Err