Re: [R] Check to see if a value is included within intervals

2019-07-19 Thread Marine Regis
_ De : Bert Gunter Envoy� : samedi 20 juillet 2019 00:46 � : Marine Regis Cc : r-help@r-project.org Objet : Re: [R] Check to see if a value is included within intervals If I understand correctly (make sure that I do!), ?findInterval should essentially do what you want. I

[R] Check to see if a value is included within intervals

2019-07-19 Thread Marine Regis
Hello all, The R code below tests if values of the variable �t� are included or not within intervals that are defined from the data frame dat. The expected results are displayed using the function "rle" (see code below). Here is the code: ta <- 100 tb <- 140 tc <- 40 td <- 85 datF <-

[R] Simplify the loop over the 3rd dimension of a 3D array

2018-07-12 Thread Marine Regis
Hello all, Is there an efficient way to simplify the loop over the 3rd dimension of a 3D array ? I want to keep the loop over the "time". Here is the code: set.seed(12345) ind <- 10 time_seq <- seq(0, 8, 1) col_array <- c(paste("time_", time_seq, sep="")) tab <- array(0,

[R] Calculate focal values for neighboring cells that are located at the raster edge from the function "focal" in the R package "raster"

2018-06-08 Thread Marine Regis
Hello All, I am using the function "focal" in the R package "raster" but I don�t understand how the function calculates values for neighboring cells that are located at the raster edge. Here is an example reproducible: f <- matrix(1, nrow=3, ncol=3) f[c(1,3,7,9)]=1/sqrt(2) f[5]=0 func <-

Re: [R] Latin hypercube sampling from a non-uniform distribution

2017-08-08 Thread Marine Regis
on <s.elli...@lgcgroup.com> Envoyé : mardi 8 août 2017 14:48 À : Marine Regis; r-help@r-project.org Objet : RE: Latin hypercube sampling from a non-uniform distribution > However, my variable is simulated from the cumulative distribution function > of the Poisson distribution. Then I am af

Re: [R] Latin hypercube sampling from a non-uniform distribution

2017-08-07 Thread Marine Regis
_probability") X <- randomLHS(100, length(parm)) colnames(X) <- c("var1", "var2", "mortality_probability") X[, "mortality_probability"] <- qpois(X[, "mortality_probability"], 0.9) hist(X[, "mortality_probability"]) Thanks for yo

[R] Latin hypercube sampling from a non-uniform distribution

2017-08-04 Thread Marine Regis
Hello, I am performing a sensitivity analysis using a Latin Hypercube sampling. However, I have difficulty to draw a Hypercube sample for one variable. I�ve generated this variable from a Poisson distribution as follows: set.seed(5) mortality_probability <- round(ppois(seq(0, 7, by = 1),

Re: [R] How to apply a system of ordinary differential equations to a cell grid?

2017-07-17 Thread Marine Regis
vid Winsemius <dwinsem...@comcast.net> Envoyé : mercredi 21 juin 2017 22:30 À : Marine Regis Cc : r-help@r-project.org Objet : Re: [R] How to apply a system of ordinary differential equations to a cell grid? > On Jun 21, 2017, at 12:48 PM, Marine Regis <marine.re...@hotmail.fr&

[R] Generate simulated data respecting some conditions

2017-07-06 Thread Marine Regis
Hello, Is it possible to generate simulated data that look like the attached figure? The curve in the figure can be obtained from this equation respecting some conditions: if(Temperature > T_min & Temperature < T_max){ a*( Temperature -T_min)*( Temperature -T_max) } else 0 T_min ~

Re: [R] How to apply a system of ordinary differential equations to a cell grid?

2017-06-21 Thread Marine Regis
<dwinsem...@comcast.net> Envoyé : mercredi 21 juin 2017 22:30 À : Marine Regis Cc : r-help@r-project.org Objet : Re: [R] How to apply a system of ordinary differential equations to a cell grid? > On Jun 21, 2017, at 12:48 PM, Marine Regis <marine.re...@hotmail.fr> wrote: > > Hello

[R] How to apply a system of ordinary differential equations to a cell grid?

2017-06-21 Thread Marine Regis
Hello, I am developing an agent-based model to simulate the spread of infectious diseases in heterogeneous landscapes composed of habitat polygons (or clumps of connected cells). To simplify the model, I consider a habitat grid (or raster) containing the polygon ID of each cell. In addition, I

[R] Randomly select one row by group from a matrix

2017-05-18 Thread Marine Regis
Hello, I would like to randomly select one row by group from a matrix. Here is an example where there is one row by group. The code gives an error message: test <- matrix(c(4,4, 6,2, 1,2), nrow = 2, ncol = 3, dimnames = list(NULL, c("xcor", "ycor", "id"))) do.call(rbind, lapply(split(test,

Re: [R] How to change parameter values as a function to time with the package "deSolve"

2017-03-24 Thread Marine Regis
) Thanks in advance for your help! Marine De : David Winsemius <dwinsem...@comcast.net> Envoyé : vendredi 24 mars 2017 06:01 À : Marine Regis Cc : r-help@r-project.org Objet : Re: [R] How to change parameter values as a function to time with the package &

[R] How to change parameter values as a function to time with the package "deSolve"

2017-03-23 Thread Marine Regis
Hello, I am trying to solve an ODE in R using deSolve. With the following code, I expected the parameter �gamma0� takes the values 5 at time step 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10, and 0 otherwise. However, the print(gamma0) shows that �gamma0� stays at 0. Here is my ODE: param <- c(a =

[R] Adding x and y axis labels with the function plot.sensFun (package FME)

2017-01-24 Thread Marine Regis
Hello, How can I add x and y axis labels for a plot that is built from the function plot.sensFun (package FME) ? I tested xlab ="Time" and ylab="Population size" but this doesn't work for me. Here is a code to generate the plot: pars <- list(gmax = 0.5, eff = 0.5, ks = 0.5, rB

Re: [R] GAM with the negative binomial distribution: why do predictions no match with original values?

2016-11-22 Thread Marine Regis
e different between models with offset=argument and offset(). Thanks a lot for your help. Have a nice day Marine ____ De : peter dalgaard <pda...@gmail.com> Envoy� : mardi 22 novembre 2016 23:52 � : Bert Gunter Cc : Marine Regis; r-help@r-project.org Objet : Re: [

[R] GAM with the negative binomial distribution: why do predictions no match with original values?

2016-11-22 Thread Marine Regis
Hello, >From capture data, I would like to assess the effect of longitudinal changes >in proportion of forests on abundance of skunks. To test this, I built this >GAM where the dependent variable is the number of unique skunks and the >independent variables are the X coordinates of the

[R] GAMs: test of simple effects following a significant interaction

2016-11-16 Thread Marine Regis
Hello, I am a novice in Generalized Additive Models (GAMs) and I would need some advice on these models. From capture data, I would like to assess the effect of longitudinal changes in proportion of forests on abundance of skunks. To test this, I built this GAM where the dependent variable is

[R] Scale and shape parameters of Gamma mixture distributions

2016-08-25 Thread Marine Regis
Hello, I used the function "mix" (package "mixdist'') to fit Gamma mixture distributions. The function gives mu and sigma parameters (output below). How can I find the scale and shape parameters of the Gamma distributions ? Parameters: pimu sigma 1 0.2089 185.7 285.4 2 0.7911 530.1

[R] Graphical output of density for the function gammamixEM (package mixtools)

2016-08-05 Thread Marine Regis
Hello, I'm using the function gammamixEM from the package mixtools. How can I return the graphical output of density as in the function normalmixEM (i.e., the second plot in plot(x, density=TRUE)) ? Thank you very much for your time. Have a nice day. Marine [[alternative HTML

[R] Replace any values in a data frame based on another data frame

2016-07-30 Thread Marine Regis
Hello, I have two data frames with different sizes but with the same number of columns. > df1 <- data.frame(col1 = c(1:6), col2 = c(rep("a", 3), rep("b", 3)), col3 = > c(rep("AA", 2), rep("BB", 2), rep("CC", 2)), col4=c(1,8,6,9,7,6)) > df1 col1 col2 col3 col4 11a AA1 22

[R] data.table: “group counter” with NAs

2016-06-29 Thread Marine Regis
Hello, I would like to add a counter column in a data frame based on a set of identical rows. To do this, I tested: DF = data.table(x=c("a","a","a","b","c","d","e","f","f"), y=c(1,3,2,8,8,4,NA,NA,NA)) DF[ , Index := .GRP, by = c("y") ] DF However, the rows with NAs are considered to be

[R] Extract character strings from a vector

2016-06-21 Thread Marine Regis
Hello, I have a vector x of character strings: x <- c("LM0122","RTG", "GF TYHH", "HJN 89963", "KFTR1","RT 8") >From this vector, how can I extract the following character strings (i.e., >which contain 0 or 1 numeric value) [1] "RTG" "GF TYHH" "KFTR1" "RT 8" Thank you

[R] Snowfall - Error in checkForRemoteErrors(val) with sfClusterApplyLB()

2016-04-28 Thread Marine Regis
Hello, I'm trying to run a code that uses the snowfall package. Here is the structure of my code. sfInit(parallel=T, cpus = 5, slaveOutfile="ErrorMessage.txt") sfExportAll() sfLibrary(rgdal) sfLibrary(raster) sfLibrary(sp) sfLibrary(rgeos) sfLibrary(snowfall) system.time(

Re: [R] Compute the Gini coefficient

2016-03-31 Thread Marine Regis
ice day. Marine De : Achim Zeileis <achim.zeil...@uibk.ac.at> Envoyé : mercredi 30 mars 2016 12:05 À : Erich Neuwirth Cc : Marine Regis; r-help@r-project.org Objet : Re: [R] Compute the Gini coefficient On Wed, 30 Mar 2016, Erich Neuwirth wrote: >

[R] Compute the Gini coefficient

2016-03-29 Thread Marine Regis
Hello, I would like to build a Lorenz curve and calculate a Gini coefficient in order to find how much parasites does the top 20% most infected hosts support. Here is my data set: Number of parasites per host: parasites = c(0,1,2,3,4,5,6,7,8,9,10) Number of hosts associated with each number

[R] Warning message with "projectRaster" (package "raster"): 'from' has no cell values

2016-03-12 Thread Marine Regis
Hello, I have two rasters with different resolution and projection. > r1 class : RasterLayer dimensions : 2510, 5233, 13134830 (nrow, ncol, ncell) resolution : 56, 56 (x, y) extent : 503198, 796246, 4917498, 5058058 (xmin, xmax, ymin, ymax) coord. ref. : +proj=utm

[R] Split a character string with two separators

2016-02-18 Thread Marine Regis
Hello, >From this character string: test <-"k0298_7832_8964" how can I obtain: [[1]] "0298" Thank you very much for your help. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

[R] Mixed models with overdispersion

2013-10-11 Thread Marine Regis
Hello everybody, I have count data and with these data, I would like to build a mixed model by using the function glmer(). In a first time, I calculated the c-hat of a simple model with glm() to verify overdispersion and I found a c-hat = 18. I also verified overdispersion in the mixed model

[R] predict() from conditional logit model?

2013-09-12 Thread Marine Regis
Hello everybody, I used the function clogit() (package survival) to build a conditional logit model. This is the R output of my model : coef exp(coef) se(coef) robust se z Pr(|z|) anthro 2.14776 8.56565 0.09352 0.53989 3.978 6.94e-05 *** cor 0.92365 2.51846 0.07757 0.41944 2.202

[R] FW: predict() from conditional logit model?

2013-09-12 Thread Marine Regis
: dwinsem...@comcast.net To: marine.re...@hotmail.fr Subject: Re: [R] predict() from conditional logit model? Date: Thu, 12 Sep 2013 17:52:33 -0500 On Sep 12, 2013, at 3:31 PM, Marine Regis wrote: Hello everybody, I used the function clogit() (package survival) to build