similar to: How to fix indeces in a loop

Displaying 20 results from an estimated 700 matches similar to: "How to fix indeces in a loop"

2012 May 25
2
Collecting results of a test with array
Dear contributors I have tried this experiment: x<-c() for (i in 1:12){ x[i]<-list(cbind(x1[i],x2[i])) #this is a list of 12 couples of time series I am using to perform a test } # that compares them 2 by 2 # ################# #trace statistic test<-data.frame() cval<-array( , dim=c(2,3,12)) for (i in 2:12){ for (k in 1:2){ for (j in 1:3){ result[k,j,i]<-
2013 Jan 27
2
Loops
Dear Contributors, I am asking help on the way how to solve a problem related to loops for that I always get confused with. I would like to perform the following procedure in a compact way. Consider that p is a matrix composed of 100 rows and three columns. I need to calculate the sum over some rows of each column separately, as follows: fa1<-(colSums(p[1:25,])) fa2<-(colSums(p[26:50,]))
2017 Oct 19
2
Select part of character row name in a data frame
Thanks a lot, so simple so efficient! I will study more the grep command I did not know. Thanks! Francesca Pancotto > Il giorno 19 ott 2017, alle ore 12:12, Enrico Schumann <es at enricoschumann.net> ha scritto: > > df[grep("strat", row.names(df)), ] [[alternative HTML version deleted]]
2017 Oct 19
0
Select part of character row name in a data frame
(Re-)read the discussion of indexing (both `[` and `[[`) and be sure to get clear on the difference between matrices and data frames in the Introduction to R document that comes with R. There are many ways to create numeric vectors, character vectors, and logical vectors that can then be used as indexes, including the straightforward way: df[ c( "Unique to strat ", "Unique
2017 Oct 19
2
Select part of character row name in a data frame
Dear R contributors, I have a problem in selecting in an efficient way, rows of a data frame according to a condition, which is a part of a row name of the table. The data frame is made of 64 rows and 2 columns, but the row names are very long but I need to select them according to a small part of it and perform calculations on the subsets. This is the example: X Y "Unique to
2011 Jul 27
3
Reorganize(stack data) a dataframe inducing names
Dear Contributors, thanks for collaboration. I am trying to reorganize data frame, that looks like this: n1.Index Date PX_LAST n2.Index Date.1 PX_LAST.1 n3.Index Date.2 PX_LAST.2 1 NA 04/02/07 1.34 NA 04/02/07 1.36 NA 04/02/07 1.33 2 NA 04/09/07 1.34 NA 04/09/07
2008 Jul 29
1
tensor product of equi-spaced B-splines in the unit square
Dear all, I need to compute tensor product of B-spline defined over equi-spaced break-points. I wrote my own program (it works in a 2-dimensional setting) library(splines) # set the break-points Knots = seq(-1,1,length=10) # number of splines M = (length(Knots)-4)^2 # short cut to splineDesign function bspline = function(x) splineDesign(Knots,x,outer.ok = T) # bivariate tensor product of
2017 Oct 19
0
Select part of character row name in a data frame
Quoting Francesca PANCOTTO <f.pancotto at unimore.it>: > Dear R contributors, > > I have a problem in selecting in an efficient way, rows of a data > frame according to a condition, > which is a part of a row name of the table. > > The data frame is made of 64 rows and 2 columns, but the row names > are very long but I need to select them according to a small
2010 May 17
2
best polynomial approximation
Dear R-users, I learned today that there exists an interesting topic in numerical analysis names "best polynomial approximation" (BSA). Given a function f the BSA of degree k, say pk, is the polynomial such that pk=arginf sup(|f-pk|) Although given some regularity condition of f, pk is unique, pk IS NOT calculated with least square. A quick google tour show a rich field of research
2011 Nov 12
1
Simulation over data repeatedly for four loops
Dear Contributors, I am trying to perform a simulation over sample data, but I need to reproduce the same simulation over 4 groups of data. My ability with for loop is null, in particular related to dimensions as I always get, no matter what I try, "number of items to replace is not a multiple of replacement length" This is what I intend to do: replicate this operation for four
2008 Aug 08
3
Multivariate regression with constraints
Hi all, I am running a bivariate regression with the following: p1=c(184,155,676,67,922,22,76,24,39) p2=c(1845,1483,2287,367,1693,488,435,1782,745) I1=c(1530,1505,2505,204,2285,269,1271,298,2023) I2=c(8238,6247,6150,2748,4361,5549,2657,3533,5415) R1=I1-p1 R2=I2-p2 x1=cbind(p1,R1) y1=cbind(p2,R2) fit1=lm(y1~-1+x1) summary(fit1) Response 2: Coefficients: Estimate Std. Error t value
2013 Jan 29
0
On the calulation of crossed differences
Dear Contributors, I am back asking for help concerning the same type of dataset I was asking before, in a previous help request. I needed to sum data over subsample of three time series each of them made of 100 observations. The solution proposed were various, among which: db<-p dim( db ) <- c(25,4,3) db2 <- apply(db, c(2,3), sum) db3 <- t(apply(db2, 1, function(poff)
2013 Aug 22
1
corrgram (package corrgram): how to plot multiple correlograms in the same page?
Hello, I am trying to plot a few correlograms on the same figure, with the function corrgram() from the package corrgram. However, the function does not seem to use the base graphic system, as setting out the multiple figure layout with, e.g., par(mfrow=c(2, 2,)) does not work. Does anybody know a workaround for this? Many thanks in advance for any advice best giuseppe -- Giuseppe Pagnoni,
2011 Sep 28
1
Wilcox test and data collection
Dear Contributors I have a problem with the collection of data from the results of a test. I need to perform a comparative test over groups of data , recall the value of the pvalue and create a table. My problem is in the way to replicate the analysis over and over again over subsets of data according to a condition. I have this database, called y: gg t1 t2 d 40 1 1
2011 Nov 11
8
Help
Dear Contributors I would like to perform this operation using a loop, instead of repeating the same operation many times. The numbers from 1 to 4 related to different groups that are in the database and for which I have the same data. x<-c(1,3,7) datiP1 <- datiP[datiP$city ==1,x]; datiP2 <- datiP[datiP$city ==2,x]; datiP3 <- datiP[datiP$city ==3,x] datiP4 <-
2008 May 29
2
Troubles plotting lrm output in Design Library
Dear R-helpers, I'm having a problem in using plot.design in Design Library. Tho following example code produce the error: > n <- 1000 # define sample size > set.seed(17) # so can reproduce the results > age <- rnorm(n, 50, 10) > blood.pressure <- rnorm(n, 120, 15) > cholesterol <- rnorm(n, 200, 25) > sex <-
2008 Jul 23
1
mle2(): logarithm of negative pdfs
Hi, In order to use the mle2-function, one has to define the likelihood function itself. As we know, the likelihood function is a sum of the logarithm of probability density functions (pdf). I have implemented myself the pdfs that I am using. My problem is, that the pdfs values are negative and I cann't take the logarithm of them in the log-likelihood function. So how can one take the
2005 Apr 14
1
maildir creation
Hi all, this is my first post to the list and sorry for my english. I have a mail server based on qmail+dovecot+ldap with virtualdomains and maildir stored in /var/vmail/<DOMAIN>/<USERNAME>/Maildir. When I create a user on LDAP I don't create maildir too. So if I log-in with dovecot (143,110) I hope dovecot creates maildir for users but this is not I get: maildir are not
2005 May 16
1
Active Directory Auth
Hi, this is my fist post :) I'm trying to authenticate users to Active Directory, but I don?t know how to set up dovecot-ldap.conf to do this. Specially user_filter and pass_filter attrs. Does someone have this configuration working? Thanks in advance. -- Juan Pablo Fava Ing. en Sistemas de Informaci?n
2008 Jul 22
1
How to simulate heteroscedasticity (correlation)
Hi, I would like to generate two correlated variables. I found that funktion for doing that: a <- rmvnorm(n=10000,mean=c(20,20),sigma=matrix(c(5,0.8*sqrt(50), 0.8*sqrt(50),10),2,2)) (using library(mvtnorm)) Now I also want to generate two correlated variables where the error variance vary over the variable-correlation. And I want to plot this for showing heteroscedasticity. Like shown