similar to: simple for loop question - how do you exit?

Displaying 20 results from an estimated 20000 matches similar to: "simple for loop question - how do you exit?"

2009 Apr 22
1
How do I loop through strings?
I read in a CSV file with Data <- read.csv(file="FileName.csv",head=TRUE,sep=",") the file containts strings in the 2nd and 3rd columns and each has about 1000 rows. I need to either loop through the strings there looking for strings that would trigger other logic or remove those rows and put them in another array and loop through them in the new array. I can't seem
2009 Apr 23
6
Stuck using constrOptim
Trying to use constrOptim to minimize the sum of squared deviations. I put the objective function in as: sum((x %*% Y - Z)^2) so i'm trying to get values for x to minimize the sum of the squared deviations between the product of x and Y and Z. Anyways i have no problem using this when x is a 3x1 test variable. it works great with the constraints and everything. when i actually use it on
2009 Apr 22
3
Help using spg optimization in BB package
i'm trying to use the BB package to minimize the sum of the squared deviations for 2 vectors. The only thing am having trouble with is defining the project constraint. I got the upper and lower bounds to work but i am not sure how to create a constraint that the sum of x must be 1. Any help would be greatly appreciated. -- View this message in context:
2009 Oct 22
3
Simple question, I think
Greetings, I am recoding a dummy variable (coded 1,0) so that 0 = 2. I am using the line sciach$dummyba[sciach$ba==0] <- 2 I notice that it creates a new column dummyba, with 0 coded as 2 but with 1's now coded as NA. Is there a simple way around this in the line I am using, or do I need to have an additional line sciach$dummyba[sciach$ba==1] <- 1 Thanks in advance. David
2008 Nov 30
4
simple question with table()
Dear List, my problem should be easy to fix, but I couldn't find a solution by myself... In my survey, there is a question with 14 possible answers. None of the respondents choose the 13th answer, so when I table() the results, R says: 1 2 3 4 5 6 7 8 9 10 11 12 14 31 52 7 21 40 7 8 2 28 2 2 1 17 13 is missing... anyone knows how to tell table() that there are 14 modalities in the
2008 May 13
9
A Very Simple Question
On 5/13/2008 10:27 AM, Yukihiro Ishii wrote: > Hi Rusers! > > I am ashed of asking such a simple question. > > X<-matrix(rnorm(24), 4) > X0<-apply(X,2,mean) > > What I want is a matrix which consists of colums such as X[,1]--X0[1]. > > X-X0 doesn't work. > > Perhaps apply function? scale(X, scale=FALSE) ?scale > Thanks in advance. > >
2007 Jan 16
2
problems with for loop
Hello, With this program I try to repeat analysis for different years. The results of the analysis are not printed when in the loop, except for the year sequence. What is wrong? Thanks a lot. for (i in 92:99){ cat("\n", "=============================================================\n", "YEAR =",i,"\n",
2007 Nov 01
4
simple averaging question?
Hi all, Suppose I have a column vector of 600 measurements taken in 1s intervals. What I want is a new vector with the averages for each min (so there would be 10 entries). Is there an efficient way to do this? I’ve been doing it with a ‘for’ loop but something tells me there is a simple command that is more efficient. Jeff Internal Virus Database is out-of-date. Checked by
2010 May 13
3
How ls() only functions or anything else but functions?
Hello, How ls() only functions or only data objects (basically anything other than functions) such as data.frame, numeric ...? John [[alternative HTML version deleted]]
2008 Oct 03
1
how to do a probit?
Hi, I know that this question appears in the archives, but from the docs I couldn't figure out how to do it, (I am really new to R) I have a simple setting with three variables (y binary, x1 continuous, x2 dummy) and would like to run a probit estimation of the form y=Phi(X*B). How can I do this? I've found nls, but can't figure out how to use it. thanks for your help, Viktor
2008 Apr 14
3
Power curves
Hi, I am trying to create a power curve to show how the power of a t-test varies depending on the mean. Any ideas how I should go about this? Louisa _________________________________________________________________ [[alternative HTML version deleted]]
2009 Jun 12
3
Replacing 0s with NA
Hello I have a dataset in which I would like to replace 0s with NAs. There is a lot of information on how to replace NAs with 0, but I have struggled to find anything with regards to doing the reverse. Any recommendations would be great. Cheers Christine
2008 Aug 07
6
multiple tapply
Hi folk, I tried this and it works just perfectly tapply(iris[,1],iris[5],mean) but, how to obtain a single table from multiple variables? In tapply x is an atomic object so this code doesn't work tapply(iris[,1:4],iris[5],mean) Thanx and great summer holidays Gianandrea -- View this message in context: http://www.nabble.com/multiple-tapply-tp18868063p18868063.html Sent from the R help
2007 Jan 27
3
how to handle a longitudinal data
i have a data set with repeated measures on same people, structure like below: id x1 x2 ... 001 10 20 ... 001 8 45 ... 001 4 2 ... 002 .... 002 ... 002 .... 002 .... 003 .... ....... what is the easist way to show how many observations for each subject id? [[alternative HTML version deleted]]
2010 Mar 01
3
setting the steps for x axis labels on plot
Hello, I'm new to R, I've been working with it for the last 2 weeks. I am plotting some data and not getting the labels on the x axis I am expecting on my plot. my code reads #hours in the day h <- c(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23) #hp is a data frame with a pivot table of 25 columns (label and data for 24 hours) plot(h, as.matrix(hp[1,2:25]),
2007 Jan 18
4
How to optimize this loop ?
Dear R Users, I request your help to optimize a loop. Given a series of observations, I want to know how many consecutive past observations are below the last one. e.g : my_series <- c(3, 4, 10,14,8,3,4,6,9) As the last number (9) is higher than the four preceding numbers (6, 4, 3, 8), this function should return 4. my_series <- c(3, 4, 10,14,8,3,4,11,9) Here, it should return 0, as 9
2008 Jun 06
5
request: a class having max frequency
Dear R users I have a very basic question. I tried but could not find the required result. using dat <- pima f <- table(dat[,9]) > f 0 1 500 268 i want to find that class say "0" having maximum frequency i.e 500. I used >which.max(f) which provide 0 1 How can i get only the "0". Thanks and best regards Muhammad Azam Ph.D. Student Department of
2009 Dec 02
4
Finding cases in one subset that are closet to another subset
Good afternoon Running R2.10.0 on Windows I have a data frame that includes (among much else) a factor (In_2006) and a continuous variable (math_3_4). I would like to find the 2 cases for In_2006 = 0 that are closest to each case where In_2006 = 1. My data looks like In_2006 math_3_4 0 55.1 1 51.6 1 18.1 1 26.6 1 14.1
2008 Mar 04
2
Asking, are simple effects different from 0
Hello, R-i-zens. I'm working on an data set with a factorial ANOVA that has a significant interaction. I'm interested in seeing whether the simple effects are different from 0, and I'm pondering how to do this. So, I have my.anova<-lm(response ~ trtA*trtB) The output for which gives me a number of coefficients and whether they are different from 0. However, I want the
2004 Jun 25
2
simple questions
Hello, I am a new user or R, and am so far very impressed with its capabilities. However, I have no programming experience, and am having some issues in trying to tell the software what I want done. There are basically two issues which I am currently grappling with. The first, I have a data matrix, with two factors and dozens of response variables. I am interested on conducting ANOVAs on