similar to: If/then statement, if in a list then

Displaying 20 results from an estimated 10000 matches similar to: "If/then statement, if in a list then"

2012 Jul 24
3
Linear Model Prediction
I have data X and Y, and I want to predict what the very next point would be based off the model. This is what I have: >model=lm(x~y) I think I want to use the predict function, but I'm not exactly sure what to do. Thank you! -- View this message in context: http://r.789695.n4.nabble.com/Linear-Model-Prediction-tp4637644.html Sent from the R help mailing list archive at Nabble.com.
2012 Jul 17
2
TRUE/FALSE
Any reason I'd get an error like this? Error in if (round(pos[o + 1]) == (pos[o + 1] - 0.4)) { : missing value where TRUE/FALSE needed but when i do it individually, out of the for loop, > (round(pos[o+1])==(pos[o+1]-.4) ) 65 TRUE -- View this message in context: http://r.789695.n4.nabble.com/TRUE-FALSE-tp4636748.html Sent from the R help mailing list archive at Nabble.com.
2012 Jul 18
1
Skip file
What i have is a for loop to name files. I want it to skip over the file if it doesn't exist. Is there a way to do that? s=seq(from = chron("03/15/2012"), to = chron("06/15/2012")) day=format(as.Date(s), "%Y%m%d") for (k in 1:length(day)){ B1=read.csv(paste("S:/file_", day[k], ".csv", sep="")) Date=strptime(B1[,1],
2008 Apr 29
5
If(cond) statement
Why will this simple statement not work? I think I am following the documentation for if(cond) statements, and I have tried wrapping the cons.expr and alt.expr in {}, I get the same error. There is no example in the help file, and this is not covered in the Introduction to R, SimpleR or other tutorials I have looked into. mxx=max(cpx_list$nMV); mxy=max(trend_list$nMV); if (mxx>mxy) mxy=mxx
2009 Apr 19
2
Including a vector element in an if statement
Hi all, I've searched high and low on this and found nothing of help. I'm using v2.6.2 and trying to write a function that will count how many people from a dataset fall under a poverty line of 50% of the mean income. a9 is my 100-element vector of incomes. I want pa9 to be my vector that counts how many of these are classed as in poverty. My problem is that my command if(a9[i] <
2007 Jan 19
3
if else statement
Hello, I'm doing some scripting and I've noticed that R doesn't seem to have an if (cond){ do }ifelse (cond) { do } else { do } type block. Is this correct or am I missing something. THX Paul -- Research Technician Mass Spectrometry o The / o Scripps \ o Research / o Institute
2003 Sep 02
8
I don't understand this
For reasons which I'll spare you, I'm writing a program to analyse R source code. This has led me to probe some of the darker corners of R syntax to find out what is supposed to happen. Now, from reading the R documentation (and the New S book &c) I know perfectly well that f(a, b, etc) <- x is supposed to turn into a <- "f<-"(a, b, etc, value=x) Except,
2003 Feb 11
4
How "else" works
I have what is likely to be a simple question about the else keyword. The usage in the help pages is as follows: if(cond) cons.expr else alt.expr I would expect to be able to use it in the following way as well: if(cond){ cons.expr } else alt.expr This results a syntax error. Am I doing something wrong, or doesn't R support the spanning of the combination of if and else
2011 Apr 14
1
if (cond) expr1 expr2 ??
hi , this can be done easily if (cond) expr ex:  > for (i in 1: 4)+ {+ if(i==2) print("a")+ if(i==2) print("b")+ } output : [1] "a"[1] "b" but i want this  if (cond) expr1 expr 2 i tried this :  > for (i in 1: 4)+ {+ if(i==2) (print("b") && print("a"))+ } output : [1] "b"Error in print("b") &&
2011 Jul 27
3
[LLVMdev] Proposal for better assertions in LLVM
wrapping the macro's body in: do { ... } while (false) would make the the macro a proper statement so that: if (cond) ASSERT(some_other_cond); else do_something_cool (); compiles as expected. IMO, it would work as such #define ASSERT_STM(cond,expr) On Tue, Jul 26, 2011 at 6:36 PM, Reid Kleckner <reid.kleckner at gmail.com>wrote: > He wants to be able to resume execution
2006 Jun 08
2
Turning off a temporary message in voicemail
Can a temporary message in Asterisk voicemail be de-activated so that the "regular" unavailable and busy messages are played. I have several users who are stuck with the temporary message. Thanks Mark
2011 Mar 24
3
Extract the names of the arguments in an "expression"
Hi everybody: I need to get the names of the arguments in an object of class "expression". I've got the following expression: > x <- expression(rho * cos(omega)) Is there any function or procedure that returns the names of the arguments (in the example: "rho" and "omega")? I tried a rough approach implemented in the function expr.args() shown below. As
2011 Jul 27
0
[LLVMdev] Proposal for better assertions in LLVM
sorry, my previous message got sent too early I think the macro should look something like this: #define ASSERT_STRM(cond,expr) \ do { if (cond) { std::cerr << expr << std::end; assertion_trap (); } } while (false) On Tue, Jul 26, 2011 at 7:57 PM, Nathan Jeffords <blunted2night at gmail.com>wrote: > wrapping the macro's body in: > > do { ... } while
2018 Nov 22
2
[tryExcept] New try Function
Hi everyone, When dealing with errors, sometimes I want to run a bunch of code when an error occurs. For now I usually use a structure such as: res <- tryCatch(expr, error = function(cond) cond) # or try(expr) if (inherits(res, ?error?)) # or inherits(res, ?try-error?) # a bunch of code I though it would be useful to have a function that does this naturally, so I came up with the attached
2013 Apr 23
2
[LLVMdev] 'loop invariant code motion' and 'Reassociate Expression'
Hi, I am investigating a performance degradation between llvm-3.1 and llvm-3.2 (Note: current top-of-tree shows a similar degradation) One issue I see is the following: - 'loop invariant code motion' seems to be depending on the result of the 'reassociate expression' pass: In the samples below I observer the following behavior: Both start with the same expression: %add = add
2007 Aug 20
2
how to collapse a list of 1 column matrix to a matrix?
Hi, I encounter a situation where I have a list whose element is a column matrix. Says, $'1' [,1] 1 2 3 $'2' [,1] 4 5 6 Is there fast way to collapse the list into a matrix like a cbind operation in this case? Meaning, the result should be a matrix that looks like: [,1] [,2] [1,] 1 4 [2,] 2 5 [3,] 3 6 I can loop through all elements and do
2013 Apr 25
2
[LLVMdev] 'loop invariant code motion' and 'Reassociate Expression'
It's an interesting problem. The best stuff I've seen published is by Cooper, Eckhart, & Kennedy, in PACT '08. Cooper gives a nice intro in one of his lectures: http://www.cs.rice.edu/~keith/512/2012/Lectures/26ReassocII-1up.pdf I can't tell, quickly, what's going on in Reassociate; as usual, the documentation resolutely avoids giving any credit for the ideas. Why is that?
2008 Aug 13
3
conditional IF with AND
Hi everyone, I'm trying to create an "if" conditional statement with two conditions, whereby the statement is true when condition 1 AND condition 2 are met: code structure: if ?AND? (a[x,y] <condition1>, a[x,y] <condition2>) I've trawled through the help files, but I cannot find an example of the syntax for incorporating an AND in a conditional IF statement.
2007 May 15
1
Problem accessing SWAT with Firefox
Hi, not sure if I'm posting in the right place but couldn't find a SWAT forum. I've just changed my PC but the new one has exactly the same settings (IP, computername, login, password) as the old one, however I am getting an error when I try to access any of my Samba servers from Firefox (2.0.0.3) :- " 400 Server ErrorSamba is configured to deny access from this client Check
2017 Jul 04
5
about adding a column for water year
Hi R users, I have a question about adding a column for water year. The dataframe has the structure below. But the wyear column just shows one year. Could anyone help me with this problem? Thanks. DF year month day time flow 1972 1 1 1972-01-01 5 1972 1 2 1972-01-02 5.5 1972 1 3 1972-01-03 6 ... 1985 12