Re: [R] [Tagged] Re: col.names in as.data.frame() ?

2023-10-28 Thread avi.e.gross
Jef, your terse reply was so constructive that you converted me! LOL! That is an interesting point though that I remain a bit unclear on. Both data.frame and as.data.frame can be used in some ways similarly as in: > data.frame(matrix(1:12, nrow=3)) X1 X2 X3 X4 1 1 4 7 10 2 2 5 8 11 3

Re: [R] [Tagged] Re: col.names in as.data.frame() ?

2023-10-28 Thread Duncan Murdoch
On 28/10/2023 4:45 p.m., Bert Gunter wrote: Jeff, et. al. : but ... Note that as.data.frame() *already* changes the matrix object by adding column names of *its own choosing* when the matrix has none. So the issue here is not *whether* col names should be added, but *what*/*how* they should be.

Re: [R] [Tagged] Re: col.names in as.data.frame() ?

2023-10-28 Thread Bert Gunter
Jeff, et. al. : but ... Note that as.data.frame() *already* changes the matrix object by adding column names of *its own choosing* when the matrix has none. So the issue here is not *whether* col names should be added, but *what*/*how* they should be. Unless you wish to extend your criticism to

Re: [R] Plot for 10 years extrapolation

2023-10-28 Thread varin sacha via R-help
Dear Rui, I really thank you a lot for your precious R help. It is exactly what I was trying to do! Once more, many thanks! Best, Sacha Le vendredi 27 octobre 2023 à 09:36:18 UTC+2, Rui Barradas a écrit : Às 19:23 de 26/10/2023, varin sacha via R-help escreveu: > Dear R-Experts, >

Re: [R] [Tagged] Re: col.names in as.data.frame() ?

2023-10-28 Thread Boris Steipe
Ah - that's an excellent point. Thanks. > On Oct 28, 2023, at 14:54, Jeff Newmiller wrote: > > as.data.frame is a _converter_, while data.frame is a _constructor_. > Changing the object contents is not what a conversion is for. > > On October 28, 2023 11:39:22 AM PDT, Boris Steipe >

Re: [R] [Tagged] Re: col.names in as.data.frame() ?

2023-10-28 Thread Jeff Newmiller via R-help
as.data.frame is a _converter_, while data.frame is a _constructor_. Changing the object contents is not what a conversion is for. On October 28, 2023 11:39:22 AM PDT, Boris Steipe wrote: >Thanks Duncan and Avi! > >That you could use NULL in a matrix() dimnames = list(...) argument wasn't

Re: [R] col.names in as.data.frame() ?

2023-10-28 Thread Boris Steipe
Thanks Duncan and Avi! That you could use NULL in a matrix() dimnames = list(...) argument wasn't clear to me. I thought that would be equivalent to a one-element list - and thereby define rownames. So that's good to know. The documentation could be more explicit - but it is probably more work

Re: [R] col.names in as.data.frame() ?

2023-10-28 Thread avi.e.gross
Борис, Try this where you tell matrix the column names you want: nouns <- as.data.frame( matrix(c( "gaggle", "geese", "dule", "doves", "wake", "vultures" ), ncol = 2, byrow = TRUE, dimnames=list(NULL, c("collective", "category" Result: > nouns

Re: [R] weights vs. offset (negative binomial regression)

2023-10-28 Thread Ben Bolker
Using an offset of log(Effort) as in your second model is the more standard way to approach this problem; it corresponds to assuming that catch is strictly proportional to effort. Adding log(Effort) as a covariate (as illustrated below) tests whether a power-law model (catch propto

Re: [R] col.names in as.data.frame() ?

2023-10-28 Thread Duncan Murdoch
Sent a slightly shorter version of this to your email, this one is to the list: On 28/10/2023 1:54 p.m., Boris Steipe wrote: > > I have been trying to create a data frame from some structured text in a single expression. Reprex: > > > > nouns <- as.data.frame( > >matrix(c( > >

[R] col.names in as.data.frame() ?

2023-10-28 Thread Boris Steipe
I have been trying to create a data frame from some structured text in a single expression. Reprex: nouns <- as.data.frame( matrix(c( "gaggle", "geese", "dule", "doves", "wake", "vultures" ), ncol = 2, byrow = TRUE), col.names = c("collective", "category")

Re: [R] How to Reformat a dataframe

2023-10-28 Thread jim holtman
You can also use the pivot_longer to do it: library(tidyverse) input <- structure(list(...1 = c(92.9925354, 76.0024254, 44.99547465, 28.00536465, 120.0068103, 31.9980405, 85.0071837, 40.1532933, 19.3120917, 113.12581575, 28.45843425, 114.400074, 143.925, 46.439634, 20.7845679, 50.82874575,

Re: [R] How to Reformat a dataframe

2023-10-28 Thread avi.e.gross
Paul, I have snipped away your long message and want to suggest another approach or way of thinking to consider. You have received other good suggestions and I likely would have used something like that, probably within the dplyr/tidyverse but consider something simpler. You seem to be viewing

Re: [R] How to Reformat a dataframe

2023-10-28 Thread Rui Barradas
Às 04:13 de 28/10/2023, Paul Bernal escreveu: Dear friends, I have the following dataframe: dim(alajuela_df) [1] 126 12 dput(alajuela_df) structure(list(...1 = c(92.9925354, 76.0024254, 44.99547465, 28.00536465, 120.0068103, 31.9980405, 85.0071837, 40.1532933, 19.3120917, 113.12581575,

Re: [R] How to Reformat a dataframe

2023-10-28 Thread Chris Evans via R-help
The tidyverse idiom looks very different but does what you want and I have come to like it. What idiom of R one likes, for the mostly small datasets I handle, is largely a matter of preferenceds for "readability", itself very personal. Here's my tidyverse way of doing what you wanted: ###

[R] weights vs. offset (negative binomial regression)

2023-10-28 Thread 유준택
Colleagues, I have a dataset that includes five variables. - Catch: the catch number counted in some species (ind.) - Effort: fishing effort (the number of fishing vessels) - xx1, xx2, xx3: some environmental factors As an overdispersion test on the “Catch” variable, I modeled with negative