similar to: How to remove double for loop?

Displaying 20 results from an estimated 10000 matches similar to: "How to remove double for loop?"

2008 Mar 19
3
How to remove double loop?
Bill, Alberto, Gabor, Thank you for answering my question. Now I learned about outer() function. That was a straightforward example. But what if I had a matrix, where the last column was filled with values first (again, a for loop), and the rest was filled by using a double loop? OVal <- matrix(0, n+1, n+1) for(i in 0:n){ OVal[i+1, n+1] <- max(Val[i+1, n+1]-K, 0) } for(i in seq(n,1,
2002 Jan 16
4
faster vector subtraction??
hi is there a faster way to do this? i <- 1 for(x in vector1) for(y in vector2) { m[[i]] <- (x - y) i <- i + 1 } regards soren -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in
2008 Nov 08
4
missing value where TRUE/FALSE needed
Hello dear R people, for my MSc thesis I need to program some functions, and some of them simply do not work. In the following example, I made sure both vectors have the same length (10), but R gives me the following error: Error in if (vector1[i] == vector2[j]) { : missing value where TRUE/FALSE needed I googled for possible solutions, but I did not find a good explanation for this...
2012 Jul 30
4
A "matching problem"
Dear all, I was encountering with a typical Matching problem and was wondering whether R can help me to solve it directly. Let say, I have 2 vectors of equal length: vector1 <- LETTERS[1:6] vector2 <- letters[1:6] Now I need to match these 2 vectors with all possible ways like: (A,B,C,D,E) & (a,b,c,d,e) is 1 match. Another match can be (A,B,C,D,E) & (b,a,c,d,e), however there
2008 Jan 07
3
Polynomial fitting
I wonder how one in R can fit a 3rd degree polynomial to some data? Say the data is: y <- c(15.51, 12.44, 31.5, 21.5, 17.89, 27.09, 15.02, 13.43, 18.18, 11.32) x <- seq(3.75, 6, 0.25) And resulting degrees of polynomial are: 5.8007 -91.6339 472.1726 -774.2584 THanks in advance! -- Jonas Malmros Stockholm University Stockholm, Sweden
2005 Jun 20
3
vectorisation suggestion
Hi All, I am counting the number of occurrences of the terms listed in one vector in another vector. My code runs: for( i in 1:length(vector3)){ vector3[i] = sum(1*is.element(vector2, vector1[i])) } where vector1 = vector containing the terms whose occurrences I want to count vector2 = made up of a number of repetitions of all the elements of vector1 vector3 = a vector of NAs that is
2007 Dec 17
3
Cannot grasp how to apply "by" here...
I have a data frame named "database" with panel data, a little piece of which looks like this: Symbol Name Trial Factor1 Factor2 External 1 548140 A 1 -3.87 -0.32 0.01 2 547400 B 1 12.11 -0.68 0.40 3 547173 C 1
2003 Aug 26
3
matching-case sensitivity
Hi All, I am trying to match two character arrays (email lists) using either pmatch(), match() or charmatch() functions. However the function is "missing" some matches due to differences in the cases of some letters between the two arrays. Is there any way to disable case sensitivity or is there an entirely better way to match two character arrays that have identical entries but written
2007 Nov 13
1
Cleaning database: grep()? apply()?
Dear R users, I have a huge database and I need to adjust it somewhat. Here is a very little cut out from database: CODE NAME DATE DATA1 4813 ADVANCED TELECOM 1987 0.013 3845 ADVANCED THERAPEUTIC SYS LTD 1987 10.1 3845 ADVANCED THERAPEUTIC SYS LTD 1989 2.463 3845 ADVANCED THERAPEUTIC SYS LTD 1988 1.563 2836 ADVANCED TISSUE
2007 Oct 27
3
How to make own function load automatically on startup
Dear list members, I have written a function, called say Analysis. I supply an Excel file name as an argument, it does analysis on this file and returns a pdf file with specific plots, and a text file with several statistical models' output (I extract certain values from the output and create my own custom dataframe with output). As of now I have to open the script file and load the function
2007 Dec 17
1
How to create a mixed col.names?
Hello, I have a vector of names, say : names <- c("Factor 1", "Factor 2", Factor 3") I am creating a dataframe and I want the column names to be mixed like this: "Factor 1" " Sign Factor 1" "Factor 2" "Sign Factor 2" "Factor 3" "Sign Factor 3" How can I automate the creation of such a mixed vector? I tried
2005 Sep 09
2
Simulate phi-coefficient
Looking for help with the following problem. Given a sample of zeros and ones, for example: > VECTOR1<-rep(c(1,0),c(15,10)) > VECTOR1 [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 How would I create a new sample (VECTOR2) also containing zeros and ones, in which the phi-coefficient between the two sample vectors was drawn from a population with a known
2007 Oct 31
1
textplot() in gplots causes problems (0x9)
Hello, I am using textplot function in gplots package to put some model output inside a PDF file, but it does not seem to work properly with PDF. I am doing follwing: pdf(file="C:/...", paper="a4", width=8, height=12) .model <- lm(.model.formula, data=database) textplot(capture.output(summary(.model)), valign="top", halign="left") I am getting these
2008 Jun 13
1
x86 SSE* Pointer Favors
Dear Statisticians--- This is not even an R question, so please forgive me. I have so much ignorance in this matter that I do not know where to begin. I hope someone can point me to documentation and/or a sample. I want to compute a covariance as quickly as non-humanly possible on an Intel core processor (up to SSE4) under linux. Alas, I have no idea how to engage CPU vectorization. Do I need
2010 Jan 30
2
parsing files for plot
Hi, I have many files containing one column of data. I like to use the scan function to parse the data. Next I like to bind to a large vector. I try this like: count<-1 files <- list.files() # all files in the working directory for(i in files) { tmp <- scan(i) assign(files[count], tmp) count<-count+1 } This part works! Now I like to plot the data in a boxplot.
2013 Sep 04
3
Fwd: Bienvenido a la lista de distribuciĆ³n R-help-es
Hola Jose, si CONCATENAR significa APILAR, es decir, concantenar verticalmente, por decirlo de algun modo, podrias hacerlo con rbind(): nuevovector <- rbind(vector1,vector2) Si ademas quieres que cada valor de los vectores originales sea identificado en el nuevovector, puedes usar: nuevovector <- stack(vector1,vector2) en este ultimo caso se agrega una columna adicional tipo factor, con
2000 Jun 17
2
R 1.1.0 for Windows
Windows binaries at CRAN (bin/windows/Windows-NT/base) have been updated to R-1.1.0. See below for a list of Windows-specific changes. We thanks all the people who checked over pre-test versions. guido masarotto (for the R-core team) Windows-specific changes to R ============================= There is now a GUI preferences editor on the Edit menu in Rgui. A data entry editor is now
2000 Jun 17
2
R 1.1.0 for Windows
Windows binaries at CRAN (bin/windows/Windows-NT/base) have been updated to R-1.1.0. See below for a list of Windows-specific changes. We thanks all the people who checked over pre-test versions. guido masarotto (for the R-core team) Windows-specific changes to R ============================= There is now a GUI preferences editor on the Edit menu in Rgui. A data entry editor is now
2009 Apr 03
1
Hello! I got error in C - R
Hello, My name is Ick Hoon Jin and I am Ph. D. student in Texas A & M Univ.. When I run the C embedded in R in the Linux system, I confront the following error after 6,000 iteration. By googling I found this error is from the problem in C. *** caught segfault *** address (nil), cause 'memory not mapped' My C code is following:
2007 Oct 26
1
glm with Student t for error distribution
Hello, My response variable seems to be distributed according to Student t with df=4. I have 320 observations and about 20 variables. I am wondering whether there is a way to fit glm with Student t for error distribution. Student t is not one of the family choices in glm function. How should I proceed to fit glm with Student t? I know that Student t is the Inverse Gamma with shape parameter