similar to: if else statements in data frame

Displaying 20 results from an estimated 1300 matches similar to: "if else statements in data frame"

2011 Dec 02
2
Moving column averaging
# need zoo to use rollapply() # your data (I called df) df <- structure(list(a = 1:2, b = 2:3, c = c(5L, 9L), d = c(9L, 6L), e = c(1L, 5L), f = c(4, 7)), .Names = c("a", "b", "c", "d", "e", "f"), class = "data.frame", row.names = c(NA, -2L)) # transpose and make a zoo object df2 <- zoo(t(df)) #rollapply to get
2011 Jul 06
3
identifying a 'run' in a vector
Hi, How can I discern which elements in x (see below) are in 'order', but more specifically.. only the 1st 'ordered run'? I would like for it to return elements 1:8... there may be ordered values after 1:8, but those are not of interest. x <- c(1, 2, 3, 4, 5, 6, 7, 8, 20, 21, 22, 45) Thanks for any suggestions. -- View this message in context:
2006 May 17
1
Example Syntax for if - then- and - else Statements
Hello R users, I am a fairly new R user, however, one of the problems I am having is the use of applying if-, and-, then-, else- statements in R against datasets & dataframe. Rtips mentions it, but without simple examples I am not quite sure what my syntax should look like. I am particularly interested in syntax that can be used with the transform function. for example if foo[,1] ==
2004 May 04
2
If Then Else Statements - Outbound Dialling on ISDN using CAPI -Individual Dial out Plans using msns
Hi All, Many thanks to Marc who helped me with a previous Capi Dialout plan - however..... What I now would like to be able to do is: - We have 8 msn's 383590, 383591 383592 etc. What I would like to do is set up an If Then Else type statement along the following lines: - If extension 7957 Then Dialout on Capi msn 383590 ElseIf extension 7958 Then Dialout on Capi msn 383591 ElseIf
2010 Mar 23
3
If else statements
Hi everyone! May I request again for your help? I need to make some codes using if else statements... Can I do an "if-else statement" inside an "if-else statement"? Is this the correct form of writing it? Thank you.=) Example: for (v in 1:6) { for (i in 2:200) { if (v==1) (if max(x*v-y*v)>1 break()) if (v==2) (if max(x*v-y*v)>1.8 break()) if (v==3) (if
2008 Jul 23
0
Fw: Using if, else statements
Sorry in the previos replay I forgot monday' scale so weight should be: weight <- c(0.91,1,1,1,1,1.21,1.22) names(weight) <- c("mon","tue","wed","thu","fri","sat","sun") ----- Original Message ----- From: "Gabriela Cendoya" <gcendoya at balcarce.inta.gov.ar> To: "Robin Williams" <>
2012 Feb 05
4
nested if else statements
I have a vector of 2,1,0 I want to change to 0,1,2 respectively (the data is allele dosages) I have tried multiple nested if/else statements and looked at the ?if help and cannot work out what is wrong, other people have posted code which is identical and they state works. Any help would be greatly appreciated. > A[1:20] [1] 1 1 0 0 1 0 1 0 1 0 0 0 1 1 0 1 1 1 0 0 > B <-
2003 Jun 30
3
if else statements in R
Hi, there I am a grad student struggling to get my syntax right in a model I am building in R. I am trying to specify a variable,W, in a loop, such that on the first iteration, it is equal to Wo, my starting value, which I have already specified with Wo<-9.2 On any other iteration other than the first, I want W to equal the previous value of W in the iteration. plus an increment from
2011 Nov 17
1
split list of characters in groups of 2
hi, If i have a list of things, like this var.names <- c("a", "b", "c", "d", "e", "f") how can i get this: "a, b", "c, d", "e, f" thanks ahead of time. -- View this message in context: http://r.789695.n4.nabble.com/split-list-of-characters-in-groups-of-2-tp4079031p4079031.html Sent from the R
2006 Feb 14
6
Rails on Sun
Hi Everbody, I''ve got a potential idea for introducing Rails to my company. My only shot at this is to minimize what our Ops guys would have to install and configure to get this up and running. Right now, our servers are Solaris boxes and we are using Sun ONE as our web server. Anyone got Rails running in this environment? Also, has anyone got Rails talking to Oracle databases?
2009 Aug 18
4
Remove columns
Hi Everbody Could somebody help me.? I need to remove the columns where the sum of it components is equal to zero. For example > a<-matrix(c(0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,1,0,0,1,0), ncol=4) > a [,1] [,2] [,3] [,4] [1,] 0 0 0 1 [2,] 0 1 0 1 [3,] 0 0 0 0 [4,] 0 1 0 0 [5,] 0 0 0 1 [6,] 0 0 0 0 Columns
2006 Apr 10
5
ActiveRecord: Behavior not doumented
Hello everbody, doing a #find(:first,an_id) with Rails 1.1.0 I expected that find returns the record which id mathches the given parameter an_id or nil if it couldn''t be found. This behaviour is documented on api.rubyonrails.org. But the find returns the first available object and not nil if an_id is not in the db. Is the doc on rubyonrails.org out of sync? Greetings, -- Daniel
2012 Jan 23
1
R not giving significance tests for coefficients/estimates?
> 3x4 Error: unexpected symbol in "3x4" R has no idea that you equate "x" as multiplication.. use an astrix > 3*4 [1] 12 dominic wrote > > This is basically my code: > > library(MASS) > lmsreg(formula = b0 ~ b1 + b3 + b1xb2, data=mydata) > > b1xb2 is an interaction but it was the centered value for a continuous > variable times a
2011 Feb 14
4
R, Ubuntu, package installation with non-zero exit status
All: I have been looking through the string of posts regarding this same issue, but I haven't been able to fix this problem. I am running Ubuntu 10.4 64bit, R version 2.10.1 I cannot install certain packages (e.g. "vegetarian") and each time it says basically the same thing (regardless of the package): ################################################################ ... leaving
2008 Jul 23
6
Using if, else statements
Hi all, Again I have searched the net and so on, without finding an answer to this surely simple problem. A short bit of code would be appreciated. I have a object named `data' with the following column headings. Date, maxitemp, minitemp, admissions, d.o.w. Where d.o.w. is day of the week, written "Sun" "Mon" etc. I just need to scale the Monday admissions by
2011 Feb 06
2
Subsampling out of site*abundance matrix
Hello, How can I randomly sample individuals within a sites from a site (row) X species abundance (column) data frame or matrix? As an example, the matrix "abund2" made below. ##### (sorry, Im a newbie and this is the only way I know to get an example on here) abund1 <- c(150, 300, 0, 360, 150, 300, 0, 240, 150, 0, 60, 0, 150, 0, 540, 0, 0, 300, 0, 240, 300, 300,
2007 Jan 16
4
ocfs Vs ocfs2
Hi everbody this is my first post, I have two test server .(Both of them is idle) db1 : RHEL4 OCFS2 db2 : RHEL3 OCFS I test the IO both of them The result is below. db1(Time Spend)db2(Time Spend)OS Test Command dd (1GB) (Yazma)0m0.796s0m18.420stime dd if=/dev/zero of=./sill.t bs=1M count=1000 dd (1GB) (Okuma)0m0.241s8m16.406stime dd of=/dev/zero if=./sill.t bs=1M count=1000 cp
2007 Jan 16
4
ocfs Vs ocfs2
Hi everbody this is my first post, I have two test server .(Both of them is idle) db1 : RHEL4 OCFS2 db2 : RHEL3 OCFS I test the IO both of them The result is below. db1(Time Spend)db2(Time Spend)OS Test Command dd (1GB) (Yazma)0m0.796s0m18.420stime dd if=/dev/zero of=./sill.t bs=1M count=1000 dd (1GB) (Okuma)0m0.241s8m16.406stime dd of=/dev/zero if=./sill.t bs=1M count=1000 cp
2012 Oct 29
2
naming datasubsets in a loop
Hello everbody, I want to generate different subsets of my data-set and safe this subsets with names listet in a vector. Because in reality I have got about 70 subsets I want to realize this in a loop Somehow like this: names=c("nam1",
2011 Apr 08
5
duplicates() function
I need a function which is similar to duplicated(), but instead of returning TRUE/FALSE, returns indices of which element was duplicated. That is, > x <- c(9,7,9,3,7) > duplicated(x) [1] FALSE FALSE TRUE FALSE TRUE > duplicates(x) [1] NA NA 1 NA 2 (so that I know that element 3 is a duplicate of element 1, and element 5 is a duplicate of element 2, whereas the others were