similar to: alternative for multiple if_else statements

Displaying 20 results from an estimated 300 matches similar to: "alternative for multiple if_else statements"

2018 Feb 22
0
alternative for multiple if_else statements
Hi Kevin, I ran the code on the full data set and was able to reproduce the problem that you are facing. My guess is that you have an error in your intuition and/or logic, and that this relates to the use of the subscript [1]. Specifically, on the full dataset, the condition trialData$date[trialData$survey_start == "Y" & trialData$year == 2013 & trialData$site ==
2018 Feb 22
0
alternative for multiple if_else statements
I don't fully understand the logic you are trying to implement, but something along the lines of foo <- cut(trialData$date, breaks = as.Date(c("2007-01-01", "2008-05-01", "2009-04-01", "2010-05-01",
2018 Feb 26
0
alternative for multiple if_else statements
That many ifelse statements is obviously rather a pain. Would you not have got what you want with ... paste("survey", year, sep="_") ? If that is not what you're looking for (eg because 'year' is the observation year and not the study start year), perhaps something that picks the minimum year for a subject or other relevant group might work? For example
2011 Mar 14
3
increase a value by each group?
Hi everybody. I'm looking for the way to increase the depth value in 0.01 for each index group. Easier to explain with this example: >my_data=read.table("clipboard", header=TRUE) Depth s_name index 3852 Site_1 144 3852 Site_1 144 3852 Site_1 144 3852 site_A 145 3852 site_A 145 3852 site_A 145 3852 site_A 145 3852 site_B 147 3852 site_B 147 3852 site_B 147 3852 site_B 147 54962
2018 May 16
1
Systemfit Question
I can't get my simultaneous equations to work using system fit. Please help. #Reproducible script Empdata<- read.csv("/Users/ngwinuiazenui/Documents/UPLOADemp.csv") View(Empdata) str(Empdata) Empdata$gnipc<-as.numeric(Empdata$gnipc) install.packages("systemfit") library("systemfit") pdata <- plm.data(Empdata,
2018 May 16
0
Systemfit
Sadly you failed to set your email program to send plain text and the data is corrupted at my end. I also think you need to reduce the size of the data set... the intent here is to increase your understanding, not debug your particular analysis. I will say that I am having a very challenging time understanding what you are trying to accomplish though. What are the equations that you think need
2018 May 15
2
Systemfit
OK, Let's try this again! Here is the reproducible script; it is long because I had to copy the panel dataset here. My question is related to systemfit; I don't know how to get the result for the entire panel. #Reproducible script Empdata<- read.csv("/Users/ngwinuiazenui/Documents/UPLOADemp.csv") View(Empdata) install.packages("systemfit")
2018 May 01
2
how can I convert a long to wide matrix?
Hi Jim, Thank you very much for your suggestions. I used it but it gave me three sites. But actually I do have only two sites "Id_X" and "Id_y" . In fact "A" is repeated two times for "Id_X". If it is repeated, I would like to take the first one among many repeated values. dat<-structure(list(ID = structure(c(1L, 1L, 1L, 2L, 2L), .Label =
2018 May 01
0
how can I convert a long to wide matrix?
Hi Marna, I think this is due to having three rows for id_X and only two for id_Y. The function creates a data frame with enough columns to hold the greatest number of values for each ID variable. Notice that the SITE_n columns contain three values for id_X (A, A, B) and two for id_Y (A, B, NA) as there was no third occasion of measurement for the latter. Even though there are only two _values_
2018 May 01
2
how can I convert a long to wide matrix?
Hi Jim, The data set is correct. I took two readings from the "SITE A" within a short time interval, therefore I want to take the first value if there are repeated within a same group of "timeGroup". Therefore I wanted following FinalData1 B1 B2 id_X "A" "B" id_Y "A" "B" thanks, On Tue, May 1, 2018 at 4:05 PM, Jim
2017 Oct 14
2
Populate one data frame with values from another dataframe for rows that match
Dear @Rui Barradas, thank you for the solution. It works perfectly. On 13/10/2017, 23:35, "Rui Barradas" <ruipbarradas at sapo.pt> wrote: Hello, Try the following. myDF1$studyno <- as.character(myDF1$studyno) myDF2$studyno <- as.character(myDF2$studyno) i1 <- which(names(myDF1) == "pf_mcl") merge(myDF1[-i1], myDF2,
2017 Oct 13
4
Populate one data frame with values from another dataframe for rows that match
I'm trying to populate the column ?pf_mcl? in myDF1 with values from myDF2, where rows match based on column "studyno" but the solutions I have found so far don't seem to be giving me the desired output. Below is a snapshot of the data.frames. myDF1 <- structure(list(studyno = c("J1000/9", "J1000/9", "J1000/9", "J1000/9",
2017 Oct 14
0
Populate one data frame with values from another dataframe for rows that match
Hi Kevin, I think there are issues with Rui's proposed solution. For example, if there are rows in myDF1 which have a studyno which does not match any row in myDF2, then you will lose those rows. In your original request you said that you wanted to keep those rows. To demonstrate my point I need to modify your sample data. Specifically, I changed some studyno settings in myDF1, and also the
2017 Oct 14
2
Populate one data frame with values from another dataframe for rows that match
Dear @Bert Gunter<mailto:bgunter.4567 at gmail.com>, I tried merge and I faced many challenges. @Rui Barradas<mailto:ruipbarradas at sapo.pt> solution is working. From: Bert Gunter <bgunter.4567 at gmail.com> Date: Friday, 13 October 2017 at 22:44 To: Kevin Wamae <KWamae at kemri-wellcome.org> Cc: R-help <R-help at r-project.org> Subject: Re: [R] Populate one data
2017 Oct 13
0
Populate one data frame with values from another dataframe for rows that match
Hello, Try the following. myDF1$studyno <- as.character(myDF1$studyno) myDF2$studyno <- as.character(myDF2$studyno) i1 <- which(names(myDF1) == "pf_mcl") merge(myDF1[-i1], myDF2, by = "studyno") Hope this helps, Rui Barradas Em 13-10-2017 20:09, Kevin Wamae escreveu: > I'm trying to populate the column ?pf_mcl? in myDF1 with values from myDF2, where rows
2017 Oct 15
1
Populate one data frame with values from another dataframe for rows that match
Dear @William<mailto:wdunlap at tibco.com>, thanks for the feedback. I have tested it on the larger dataset and noticed that it created two variables, pf_raw and pf_curated. The output we were looking for, was one that takes the variable pf_mcl in curated dataset and replaces pf_mcl in matching rows within the raw dataset. @Eric<mailto:ericjberger at gmail.com>?s solution was able to
2017 Oct 14
0
Populate one data frame with values from another dataframe for rows that match
Your example used one distinct studyno in DF1 and one distinct pf_mcl in DF2. I think that makes it hard to see what is going on, but maybe I completely misunderstand the problem. In any case, let's redefine myDF1 and myDF2. Note that myDF1 contains a studyno not in myDF2 and vice versa. myDF1 <- structure(list(studyno = c("J1000/9", "J895/7", "J931/6",
2018 May 01
0
how can I convert a long to wide matrix?
Hi Marna, This is a condition that the function cannot handle. It would be possible to reformat the result based on the time intervals, but the stretch_df function doesn't try to interpret the values, just stretches them out to a wide format. Jim On Wed, May 2, 2018 at 9:16 AM, Marna Wagley <marna.wagley at gmail.com> wrote: > Hi Jim, > The data set is correct. I took two
2016 Aug 12
2
ifelse() woes ... can we agree on a ifelse2() ?
Excuse for the delay; I had waited for other / additional comments and reactions (and been distracted with other urgent issues), but do want to keep this thread alive [inline] .. >>>>> Duncan Murdoch <murdoch.duncan at gmail.com> >>>>> on Sat, 6 Aug 2016 11:30:08 -0400 writes: > On 06/08/2016 10:18 AM, Martin Maechler wrote: >> Dear
2016 Aug 15
2
ifelse() woes ... can we agree on a ifelse2() ?
On Fri, Aug 12, 2016 at 11:31 AM, Hadley Wickham <h.wickham at gmail.com> wrote: >> >> One possibility would also be to consider a "numbers-only" or >> >> rather "same type"-only {e.g., would also work for characters} >> >> version. >> >> > I don't know what you mean by these. >> >> In the