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

2023-11-04 Thread avi.e.gross
There are many techniques Callum and yours is an interesting twist I had not considered. Yes, you can specify what integer a factor uses to represent things but not what I meant. Of course your trick does not work for some other forms of data like real numbers in double format. There is a

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

2023-11-04 Thread CALUM POLWART
I might have factored the gender. I'm not sure it would in any way be quicker. But might be to some extent easier to develop variations of. And is sort of what factors should be doing... # make dummy data gender <- c("Male", "Female", "Male", "Female") WC <- c(70,60,75,65) TG <- c(0.9, 1.1,

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

2023-11-04 Thread roslinazairimah zakaria
Hi all, Thank you very much. I learn a lot from your suggested solution. On Sun, Nov 5, 2023 at 12:56 AM Rui Barradas wrote: > Às 01:49 de 03/11/2023, roslinazairimah zakaria escreveu: > > Hi all, > > > > This is the data: > > > >> dput(head(dt1,20))structure(list(StationName = c("PALO ALTO

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

2023-11-04 Thread Md. Kamruzzaman
Thanks Everyone, My variables are in a dataframe with multiple other variables. Thanks - *Md Kamruzzaman* On Sat, Nov 4, 2023 at 1:13 AM Bert Gunter wrote: > Well, something like: > > LAP <- ifelse(gender =='male', (WC-65)*TG, (WC-58)*TG) > > The exact code depends

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

2023-11-04 Thread avi.e.gross
There may be a point to consider about the field containing dates in the request below. Yes, much code will "work" just fine if the column are is seen as text as you can group by that too. The results will perhaps not be in the order by row that you expected but you can do your re-sorting

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

2023-11-04 Thread Rui Barradas
Às 01:49 de 03/11/2023, roslinazairimah zakaria escreveu: 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",

Re: [R] Adding columns to a tibble based on a value in a different tibble

2023-11-04 Thread avi.e.gross
Yes, Bert. At first glance I thought it was one of the merge/joins and then wondered at the wording that made it sound like the ids may not be one per column. IFF the need is the simpler case, it is a straightforward enough and common need. An example might make it clear enough so actual code

Re: [R] Adding columns to a tibble based on a value in a different tibble

2023-11-04 Thread Bert Gunter
I think a simple reproducible example ("reprex") may be necessary for you to get a useful reply. Questions with vague specifications such as yours often result in going round and round with attempts to clarify what you mean without a satisfactory answer. Clarification at the outset with a reprex

[R] Adding columns to a tibble based on a value in a different tibble

2023-11-04 Thread Alessandro Puglisi
Hi everyone, I have a tibble with various ids and associated information. I need to add a new column to this tibble that retrieves a specific 'y' value from a different tibble that has some of the mentioned ids in the first column and a 'y' value in the second one. If the id, and so the 'y'