Re: [R] help with recursive function

2017-12-14 Thread DIGHE, NILESH [AG/2362]
. Nilesh From: William Dunlap [mailto:wdun...@tibco.com] Sent: Thursday, December 14, 2017 11:26 AM To: DIGHE, NILESH [AG/2362] Cc: Eric Berger ; r-help Subject: Re: [R] help with recursive function Your code contains the lines stopifnot(!(any(data1$norm_sd >= 1)))

Re: [R] help with recursive function

2017-12-14 Thread DIGHE, NILESH [AG/2362]
stopifnot condition is met. When the stopifnot condition is met, I like to get the output from if statement saved. Anyway, I will keep trying. Again, Thanks for your help! Nilesh From: Eric Berger [mailto:ericjber...@gmail.com] Sent: Thursday, December 14, 2017 10:29 AM To: DIGHE, NILESH [AG/2362

Re: [R] help with recursive function

2017-12-14 Thread DIGHE, NILESH [AG/2362]
atment, value) %>% mutate(outlier = NA) stopifnot(!(any(data1$norm_sd >= 1))) if (!(any(data1$norm_sd >= 1))) { df1 <- dat1 return(df1) } else { df2 <- recursive_funlp() return(df2) } } df3 <-

Re: [R] help with recursive function

2017-12-14 Thread DIGHE, NILESH [AG/2362]
gmail.com>> wrote: You seem to have a typo at this expression (and some others like it) Namely, you write any(!dat2$norm_sd) >= 1 when you possibly meant to write !( any(dat2$norm_sd) >= 1 ) i.e. I think your ! seems to be in the wrong place. HTH, Eric On Thu, Dec 14, 2017 at 3:26

[R] help with recursive function

2017-12-14 Thread DIGHE, NILESH [AG/2362]
Hi, I need some help with running a recursive function. I like to run funlp2 recursively. When I try to run recursive function in another function named "calclp" I get this "Error: any(!dat2$norm_sd) >= 1 is not TRUE". I have never built a recursive function before so having trouble executing it

Re: [R] dynamically create columns using a function

2017-07-21 Thread DIGHE, NILESH [AG/2362]
dataset = dat, col = col_mean_gg, col_name = col_name_gg) dat2 } # function demo_fn demo_fn<- function (dat, f, blup_datacut) { for (i in blup_datacut) { dat <- f(dat, i) } dat } # get expected results by applying functions demo_fn(dem, f, c("REG1", &

[R] dynamically create columns using a function

2017-07-20 Thread DIGHE, NILESH [AG/2362]
Hi, I am writing a function to dynamically create column names and fill those columns with some basic calculations. My function "demo_fn" takes argument "blup_datacut" and I like to use the contents of those arguments to dynamically create new columns in my dataset. Please note that I have anot

Re: [R] Why is merge sorting even when sort = F?

2017-03-09 Thread DIGHE, NILESH [AG/2362]
Using the "join" function from the plyr package preserves the data order library(plyr) join(grades2, info, by="grade", type="left", match="all") Nilesh -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Dimitri Liakhovitski Sent: Wednesday, March 08, 2017

Re: [R] Understanding and predict round-off errors sign on simple functions

2016-06-30 Thread DIGHE, NILESH [AG/2362]
Using "runmean" function from caTools package within your SMA function appears to solve the issue. Please see details below. library(caTools) > dput(m) structure(c(-0.626453810742332, 0.183643324222082, -0.835628612410047, 1.59528080213779, 0.329507771815361, -0.820468384118015, 0.487429052428

Re: [R] sample within a loop

2016-03-20 Thread DIGHE, NILESH [AG/2362]
Tanvir & Don: Thanks a lot for your solutions. Both solutions work great. I really appreciate your help. Regards, Nilesh -Original Message- From: Mohammad Tanvir Ahamed [mailto:mashra...@yahoo.com] Sent: Thursday, March 17, 2016 1:24 PM To: DIGHE, NILESH [AG/2362]; r-he

[R] sample within a loop

2016-03-19 Thread DIGHE, NILESH [AG/2362]
Dear R users, My data frame has four "groups" namely A1, B2, C3, & D4. Each group has 12 rows (variable "plotno). I like to randomly sample one "plotno" within each "groups" variable and label it as "CONTROL" and label others as "TEST" in a new variable called "entry". I am tr

Re: [R] store results from loop into a dataframe

2016-01-05 Thread DIGHE, NILESH [AG/2362]
Sarah: Thanks a lot for taking time to guide me to the right direction. I now see how the missing data is causing the problem. Thanks again! Nilesh -Original Message- From: Sarah Goslee [mailto:sarah.gos...@gmail.com] Sent: Tuesday, January 05, 2016 12:13 PM To: DIGHE, NILESH [AG/2362

Re: [R] store results from loop into a dataframe

2016-01-05 Thread DIGHE, NILESH [AG/2362]
handle these errors. Do you recommend any other approach to solve my problem? Thanks for your time. Nilesh -Original Message- From: Sarah Goslee [mailto:sarah.gos...@gmail.com] Sent: Tuesday, January 05, 2016 11:20 AM To: DIGHE, NILESH [AG/2362] Cc: r-help@r-project.org Subject: Re

[R] store results from loop into a dataframe

2016-01-05 Thread DIGHE, NILESH [AG/2362]
Dear R users: I am trying to create a function that will loop over three dependent variables in my aov model, and then get the HSD.test for each variable. I like to store the results from each loop in a data frame. When I run my function (funx) on my data (dat), results from only yield gets

Re: [R] subset data using a vector

2015-11-24 Thread DIGHE, NILESH [AG/2362]
t;V046", "V047", "V048", "V049", "V050", "V051", "V052", "V053", "V054", "V055", "V056", "V057"), class = "factor"), linecode = structure(c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,

Re: [R] subset data using a vector

2015-11-23 Thread DIGHE, NILESH [AG/2362]
lit(as.character(dataset$ranges2use), ",")[[i]]) } m2 } I am not sure where I am making a mistake. Thanks. Nilesh -Original Message- From: Michael Dewey [mailto:li...@dewey.myzen.co.uk] Sent: Monday, November 23, 2015 12:11 PM To: DIGHE, NILESH [AG/2362]; r-help@r-pro

Re: [R] subset data using a vector

2015-11-23 Thread DIGHE, NILESH [AG/2362]
Michael: I like to use the actual range id's listed in column "rangestouse" to subset my data and not the length of that vector. Thanks. Nilesh -Original Message- From: Michael Dewey [mailto:li...@dewey.myzen.co.uk] Sent: Monday, November 23, 2015 10:17 AM To: DIGHE,

[R] subset data using a vector

2015-11-23 Thread DIGHE, NILESH [AG/2362]
Dear R users, I like to split my data by a vector created by using variable "ranges". This vector will have the current range (ranges), preceding range (ranges - 1), and post range (ranges + 1) for a given plotid. If the preceding or post ranges in this vector are outside the l

[R] spatial adjustment using checks

2015-10-22 Thread DIGHE, NILESH [AG/2362]
Hi, I have yield data for several varieties and a randomly placed check (1 in every 8 column or "cols") in a field test arranged in a rows*cols grid format (see image attached). Both "rows" & "cols" are variables in the data set. I like to adjust "yield" variable for each row listed as "variet

Re: [R] help with "by" function

2015-05-12 Thread DIGHE, NILESH [AG/2362]
Jean: Thanks a lot!! The changes you made to the code gave me what I needed. I truly appreciate your time in correcting the code. Nilesh From: Adams, Jean [mailto:jvad...@usgs.gov] Sent: Tuesday, May 12, 2015 2:14 PM To: DIGHE, NILESH [AG/2362] Cc: r-help@r-project.org Subject: Re: [R] help

[R] help with "by" function

2015-05-12 Thread DIGHE, NILESH [AG/2362]
Hi, I have an anonymous function called function(x) that will run anova, run HSD.test on the model, and then sort the results. I am passing this anonymous function to the "by" function to get results by "Isopair" factor which is my index variable. Since I want to run the anova on multiple depe