Re: [R] I need to create new variables based on two numeric variables and one dichotomize conditional category variables.

2023-11-03 Thread Bert Gunter
Well, something like: LAP <- ifelse(gender =='male', (WC-65)*TG, (WC-58)*TG) The exact code depends on whether your variables are in a data frame or list or whatever, which you failed to specify. If so, ?with may be useful. Cheers, Bert On Fri, Nov 3, 2023 at 3:43 AM Md. Kamruzzaman wrote:

Re: [R] Bug in print for data frames?

2023-11-03 Thread peter dalgaard
It's still kind of weird; embedded 2-column data frames print differently than 1-column ones: > d <- data.frame(a=1, b=I(data.frame(d=1,e=2))) > d a b.d b.e 1 1 1 2 > str(d) 'data.frame': 1 obs. of 2 variables: $ a: num 1 $ b:Classes 'AsIs' and 'data.frame': 1 obs. of 2 variables:

[R] I need to create new variables based on two numeric variables and one dichotomize conditional category variables.

2023-11-03 Thread Md. Kamruzzaman
Hello Everyone, I have three variables: Waist circumference (WC), serum triglyceride (TG) level and gender. Waist circumference and serum triglyceride is numeric and gender (male and female) is categorical. From these three variables, I want to calculate the "Lipid Accumulation Product (LAP)

Re: [R] Sum data according to date in sequence

2023-11-03 Thread roslinazairimah zakaria
Hi, I tried this: # extract date from the time stamp dt1 <- cbind(as.Date(dt$EndDate, format="%m/%d/%Y"), dt$EnergykWh) head(dt1) colnames(dt1) <- c("date", "EnergykWh") and my dt1 becomes these, the dates are replace by numbers. dt1 <- cbind(as.Date(dt$EndDate, format="%m/%d/%Y"), dt$EnergykWh)

Re: [R] Sum data according to date in sequence

2023-11-02 Thread roslinazairimah zakaria
Thank you very much for your help. It is very much appreciated. On Fri, Nov 3, 2023 at 7:23 AM roslinazairimah zakaria wrote: > Dear all, > > I have this set of data. I would like to sum the EnergykWh according date > sequences. > > > head(dt1,20) StationName date time

Re: [R] Sum data according to date in sequence

2023-11-02 Thread roslinazairimah zakaria
Hi all, This is the data: > dput(head(dt1,20))structure(list(StationName = c("PALO ALTO CA / CAMBRIDGE > #1", "PALO ALTO CA / CAMBRIDGE #1", "PALO ALTO CA / CAMBRIDGE #1", "PALO ALTO CA / CAMBRIDGE #1", "PALO ALTO CA / CAMBRIDGE #1", "PALO ALTO CA / CAMBRIDGE #1", "PALO ALTO CA / CAMBRIDGE #1",

Re: [R] Sum data according to date in sequence

2023-11-02 Thread jim holtman
How about send a 'dput' of some sample data. My guess is that your date is 'character' and not 'Date'. Thanks Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it.* On Thu, Nov 2, 2023 at 4:24 PM

Re: [R] Sum data according to date in sequence

2023-11-02 Thread Christopher W. Ryan via R-help
date appears to be a character variable, and R is treating it as such. str(dt1) might give you some insight. Or the dplyr equivalent glimpse(dt1) I think R did what you asked, but if you want to be able to order records by date, in temporal order, you need to tell R that it is a date:

[R] Sum data according to date in sequence

2023-11-02 Thread roslinazairimah zakaria
Dear all, I have this set of data. I would like to sum the EnergykWh according date sequences. > head(dt1,20) StationName date time EnergykWh 1 PALO ALTO CA / CAMBRIDGE #1 1/14/2016 12:09 4.680496 2 PALO ALTO CA / CAMBRIDGE #1 1/14/2016 19:50 6.272414 3 PALO ALTO CA

Re: [R] Bug in print for data frames?

2023-11-02 Thread Ivan Krylov
В Wed, 25 Oct 2023 09:18:26 +0300 "Christian Asseburg" пишет: > > str(x) > 'data.frame': 1 obs. of 3 variables: > $ A: num 1 > $ B: num 1 > $ C:'data.frame': 1 obs. of 1 variable: > ..$ A: num 1 > > Why does the print(x) not show "C" as the name of the third element?

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

2023-11-02 Thread peter dalgaard
I think it is more clear-cut than so, at least if the Poisson situation is something to go by. There, you can do either of these and get equivalent results > fit.lung <- glm(cases ~ age + city, offset=log(pop), + family=poisson, data=lungcancer) > fit.lung2 <- glm(cases/pop ~

Re: [R] How can I remove my packages from rdrr.io?

2023-11-01 Thread David Winsemius
> On Nov 1, 2023, at 6:06 AM, Kim Emilia wrote: > > Hello all, > > I would like to take down my packages posted/created on the website rdrr.io. > [https://rdrr.io/] Is there any way to take down packages from the website? > It would be appreciated if you suggested/offered a way to remove the

Re: [R] How can I remove my packages from rdrr.io?

2023-11-01 Thread Ben Bolker
There is a github site with an issues list: https://github.com/rdrr-io/rdrr-issues/issues It looks like people have successfully requested removal in the past, e.g. https://github.com/rdrr-io/rdrr-issues/issues/113 On 2023-11-01 9:06 a.m., Kim Emilia wrote: Hello all, I would like to

Re: [R] How can I remove my packages from rdrr.io?

2023-11-01 Thread Ivan Krylov
В Wed, 1 Nov 2023 22:06:27 +0900 Kim Emilia пишет: > I would like to take down my packages posted/created on the website > rdrr.io. I think it's unlikely to find people affiliated with rdrr.io here on the R-help mailing list. Have you tried contacting the website author via the links at the

[R] How can I remove my packages from rdrr.io?

2023-11-01 Thread Kim Emilia
Hello all, I would like to take down my packages posted/created on the website rdrr.io. [https://rdrr.io/] Is there any way to take down packages from the website? It would be appreciated if you suggested/offered a way to remove the package from the website. Thank you. [[alternative

Re: [R] running crossvalidation many times MSE for Lasso regression

2023-11-01 Thread David Winsemius
> On Oct 22, 2023, at 4:01 PM, Bert Gunter wrote: > > No error message shown Please include the error message so that it is > not necessary to rerun your code. This might enable someone to see the > problem without running the code (e.g. downloading packages, etc.) > > -- Bert > > On Sun,

Re: [R] Missing shapes in legend with scale_shape_manual

2023-10-31 Thread Rui Barradas
Às 20:55 de 30/10/2023, Kevin Zembower via R-help escreveu: Hello, I'm trying to plot a graph of blood glucose versus date. I also record conditions, such as missing the previous night's medications, and missing exercise on the previous day. My data looks like: b2[68:74,] # A tibble: 7 × 5

Re: [R] Missing shapes in legend with scale_shape_manual

2023-10-31 Thread Kevin Zembower via R-help
Tim, thanks, it helps very much. It works like a charm. Wow, there's so much I don't understand about ggplot2 functions, especially the aes() function. I just discovered the ggplot2-book.org site, and I hope to read it slowly and carefully over the next couple of weeks. Thanks again, Tim, for

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

2023-10-31 Thread Ben Bolker
[Please keep r-help in the cc: list] I don't quite know how to interpret the difference between specifying effort as an offset vs. as weights; I would have to spend more time thinking about it/working through it than I have available at the moment. I don't know that specifying effort

Re: [R] Virus alert because of an R-help e-mail

2023-10-31 Thread Bert Gunter
No attachments. Most are deleted by ETH mailman ... because they might contain viruses. -- Bert On Tue, Oct 31, 2023 at 8:59 AM David Croll wrote: > I just received a virus warning from my e-mail provider, GMX. See the > attached image below. > > The virus detection can be spurious - but the

[R] Virus alert because of an R-help e-mail

2023-10-31 Thread David Croll
I just received a virus warning from my e-mail provider, GMX. See the attached image below. The virus detection can be spurious - but the e-mail was automatically deleted by GMX. With the best regards, David __ R-help@r-project.org mailing list --

Re: [R] Missing shapes in legend with scale_shape_manual

2023-10-31 Thread Howard, Tim G (DEC) via R-help
I believe the missing shapes are because you had set alpha=0 for the last geom point. I expect there are better ways, but one way to handle it would be to avoid the filtering, adding columns with med and exercise status, like the following: # setup with data provided Date <- c('2023-10-17',

[R] [Rd] R 4.3.2 is released

2023-10-31 Thread Peter Dalgaard via R-help
The build system rolled up R-4.3.2.tar.gz (codename "Eye Holes") this morning. This is a minor update, with a few bug fixes. The list below details the changes in this release. You can get the source code from https://cran.r-project.org/src/base/R-4/R-4.3.2.tar.gz or wait for it to be

[R] [R-pkgs] Introducing the makeit package

2023-10-31 Thread Arni Magnusson
Dear R community, Just a quick note about a new package on CRAN called makeit. Yesterday, I added a vignette and released as 1.0.1: https://cran.r-project.org/package=makeit https://cran.r-project.org/web/packages/makeit/vignettes/makeit.html It provides a simple but powerful function make()

[R] Missing shapes in legend with scale_shape_manual

2023-10-30 Thread Kevin Zembower via R-help
Hello, I'm trying to plot a graph of blood glucose versus date. I also record conditions, such as missing the previous night's medications, and missing exercise on the previous day. My data looks like: > b2[68:74,] # A tibble: 7 × 5 Date Time bg missed_meds no_exercise

Re: [R] Dynamically create a (convenience) function in a package

2023-10-30 Thread Martin Maechler
> Iris Simmons > on Mon, 30 Oct 2023 06:37:04 -0400 writes: > If you don't know the name of the attributes in advance, > how can you know the function name to be able to call it? > This seems like a very flawed approach. > Also, I would discourage the use of

Re: [R] The argument 'eps.Pvalue' of `printCoefmat()`

2023-10-30 Thread Martin Maechler
> Duncan Murdoch > on Sun, 29 Oct 2023 04:45:19 -0400 writes: > On 29/10/2023 3:48 a.m., Shu Fai Cheung wrote: >> Hi all, >> >> Just a minor issue that I am not sure whether this is >> considered a "bug." It is about the help page. >> >> In the help page

Re: [R] Dynamically create a (convenience) function in a package

2023-10-30 Thread Iris Simmons
If you don't know the name of the attributes in advance, how can you know the function name to be able to call it? This seems like a very flawed approach. Also, I would discourage the use of eval(parse(text = )), it's almost always not the right way to do what you want to do. In your case,

[R] Dynamically create a (convenience) function in a package

2023-10-30 Thread Sigbert Klinke
Hi, n a package, I have a data object with attributes, and I want to dynamically create a convenience function to access those attributes. This way, instead of using attr(x, "number"), I would like to use number(x). Because I don't know in advance which attributes the data object may

Re: [R] The argument 'eps.Pvalue' of `printCoefmat()`

2023-10-29 Thread Duncan Murdoch
On 29/10/2023 3:48 a.m., Shu Fai Cheung wrote: Hi all, Just a minor issue that I am not sure whether this is considered a "bug." It is about the help page. In the help page of printCoefmat(), for the argument 'eps.Pvalue', the description is as below: number, .. I have to read the source to

[R] The argument 'eps.Pvalue' of `printCoefmat()`

2023-10-29 Thread Shu Fai Cheung
Hi all, Just a minor issue that I am not sure whether this is considered a "bug." It is about the help page. In the help page of printCoefmat(), for the argument 'eps.Pvalue', the description is as below: number, .. I have to read the source to figure out that this argument is to be used by

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

Re: [R] How to Reformat a dataframe

2023-10-27 Thread Paul Bernal
Hi Iris, Thank you so much for your valuable feedback. I wonder why your code gives you 1512 rows, given that the original structure has 12 columns and 126 rows, so I would expect (125*12)+ 9=1,509 total rows. Cheers, Paul El El vie, 27 de oct. de 2023 a la(s) 10:40 p. m., Iris Simmons <

Re: [R] How to Reformat a dataframe

2023-10-27 Thread Iris Simmons
You are not getting the structure you want because the indexes are wrong. They should be something more like this: i <- 0 for (row in 1:nrow(alajuela_df)){ for (col in 1:ncol(alajuela_df)){ i <- i + 1 df[i,1]=alajuela_df[row,col] } } but I think what you are doing can be written much

[R] How to Reformat a dataframe

2023-10-27 Thread Paul Bernal
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, 28.45843425, 114.400074, 143.925, 46.439634,

Re: [R] Inquiry about bandwidth rescaling in Ksmooth

2023-10-27 Thread Jan Failenschmid via R-help
Dear Bert, Thank you very much for your quick reply. I have tested this, and it indeed appears to be the source of the discrepancy I observed. My apologies for overlooking this in the documentation and thank you for clarifying. Cheers, Jan From: Bert Gunter

Re: [R] Plot for 10 years extrapolation

2023-10-27 Thread Rui Barradas
Às 19:23 de 26/10/2023, varin sacha via R-help escreveu: Dear R-Experts, Here below my R code working but I don't know how to complete/finish my R code to get the final plot with the extrapolation for the10 more years. Indeed, I try to extrapolate my data with a linear fit over the next 10

Re: [R] Plot for 10 years extrapolation

2023-10-26 Thread Bert Gunter
Incidentally, if all you wanted to do was plot fitted values, the predict method is kinda overkill, as it's just the fitted line from the model. But I assume you wanted to plot CI's/PI's also, as the example illustrated. -- Bert On Thu, Oct 26, 2023 at 1:56 PM Bert Gunter wrote: > > from

Re: [R] Plot for 10 years extrapolation

2023-10-26 Thread Bert Gunter
from ?predict.lm: "predict.lm produces a vector of predictions or a matrix of predictions and bounds with column names fit, lwr, and upr if interval is set. " ergo: predict(model, dfuture, interval = "prediction")[,"fit"] ## or [,1] as it's the first column in the returned matrix is your

Re: [R] Need help to resolve the Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Execution halted

2023-10-26 Thread Ben Bolker
Hmm, I can't replicate (i.e., it works fine for me). What are the results of your sessionInfo() (from a *clean* R session)? == R Under development (unstable) (2023-10-25 r85410) Platform: x86_64-pc-linux-gnu Running under: Pop!_OS 22.04 LTS Matrix products: default BLAS:

[R] Need help to resolve the Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Execution halted

2023-10-26 Thread siddharth sahasrabudhe via R-help
Hello Colleagues, I am trying to get the Git repository using *remotes* package. I am using *remotes::install_github("dcl-docs/dcldata") *to get the Git repo. However, I am getting the following error message. I have absolutely no idea on what this error message means and how to get away with

[R] Plot for 10 years extrapolation

2023-10-26 Thread varin sacha via R-help
Dear R-Experts, Here below my R code working but I don't know how to complete/finish my R code to get the final plot with the extrapolation for the10 more years. Indeed, I try to extrapolate my data with a linear fit over the next 10 years. So I create a date sequence for the next 10 years and

Re: [R] Inquiry about bandwidth rescaling in Ksmooth

2023-10-26 Thread Bert Gunter
Apologies in advance if my comments don't help, in which case, no need to respond, but I noted in ?ksmooth: "bandwidth the bandwidth. The kernels are scaled so that their quartiles (viewed as probability densities) are at ± 0.25*bandwidth." So, could this be a source of the discrepancies you

Re: [R] Bug in print for data frames?

2023-10-26 Thread Christian Asseburg
Dear R users! Thank you for your excellent replies. I didn't know that the print.data.frame expands matrix-like values in this way. Why doesn't it call the column in my example C.A? I understand that something like that happens when the data.frame in position three has multiple columns. But

[R] Inquiry about bandwidth rescaling in Ksmooth

2023-10-26 Thread Jan Failenschmid via R-help
Dear Sir, Madam, or to whom this may concern, my name is Jan Failenschmid and I am a Ph.D. student at Tilburg University. For my project I have been looking into different types of kernel regression estimators and corresponding R functions. While comparing different functions I noticed that

Re: [R] Yext in parentheses.

2023-10-26 Thread Jeff Newmiller via R-help
I recommend cutting snippets out of your code by stopping the code at the point of interest and using dput() to pull out "data as it is" before the troublesome section and then using the reprex package to test that the snippet runs. Either you will notice the problem on your own while taking

Re: [R] Yext in parentheses.

2023-10-26 Thread Sarah Goslee
Hi, It isn't at all clear to me what you're trying to do. For one thing, you never actually add more items to cat.ref in the code snippet you give. You do use c() on zx.ref - is that what you mean? But you aren't adding cat.ref to it, you're adding v$cat.ref, and I have no idea what that might

[R] Yext in parentheses.

2023-10-26 Thread Steven Yen
Dear All My program is long and sorry I do not have a replicable set of codes to present. But I present a chunk of codes at the end below. Essentially, 1. I initialize cat.ref as NUL (see line 1) 2. Then, I repeatedly add elements to cat.ref, where each element include parentheses in double

Re: [R] Bug in print for data frames?

2023-10-26 Thread Rui Barradas
Hello, Inline. Às 13:32 de 26/10/2023, Ebert,Timothy Aaron escreveu: The "problem" goes away if you use x$C <- y[1,] Actually, if I understand correctly, the OP wants the column: x$C <- y[,1] In this case it will produce the same output because y is a df with only one row. But that is

Re: [R] Bug in print for data frames?

2023-10-26 Thread Ebert,Timothy Aaron
The "problem" goes away if you use x$C <- y[1,] If you have another row in your x, say: x <- data.frame(A=c(1,4), B=c(2,5), C=c(3,6)) then your code x$C <- y[1] returns an error. If y has the same number of rows as x$C then R has the same outcome as in your example. It looks like your code

Re: [R] Bug in print for data frames?

2023-10-26 Thread Rui Barradas
Às 07:18 de 25/10/2023, Christian Asseburg escreveu: Hi! I came across this unexpected behaviour in R. First I thought it was a bug in the assignment operator <- but now I think it's maybe a bug in the way data frames are being printed. What do you think? Using R 4.3.1: x <- data.frame(A =

Re: [R] Bug in print for data frames?

2023-10-26 Thread Duncan Murdoch
On 25/10/2023 2:18 a.m., Christian Asseburg wrote: Hi! I came across this unexpected behaviour in R. First I thought it was a bug in the assignment operator <- but now I think it's maybe a bug in the way data frames are being printed. What do you think? Using R 4.3.1: x <- data.frame(A = 1,

Re: [R] Bug in print for data frames?

2023-10-26 Thread Iris Simmons
I would say this is not an error, but I think what you wrote isn't what you intended to do anyway. y[1] is a data.frame which contains only the first column of y, which you assign to x$C, so now x$C is a data.frame. R allows data.frame to be plain vectors as well as matrices and data.frames,

[R] Bug in print for data frames?

2023-10-26 Thread Christian Asseburg
Hi! I came across this unexpected behaviour in R. First I thought it was a bug in the assignment operator <- but now I think it's maybe a bug in the way data frames are being printed. What do you think? Using R 4.3.1: > x <- data.frame(A = 1, B = 2, C = 3) > y <- data.frame(A = 1) > x A B C

Re: [R] Create a call but evaluate only some elements

2023-10-25 Thread Shu Fai Cheung
Dear Bert, Many thanks for your suggestion! I am reading the section to understand more about this topic. It is highly relevant to what I plan to work on. Regards, Shu Fai On Thu, Oct 26, 2023 at 5:38 AM Bert Gunter wrote: > > As you seem to have a need for this sort of capability (e.g.

Re: [R] Create a call but evaluate only some elements

2023-10-25 Thread Bert Gunter
As you seem to have a need for this sort of capability (e.g. bquote), see Section 6: "Computing on the Language" in the R Language Definition manual. Actually, if you are interested in a concise (albeit dense) overview of the R Language, you might consider going through the whole manual. Cheers,

Re: [R] Error running gee function. I neither understand the error message, nor know what needs to be done the get the gee to run

2023-10-25 Thread Duncan Murdoch
Actually a better solution would be to make PID into a factor. They can always be coerced to a number, but will display with your meaningful labels. Duncan Murdoch On 25/10/2023 3:38 p.m., Duncan Murdoch wrote: I don't see it documented, but it appears that the gee() function assumes the id

Re: [R] Error running gee function. I neither understand the error message, nor know what needs to be done the get the gee to run

2023-10-25 Thread Duncan Murdoch
I don't see it documented, but it appears that the gee() function assumes the id variable can be coerced to a number. Your ids are in PID, and are strings like "HIPS004", etc. Change that to "004" or a numeric 4 and the error goes away. Duncan Murdoch On 25/10/2023 3:23 p.m., Sorkin, John

[R] Error running gee function. I neither understand the error message, nor know what needs to be done the get the gee to run

2023-10-25 Thread Sorkin, John
Colleagues, I am receiving several error messages from the gee function. I don't understand the ides the error messages are trying to impart, and I don't know how to debug or correct the error. The error messages follow: > fitgee <- gee(HipFlex ~ >

Re: [R] by function does not separate output from function with mulliple parts

2023-10-25 Thread Rui Barradas
Às 00:22 de 25/10/2023, Sorkin, John escreveu: Colleagues, I have written an R function (see fully annotated code below), with which I want to process a dataframe within levels of the variable StepType. My program works, it processes the data within levels of StepType, but the usual headers

Re: [R] by function does not separate output from function with, mulliple parts

2023-10-25 Thread Leonard Mada via R-help
Dear John, Printing inside the function is problematic. Your function itself does NOT print the labels. Just as a clarification: F = factor(rep(1:2, 2)) by(data.frame(V = 1:4, F = F), F, function(x) { print(x); return(NULL); } ) #   V F # 1 1 1 # 3 3 1 #   V F # 2 2 2 # 4 4 2 # F: 1 <- this

Re: [R] Create a call but evaluate only some elements

2023-10-25 Thread Shu Fai Cheung
Dear Iris, Many many thanks! This is exactly what I need! I have never heard about bquote(). This function will also be useful to me on other occasions. I still have a lot to learn about the R language ... Regards, Shu Fai On Wed, Oct 25, 2023 at 5:24 PM Iris Simmons wrote: > > You can try

Re: [R] Create a call but evaluate only some elements

2023-10-25 Thread Iris Simmons
You can try either of these: expr <- bquote(lm(.(as.formula(mod)), dat)) lm_out5 <- eval(expr) expr <- call("lm", as.formula(mod), as.symbol("dat")) lm_out6 <- eval(expr) but bquote is usually easier and good enough. On Wed, Oct 25, 2023, 05:10 Shu Fai Cheung wrote: > Hi All, > > I have a

Re: [R] Create a call but evaluate only some elements

2023-10-25 Thread Shu Fai Cheung
Sorry for a typo, regarding the first attempt, lm_out2, using do.call(), I meant: 'It does have the formula, "as a formula": y ~ x1 + x2. However, the name "dat" is evaluated. ...' Regards, Shu Fai On Wed, Oct 25, 2023 at 5:09 PM Shu Fai Cheung wrote: > > Hi All, > > I have a problem that may

[R] Create a call but evaluate only some elements

2023-10-25 Thread Shu Fai Cheung
Hi All, I have a problem that may have a simple solution, but I am not familiar with creating calls manually. This is example calling lm() ``` r set.seed(1234) n <- 10 dat <- data.frame(x1 = rnorm(n), x2 = rnorm(n), y = rnorm(n)) lm_out <- lm(y ~ x1 + x2,

[R] by function does not separate output from function with mulliple parts

2023-10-24 Thread Sorkin, John
Colleagues, I have written an R function (see fully annotated code below), with which I want to process a dataframe within levels of the variable StepType. My program works, it processes the data within levels of StepType, but the usual headers that separate the output by levels of StepType

Re: [R] running crossvalidation many times MSE for Lasso regression

2023-10-24 Thread varin sacha via R-help
Dear Rui, I really thank you a lot for your response and your R code. Best, Sacha Le mardi 24 octobre 2023 à 16:37:56 UTC+2, Rui Barradas a écrit : Às 20:12 de 23/10/2023, varin sacha via R-help escreveu: > Dear R-experts, > > I really thank you all a lot for your responses. So, here

Re: [R] How to Calculate the Mean by Multiple Groups in R

2023-10-24 Thread Gabor Grothendieck
A variation is to remove Well and then we can use dot to refer to the remaining columns. aggregate(cbind(OD, ODnorm) ~ . , subset(df, select = - Well), mean) On Tue, Oct 24, 2023 at 8:32 AM Luigi Marongiu wrote: > > Hello, > I have a data frame with different groups (Time, Target, Conc) and

Re: [R] running crossvalidation many times MSE for Lasso regression

2023-10-24 Thread Rui Barradas
Às 20:12 de 23/10/2023, varin sacha via R-help escreveu: Dear R-experts, I really thank you all a lot for your responses. So, here is the error (and warning) messages at the end of my R code. Many thanks for your help. Error in UseMethod("predict") :   no applicable method for 'predict'

Re: [R] How to Calculate the Mean by Multiple Groups in R

2023-10-24 Thread Luigi Marongiu
Thank you On Tue, Oct 24, 2023 at 3:01 PM peter dalgaard wrote: > > Also, > > > aggregate(cbind(OD, ODnorm) ~ Time + Target + Conc, data = df, FUN = "mean") > Time Target Conc ODODnorm > 11 BACT1 765. 108.3 > 21 BACT2 745. 88.3 > 31 BACT

Re: [R] How to Calculate the Mean by Multiple Groups in R

2023-10-24 Thread peter dalgaard
Also, > aggregate(cbind(OD, ODnorm) ~ Time + Target + Conc, data = df, FUN = "mean") Time Target Conc ODODnorm 11 BACT1 765. 108.3 21 BACT2 745. 88.3 31 BACT3 675. 18.0 (You might wish for "cbind(OD,ODnorm) ~ . - Well", but

Re: [R] How to Calculate the Mean by Multiple Groups in R

2023-10-24 Thread Luigi Marongiu
Thank you, the last is exactly what I was looking for. On Tue, Oct 24, 2023 at 2:41 PM Sarah Goslee wrote: > > Hi, > > I think you're misunderstanding which set of variables go on either > side of the formula. > > Is this what you're looking for? > > > aggregate(OD ~ Time + Target + Conc, data =

Re: [R] How to Calculate the Mean by Multiple Groups in R

2023-10-24 Thread Sarah Goslee
Hi, I think you're misunderstanding which set of variables go on either side of the formula. Is this what you're looking for? > aggregate(OD ~ Time + Target + Conc, data = df, FUN = "mean") Time Target Conc OD 11 BACT1 765. 21 BACT2 745. 31 BACT3

[R] How to Calculate the Mean by Multiple Groups in R

2023-10-24 Thread Luigi Marongiu
Hello, I have a data frame with different groups (Time, Target, Conc) and each entry has a triplicate value of the measurements OD and ODnorm. How can I merge the triplicates into a single mean value? I tried the following: ``` df = data.frame(Time=rep(1, 9), Well=paste("A", 1:9, sep=""),

Re: [R] Create new data frame with conditional sums

2023-10-24 Thread peter dalgaard
This seems to work. A couple of fine points, including handling duplicated Pct values right, which is easier if you do the reversed cumsum. > dd2 <- dummydata[order(dummydata$Pct),] > dd2$Cum <- rev(cumsum(rev(dd2$Totpop))) > use <- !duplicated(dd2$Pct) > approx(dd2$Pct[use], dd2$Cum[use], ctof,

Re: [R] running crossvalidation many times MSE for Lasso regression

2023-10-23 Thread Jin Li
Hi Ben, Martin and all, The function, glmnetcv, in the spm2 package was developed for the following main reasons: 1. The training and testing samples were generated using a stratified random sampling method instead of a simple random sampling method. By doing this, we hoped that it may be able to

Re: [R] running crossvalidation many times MSE for Lasso regression

2023-10-23 Thread varin sacha via R-help
Dear R-experts, I really thank you all a lot for your responses. So, here is the error (and warning) messages at the end of my R code. Many thanks for your help. Error in UseMethod("predict") :   no applicable method for 'predict' applied to an object of class "c('matrix', 'array', 'double',

Re: [R] running crossvalidation many times MSE for Lasso regression

2023-10-23 Thread Ben Bolker
For what it's worth it looks like spm2 is specifically for *spatial* predictive modeling; presumably its version of CV is doing something spatially aware. I agree that glmnet is old and reliable. One might want to use a tidymodels wrapper to create pipelines where you can more easily

Re: [R] Technical Help Request for "Version Differences" (i.e., CYTOFKIT package)

2023-10-23 Thread Ivan Krylov
Dear Nader Habibzadeh, В Sat, 21 Oct 2023 15:11:23 +0330 Nader Habibzadeh пишет: > I came across the same issue you have demonstrated in "r-help" but > with the shiny package installation. Do any of the replies to Murat's question, e.g. [1], help? If you have a different problem, let us know

Re: [R] running crossvalidation many times MSE for Lasso regression

2023-10-23 Thread Martin Maechler
> Jin Li > on Mon, 23 Oct 2023 15:42:14 +1100 writes: > If you are interested in other validation methods (e.g., LOO or n-fold) > with more predictive accuracy measures, the function, glmnetcv, in the spm2 > package can be directly used, and some reproducible examples

[R] Technical Help Request for "Version Differences" (i.e., CYTOFKIT package)

2023-10-23 Thread Nader Habibzadeh
Dear Murat, I came across the same issue you have demonstrated in "r-help" but with the shiny package installation. I was wondering if you could send me any information that you have gotten for figuring out this problem. Best regards, Nader -- *Nader Habibzadeh, Ph.D.,* *Department of

Re: [R] running crossvalidation many times MSE for Lasso regression

2023-10-22 Thread Jin Li
If you are interested in other validation methods (e.g., LOO or n-fold) with more predictive accuracy measures, the function, glmnetcv, in the spm2 package can be directly used, and some reproducible examples are also available in ?glmnetcv. On Mon, Oct 23, 2023 at 10:59 AM Duncan Murdoch wrote:

Re: [R] running crossvalidation many times MSE for Lasso regression

2023-10-22 Thread Duncan Murdoch
On 22/10/2023 7:01 p.m., Bert Gunter wrote: No error message shown Please include the error message so that it is not necessary to rerun your code. This might enable someone to see the problem without running the code (e.g. downloading packages, etc.) And it's not necessarily true that someone

Re: [R] running crossvalidation many times MSE for Lasso regression

2023-10-22 Thread Bert Gunter
No error message shown Please include the error message so that it is not necessary to rerun your code. This might enable someone to see the problem without running the code (e.g. downloading packages, etc.) -- Bert On Sun, Oct 22, 2023 at 1:36 PM varin sacha via R-help wrote: > > Dear

[R-es] Como generar raster de tendencia

2023-10-22 Thread Adriana Guzman
Buen día, Por favor alguien, sabe como generar un raster de tendencia ? [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es

<    10   11   12   13   14   15   16   17   18   19   >