similar to: For loop help

Displaying 20 results from an estimated 10000 matches similar to: "For loop help"

2004 Feb 17
10
How to write efficient R code
I have been lurking in this list a while and searching in the archives to find out how one learns to write fast R code. One solution seems to be to write part of the code not in R but in C. However after finding a benchmark article (http://www.sciviews.org/other/benchmark.htm) I have been more interested in making the R code itself more efficient. I would like to find more info about this. I have
2003 Oct 27
3
expanding factor with NA
I have a factor (with "n" observations and "k" levels), with only "nobs" < n of the observations not missing. I would like to produce a (n x k) model matrix with treatment contrasts for this factor, with rows of NAs placeholding the missing observations. If I use model.matrix() I get back a (nobs x k) matrix. Is there an easy way to get the (n x k) without
2003 Oct 02
3
Query: weighting cells in histogram
I have the 'breaks' for the histogram ('hist') but I want weight the cells instead of using actual observations. I thought that using freq=FALSE implied that the numbers in 'x' were weights but this turned out to be wrong. Any help and/or comment is very much appreciated. Regards, M?rten M?rten Bjellerup Doctoral Student in Economics School of Management and Economics
2004 Mar 24
7
binding vectors or matrix using their names
Hello list, I have two vectors x and x2: x=runif(10) x2=runif(10) and one vectors with their names : my.names=c("x","x2") I would like to cbind these two vectors using their names contained in the vector my.names. I can create a string with comma ncomma=paste(my.names,collapse=",") and now, I just need a function to transform this string into a adequate
2003 Dec 18
3
mclust - clustering by spatial patterns
Dear All, I have spatial data (presence/absence for 4000 squares) on 250 bird species and would like to use a model-based clustering technique to test for species associations. Is there any way of passing a distance/correlation matrix to mclust as with hclust, rather than the actual data? Or alternatively, is there a way of getting mclust to handle binary data? I'd appreciate any
2003 Apr 22
7
Subject: Eliminate repeated components from a vector X-Mailer: VM 7.00 under 21.4 (patch 6) "Common Lisp" XEmacs Lucid Reply-To: fjmolina at lbl.gov FCC: /home/f/.xemacs/mail/sent Does anyone know how I can eliminate repeated elements from a vector?
2004 Jan 04
5
Analyzing dendograms??
I have used heatmap to visualize my microarray data. I have a matrix of M-values. I do the following. #The distance between the columns. sampdist <- dist(t(matrix[,]), method="euclidean") sclus <- hclust(sampdist, method="average") #The distance between the rows. genedist <- dist(matrix[,], method="euclidean") gclus <- hclust(genedist,
2003 Nov 02
2
cannot have a function argument named 'break'
Dear list - I just discovered to my surprise that I cannot define a function with an argument named 'break' or 'while'! 'breaks' is okay. Maybe this is no surprise to the R developers. R-1.7.1, 2003-06-16, i686-pc-linux-gnu. - tom blackwell - u michigan medical school - ann arbor -
2003 Oct 06
4
Apply and its friends
Hi, Forgive a very basic question... I need to take two lists-of-lists, and apply a function to each pair of elements in the lists to return a single list... For example l1 <- list(1:5,6:10,2:15) l2 <- list(1:8,4:12,1:19,4:20) I could easily do an lapply across each of them, but is there a function that does a sort-of pairwise-apply across both together? Does anybody know of a good
2003 Oct 15
3
Fw: SIMCA algorithm implementation
I have used PCA for data classification by visual examination of the 3D scatter plot of the first 3 principal components. I now want to use the results to predict the class for new data. I have used predict.princomp to predict the scores and then visualise the results on a 3D scatter plot using the rgl library. However, is there an R function that will fit the new data to the class assignments
2003 May 22
1
Plot observed vs. fitted values (weighted nls)
Dear WizaRds, Given the experimental data, csdata<-data.frame( time=c(0,1,3,9,20), conc=c(638.697,395.69,199.00,141.58,112.16) ) weighted nls is applied, wt.MM<- function(resp, time,A1,a1,A2,a2) { pred <- A1*exp(-a1*time)+A2*exp(-a2*time) (resp - pred) / sqrt(pred) } # cs.wt <- nls( ~ wt.MM(conc, time,A1,a1,A2,a2), data=csdata,
2003 Nov 10
2
boot package question: sampling on factor, not row
Hi all: I've been looking at the boot package to "bootstrap" sample my data in a particular way. I haven't figured out how to set this up using the boot() command and thus have resorted to trying to write my own script (although I'd prefer if I could get boot() to work for this problem!) The dataset is set up in the following way: ix(factor) value 1 5.73 1 6.99 1
2004 Feb 18
3
persp and lines()
R-sters: I'm interested in keeping data plotted in persp to preserve the wireframe look, I'd just like to change one of the lines drawn (in either the x or y direction) into a different color so that it stands out. Or is there some way to add a line (say, via lines(), or abline()) to a persp() plot at the designated x or y that would follow the z surface contour? I could add a line
2003 Feb 21
2
how to chage values in data frame to NA iside a function
Dear all I have a function in which I would like to change some values to NA according to some condition. dropout<-function(y, nahr=FALSE,...) { <some stuff for computing an index> if (nahr) y[index]<<-NA invisible(index) } in case y is a vector all works OK but if it is a part of data frame by calling dropout(df$y) or dropout(df[,number]) no change is done. Please can you
2003 Jun 04
2
plot rpart tree's from list object
Hello, i want the post plot's from a rpart list object with 18 tree's , getting no error - but getting no files,too? Perhaps i should using assign!? for (i in 1:length(treeList)) { post(treeList[[i]],filename=paste("Tree","i",sep=".ps"), title="Arbeitszufriedenheit", digits=getOption("digits") - 0,use.n=TRUE) } many thanks for help,
2004 Mar 09
5
Adding data.frames together
I have a series of data frames that are identical structurally, i.e. - made with the same code, but I need to add them together so that they become one, longer, data frame, i.e. - each of the slot vectors are increased in length by the length of the added data frame vectors. So if I have df1 with a slot A so that length(df1$A) = 100 and I have df2 with a slot A so that length(df2$A)=200 then I
2003 Nov 04
5
read.spss Error reading system-file header
Is there any documentation on what kind of SPSS file can and cannot be read by read.spss? Alternatively, how can one modify or "clean" an SPSS file to make it readable by read.spss? What properties must a *.sav file before read.spss can read it? The file in this example is 270KB, with 5 rows and 173 columns. I have no trouble reading larger files with read.spss, so it's not
2003 Sep 16
1
help("print") seems truncated
Dear r-help - I just noticed that in my R-1.7.1 on i386-pc-linux-gnu, the page displayed by help("print") ends with the line " ## Printing of factors illustrated for ex" and then no more. It looks as though something got truncated here. I think this is an R that I compiled from source off of CRAN, but I can't quite remember. - tom blackwell - u michigan
2003 Sep 10
2
Need your help-SOS
Hello, I am a newbie in R project and trying to call prcomp(x) of R function using (D)COM server communicate with R in ASP, and encountering the error "Runtime error -2147221493(8004000b). Automation Error, Object is static, operation not allowed." Source code is shown as below: <% Set StatConn=Server.CreateObject("StatConnectorSrv.StatConnector")
2003 May 01
2
What' wrong?
I try to do single proportion test on my category data. Here is my R script: library("ctest") catSignifTest <- function( catFile ) { ############################################################### ## Get the data sets from text file catData <- read.table( catFile ) ncols <- length(catData) nrows <- length(catData[,1]) ncol1 <- ncols - 1 probeNbr