similar to: Loop through factors without changing to numerics

Displaying 20 results from an estimated 20000 matches similar to: "Loop through factors without changing to numerics"

2006 Jan 09
2
warning message from nlme
Hi all, I tried to do a variance components using nlme, but I got the following warning mesage ##################################################### not meaningful for factors in: Ops.factor(y[revOrder], Fitted) ###################################################### Can someone point out what is the meaning of this warning message? I tried to look at Ops.factor, but I don't
2006 Jan 05
1
convert matrix to data frame
Hi all, Suppose I have a 4 x 2 matrix A and I want to select the values in second column such that the value in first column equals to k. I gave the colnames as alpha beta, so I was trying to access the info using A$beta[A[,1]==k], however, I was told it's not a data frame, I can get the object by using dollar sign. I tried data.frame(A), but it didn't work. Any input
2006 Jan 12
1
Convert matrix to data.frame
Hi all, I wonder how could I convert a matrix A to a dataframe such that whenever I'm running a linear model such lme, I can use A$x1? I tried data.frame(A), it didn't work. Should I initialize A not as a matrix? Thanks. Yen Lin [[alternative HTML version deleted]]
2006 Jan 16
1
singular convergence(7)?
Hi all, I just wonder what singular convergence means. Thanks. Yen Lin Error in lme.formula(Data ~ 1, random = ~1 | Wafer/fie/loc, subset = Wafer == : singular convergence (7) [[alternative HTML version deleted]]
2006 Jan 18
1
Influence measure + lme ?
Hi all, Does lme has function to compute the cook's distance or influence measure like lm? I can't find them. Thanks. Yen Lin [[alternative HTML version deleted]]
2006 Feb 21
2
Limit of matrix + naming
Hi all, I have read a data matrix of 304 x 404 using read.table. When I am trying to name the colnames, with first try colnames(L5)<-list(2:305), I keep getting error message such as Error in "colnames<-"(`*tmp*`, value = list(c(2, 3, 4, 5, 6, 7, 8, 9, : length of 'dimnames' [2] not equal to array extent and I don't know why. But, if I look at
2013 Nov 04
1
A warning message generated from 'read.csv'
Hi, I'm using R version 3.0.2. While I executed the following command filedata <- read.csv(file, header=TRUE, colClasses="character") I got the warning message: In scan(file, what, nmax, sep, dec, quote, skip, nlines,  ... : EOF within quoted string I'd like to know what this means? And how shall I fix the problem? Thank you for your help. Best, Chia-Chieh Lin
2011 Feb 01
1
How can I index multiple linear models? (Without getting a warning.)
My code looks like this: lin = NA for(i in 1:15){ lin[i] = lm(reservesub[,3]~ reservesub[,i+3]) } For which I'm given 15 warning messages which say : "1: In lin[i] = lm(reservesub[, 3] ~ reservesub[, i + 3]) : number of items to replace is not a multiple of replacement length" I'm am able to generate the 15 different models and get the coefficients. I am able to access
2011 Mar 13
1
problem with looping formula through table
Dear useRs, I am stuck with a piece of code and hope you could give me some pointers. My aim is to calculate the lm-regression coefficients of individual stocks against an index. I am interested in both the coefficient and the pval. While I could do this manually for a select hand full, I hope to scale this up say for 30+ stocks (DAX-30, FTSE-100 etc.) to eventually have a matrix of coefficients
2024 Aug 09
2
If loop
OK. The fact it's in a function is making things clearer. Are you trying to update the values of an object from within the function, and have them available outside the function. I don't speak functional programming articulately enough but basically v <- 1 funA <- function() { v <- v+1 } funA() cat (v) # 1 You either return the v from the function so funB <- function() {
2024 Oct 04
3
apply
OK. Thanks to all. Suppose I have two vectors, x and y. Is there a way to do the covariance matrix with ?apply?. The matrix I need really contains the deviation products divided by the degrees of freedom (n-1). That is, the elements (1,1), (1,2),...,(1,n) (2,1), (2,2),...., (2,n) .... (n,1),(n,2),...,(n,n). > Hello, > > This doesn't make sense, if you have only one vector you
2024 Oct 04
1
apply
Hello, This doesn't make sense, if you have only one vector you can estimate its variance with var(x) but there is no covariance, the joint variance of two rv's. "co" or joint with what if you have only x? Note that the variance of x[1] or any other vector element is zero, it's only one value therefore it does not vary. A similar reasonong can be applied to cov(x[1],
2024 Aug 09
1
If loop
The following (using if else) did not help. Seemed like joint12 always kicked in. ??? me1<-me0<-NULL. ??? if(joint12){ ????? {me1<-cbind(me1,v1$p12);? me0<-cbind(me0,v0$p12)} ??? } else if(marg1) { ????? {me1<-cbind(me1,v1$p1);?? me0<-cbind(me0,v0$p1)} ??? } else if(marg2) { ????? {me1<-cbind(me1,v1$p2);?? me0<-cbind(me0,v0$p2)} ??? } else if(cond12){ ?????
2024 Aug 09
3
If loop
"Or use <<- assignment I think. (I usually return, but return can only return one object and I think you want two or more" You can return any number of objects by putting them in a list and returning the list. Use of "<<-" is rarely a good idea in R. -- Bert On Fri, Aug 9, 2024 at 1:53?AM CALUM POLWART <polc1410 at gmail.com> wrote: > > OK. The fact
2024 Oct 04
2
apply
Hello I have a vector: set.seed(123) > n<-3 > x<-rnorm(n); x [1] -0.56047565 -0.23017749 1.55870831 I like to create a matrix with elements containing variances and covariances of x. That is var(x[1]) cov(x[1],x[2]) cov(x[1],x[3]) cov(x[2],x[1]) var(x[2]) cov(x[2],x[3]) cov(x[3],x[1]) cov(x[3],x[2]) var(x[3]) And I like to do it with "apply". Thanks. On 10/4/2024 6:35
2024 Oct 04
1
apply
It's still hard to figure out what you want. If you have two vectors you can compute their (2x2) covariance matrix using cov(cbind(x,y)). If you want to compute all pairwise squared differences between elements of x and y you could use outer(x, y, "-")^2. Can you explain a little bit more about (1) the context for your question and (2) why you want/need to use apply() ? On
2018 May 22
0
Using tryCatch in a for loop
No. If your ouput is a numeric "matrix", it cannot include alpha. Columns in a data frame can be of different classes, but each column must be single class. and finally, of course, see ?cat -- I think you are misusing it. If you simply want to return "somestuff", your function should be: function(w) {"somestuff"} not function(w) {cat("somestuff")} As
2018 May 22
2
Using tryCatch in a for loop
Data and code as promised: #Creating a test dataset Year<- c(2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014) Lake1<- c(2, 4, 5, 2, 1, 1, 2, 3, 4, 5, 6, 2, 3, 1, 2) Lake2<- c(1, 3, -1, 4, -2, 1, 2, 3, 4, 5, 6, 2, 3, 1, 2) Lake3<- c(1, 2, 5, -3, 1, 1, 2, 3, 4, 5, 6, 2, 3, 1, 2) Lake4<- c(1, 1, 1, 1, 1, 1, 1, 250, 240, 240, 240, 240, 240, 239,
2011 Nov 04
6
Matrix element-by-element multiplication
is there a way to do element-by-element multiplication as in Gauss and MATLAB, as shown below? Thanks. --- a 1.0000000 2.0000000 3.0000000 x 1.0000000 2.0000000 3.0000000 2.0000000 4.0000000 6.0000000 3.0000000 6.0000000 9.0000000 a.*x 1.0000000 2.0000000 3.0000000 4.0000000
2024 Oct 04
1
apply
Hello, If you have a numeric matrix or data.frame, try something like cov(mtcars) Hope this helps, Rui Barradas ?s 10:15 de 04/10/2024, Steven Yen escreveu: > On 10/4/2024 5:13 PM, Steven Yen wrote: > >> Pardon me!!! >> >> What makes you think this is a homework question? You are not >> obligated to respond if the question is not intelligent enough for you.