similar to: Possible Improvement of the R code

Displaying 20 results from an estimated 6000 matches similar to: "Possible Improvement of the R code"

2013 Feb 02
3
vectorisation
Hi I'm trying to set up a simulation problem without resorting to (m)any loops. I want to set entries in a data frame of zeros ('starts' in the code below) to 1 at certain points and the points have been randomly generated and stored in a separate data.frame ('sl'), which has the same number of columns. An example of the procedure is as follows: ml <-
2012 Oct 02
3
Integration in R
Dear R-users, I am facing problem with integrating in R a likelihood function which is a function of four parameters. It's giving me the result at the end but taking more than half an hour to run. I'm wondering is there any other efficient way deal with. The following is my code. I am ready to provide any other description of my function if you need to move forward.
2018 Feb 25
3
include
Thank you Jim, I read the data as you suggested but I could not find K1 in col1. rbind(preval,mydat) Col1 Col2 col3 1 <NA> <NA> <NA> 2 X1 <NA> <NA> 3 Y1 <NA> <NA> 4 K2 <NA> <NA> 5 W1 <NA> <NA> 6 Z1 K1 K2 7 Z2 <NA> <NA> 8 Z3 X1 <NA> 9 Z4 Y1 W1 On Sat, Feb 24, 2018 at 6:18 PM, Jim
2009 Nov 24
1
Titles in plots overlap
Hi,   I use fCopulae package to draw different graphs of univariate and bivariate skew t.  But the plots titles overlap.  I tried using cex.main, font.main to adjust the size but they still overlaps.  Here is my code: par(mfrow = c(3, 1)) mu = 0 Omega = 1 alpha1 = 0 alpha2 = 1.5 alpha3 = 2 alpha4 = 0.5 Z1 = matrix(dmvst(x, 1, mu, Omega, alpha1, df = Inf), length(x)) Z2 = matrix(dmvst(x, 1, mu,
2018 Feb 25
2
include
HI Jim and all, I want to put one more condition. Include col2 and col3 if they are not in col1. Here is the data mydat <- read.table(textConnection("Col1 Col2 col3 K2 X1 NA Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE) The desired out put would be Col1 Col2 col3 1 X1 0 0 2 K1 0 0 3 Y1 0 0 4 W1 0 0 6 K2 X1
2018 Feb 25
0
include
Hi Val, My fault - I assumed that the NA would be first in the result produced by "unique": mydat <- read.table(textConnection("Col1 Col2 col3 Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE) val23<-unique(unlist(mydat[,c("Col2","col3")])) napos<-which(is.na(val23)) preval<-data.frame(Col1=val23[-napos],
2012 Aug 10
1
Solving binary integer optimization problem
Hi, I am new to R for solving optimization problems, I have set of communication channels with limited capacity with two types of costs, fixed and variable cost. Each channel has expected gain for a single communication. I want to determine optimal number of communications for each channel maximizing ROI)return on investment) with overall budget as constraint.60000 is the budget allocated.
2018 Feb 25
2
include
Sorry , I hit the send key accidentally here is my complete message. Thank you Jim and all, I got it. I have one more question on the original question What does this "[-1] " do? preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1], Col2=NA,col3=NA) mydat <- read.table(textConnection("Col1 Col2 col3 Z1 K1 K2 Z2
2018 Feb 25
0
include
Jim has been exceedingly patient (and may well continue to be so), but this smells like "failure to launch". At what point will you start showing your (failed) attempts at solving your own problems so we can help you work on your specific weaknesses and become self-sufficient? -- Sent from my phone. Please excuse my brevity. On February 25, 2018 7:55:55 AM PST, Val <valkremk at
2012 Aug 24
6
updating elements of a vector sequentially - is there a faster way?
I would like to know whether there is a faster way to do the below operation (updating vec1). My objective is to update the elements of a vector (vec1), where a particular element i is dependent on the previous one. I need to do this on vectors that are 1 million or longer and need to repeat that process several hundred times. The for loop works but is slow. If there is a faster way, please let
2014 Jul 09
3
error com un archivo
Hola a todos, Me gustaria pedir vuestra ayuda a encontrar el error que no consigo encontrar en este archivo. He revisado todo mil veces y probado y no doy con ello.Adjunto el archivo con Google drive porque es muy grande. ? monicap_50.csv <https://docs.google.com/file/d/0B8o2KrPEgG7ATlBMc19lTVk1d3M/edit?usp=drive_web> ? Este es el script, y lo que no entiendo que pasa es que tengo 592044
2018 Feb 25
0
include
hi Val, Your problem seems to be that the data are read in as a factor. The simplest way I can think of to get around this is: mydat <- read.table(textConnection("Col1 Col2 col3 Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE) preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1], Col2=NA,col3=NA) rbind(preval,mydat)
2007 Sep 03
1
Graphic representation of model results
Dear list members, I am facing difficulties in making a graphics that could show visually results of a model. I have tested the effects of 4 quantitative variables (Z1, Z2, Z3, Z4) on a variable Y using a weighted mixed effects GLM with weights W (using the glmmPQL function). I applied a blocking approach using factor F2 nested in factor F1 as a grouping structure on a random intercept in
2018 Feb 24
0
include
Thank you Jim and all, I got it. I have one more question on the original question What does this "[-1] " do? preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1], Col2=NA,col3=NA) mydat <- read.table(textConnection("Col1 Col2 col3 Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE)
2018 Feb 24
3
include
On 24/02/2018 1:53 PM, William Dunlap via R-help wrote: > x1 = rbind(unique(preval),mydat) > x2 <- x1[is.na(x1)] <- 0 > x2 # gives 0 > > Why introduce the 'x2'? x1[...] <- 0 alters x1 in place and I think that > altered x1 is what you want. > > You asked why x2 was zero. The value of the expression > f(a) <- b > and assignments
2013 Apr 23
2
Frustration to get help R users group
Dear R users/developers I requested help to solve the problem of formulating Multivariate Sample selection model by using Full Information Maximum Likelihood (FIML)estimation method. I could not get any response. I formulated the following code of FIML to analyse univariate sample selection problem. Would you please advise me where is my problem library (sem) library(nrmlepln) Selection
2012 Nov 27
1
Effect of each term in the accuracy of Nonlinear multivariate regression fitting equation
Dear all, I have a set of data with 4 inputs (independent variables) and one output (dependent variable). I want to perform a regression analysis in order to fit these data to a regression model, however due to the non-linearity of the model I do not have a clue which equation to use. I am thinking of starting with a very general equation including ^3 terms and interactions between the variables
2003 Aug 13
2
putting NAs at the end
I have a matrix for which each row has 12 elements that represent the xyz coordinates of 4 points. So each row of M is (x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4). Some points have NA as z values. I want another matrix to be the same as M but with the coordinates of those points with z=NA placed last. For ezample if z1=NA then the new matrix row should be (x2,y2,z2,x3,y3,z3,x4,y4,z4,x1,y1,z1)
2012 Nov 23
3
daily maximum temperature
Hello, I want to filter the daily maximum temperature. For this i made this skript, but it come out wrong results. Can anybody help me? Thanks for your help! Best regards datos$X <- as.POSIXct(strptime(datos$X, "%d/%m/%Y %H:%M:%S")) z <- aggregate(zoo(datos$Ta), as.POSIXct(datos$X), max) > str(datos) 'data.frame': 17137 obs. of 5 variables: $ X : Factor w/
2009 May 21
2
Naming a random effect in lmer
Dear guRus: I am using lmer for a mixed model that includes a random intercept for a set of effects that have the same distribution, Normal(0, sig2b). This set of effects is of variable size, so I am using an as.formula statement to create the formula for lmer. For example, if the set of random effects has dimension 8, then the lmer call is: Zs<-