Re: [R] Fill NA values in columns with values of another column

2024-08-29 Thread Bert Gunter
Dammit. Forgot all about that. Yes, that is the way to do it: with(dat, ave(Value, Group, FUN = \(x)min(x, na.rm = TRUE))) Thanks for resolving my nonsense. -- Bert On Thu, Aug 29, 2024 at 2:58 PM Jeff Newmiller via R-help < r-help@r-project.org> wrote: > Use the ave function. > > On Augu

Re: [R] Fill NA values in columns with values of another column

2024-08-29 Thread Jeff Newmiller via R-help
Use the ave function. On August 29, 2024 2:29:16 PM PDT, Bert Gunter wrote: >Petr et.al: > >I think using merge is a very nice idea! (note that the email omitted the >last rows of the result, though your code of course produced them) > >The only minor problem is that the order of the rows in the

Re: [R] Fill NA values in columns with values of another column

2024-08-29 Thread Bert Gunter
Petr et.al: I think using merge is a very nice idea! (note that the email omitted the last rows of the result, though your code of course produced them) The only minor problem is that the order of the rows in the result is changed from the original. If the OP needs to preserve the original orderi