Dear Kai
When you ask again it is best to tell us what your input is and what
output you were hoping for and what you actually got. If you can make a
small data-set which shows all that then your post will be much more
likely to get a helpful response. If you want to transfer the data-set
to
Hi Jim,
Sorry to post "same" question, because
1. I was asking to use plain text format. I have to post my question again. But
I don't know if it is working.
2. I'm a beginner for R (< 2 month). It may not easy for me to ask a "clear" R
question. My current work is to transfer my SAS code
Hi Kai,
You seem to be asking the same question again and again. This does not
give us the warm feeling that you know what you want.
testdf<-data.frame(a=c("Negative","Positive","Neutral","Random","VUS"),
b=c("No","Yes","No","Maybe","Yes"),
c=c("Off","On","Off","Off","On"),
Hello,
You don't need a loop, the R way is a vectorized solution and it's also
clearer.
Create a logical index (note only one &) and assign b, c, d where it's TRUE.
i <- try$a != "Positive" & try$a != "VUS"
try <- within(try, {
b[i] <- ''
c[i] <- ''
d[i] <- ''
})
Hope this helps,
Kai,
You have made a simple mistake. And now you cannot see it. I believe this is
not uncommon among programmers. It has happened to me more times than I want
to recall.
> On May 30, 2021, at 9:28 AM, Kai Yang via R-help wrote:
>
> Hello List,I have a data frame which having the character
Can you make R code that creates an actual sample data frame that looks like
you want the answer to look? say, just using the data.frame function and
literal strings. Oh, and read the Posting Guide... you need to send your email
using plain text format or it may get garbled when the list strips
Hello List,I have a data frame which having the character columns:
| a1 | b1 | c1 | d1 |
| a2 | b2 | c2 | d2 |
| a3 | b3 | c3 | d3 |
| a4 | b4 | c4 | d4 |
| a5 | b5 | c5 | d5 |
I need to do: if a1 not = "Positive" and not = "VUS" then values of b1, c1 and
d1 will be zero out. And do the same
Use ifelse function, not if. If is only good for one logical value at a time,
but you are working with long vectors of values simultaneously. I have no
interest in doing all of your workfor you, but the concept is
cpl_or_sngl <- dat1$b %in% c( "couple", "single" )
a_pvt <- "private" == dat1$a
You appear to be confusing && with & and || with | ; (the first of each
pair take a logical expression, the second of each a logical vector) ...
as well as if ... else with ifelse (the first is a flow control statement
taking a logical expression; the second is a function taking a logical
vector
Hi all,
I am trying to use the if else statement and create two new columns
based on the existing two columns. Below please find my sample data,
dat1 <-read.table(text="ID a b c d
A private couple 25 35
B private single 24 38
C none single28 32
E none none 20 36
Thank you very much,
I will work on it
-Original Message-
From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com]
Sent: 11 September 2017 06:50 PM
To: Mangalani Peter Makananisa
Cc: r-help@r-project.org
Subject: Re: Case statement in sqldf
2018-03-3 in your code should be 2018-03-31.
Thanks D,
I will work on the solution you gave and give feedback.
-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: 11 September 2017 05:19 PM
To: Mangalani Peter Makananisa
Cc: r-help@r-project.org
Subject: Re: [R] Case statement in sqldf
> On Sep
2018-03-3 in your code should be 2018-03-31.
The line
then'201415'
needs to be fixed.
When posting please provide minimal self-contained examples. There was
no input provided and library statements not relevant to the posted
code were included.
Fixing the invalid date and bad line, getting
> On Sep 11, 2017, at 1:05 AM, Mangalani Peter Makananisa
> wrote:
>
> Hi all,
>
> I am trying to create a new variable called Fiscal Year (FY) using case
> expression in sqldf and I am getting a null FY , see the code below .
>
> Please advise me as to how I can
Hi all,
I am trying to create a new variable called Fiscal Year (FY) using case
expression in sqldf and I am getting a null FY , see the code below .
Please advise me as to how I can do this mutation.
library(zoo)
library(lubridate)
library(stringr)
library(RH2)
library(sqldf)
Hi tan sj,
It is by no means easy to figure out what you want without the code,
but If I read your message correctly, you can run the loops either
way. When you have nested loops producing output, it is often a good
idea to include the parameters for each run in the output as well as
the result so
hi, i am new in this field.
I am now writing a code in robustness simulation study. I have written a brief
code "for loop" for the factor (samples sizes d,std deviation ) , i wish to
test them in gamma distribution with equal and unequal skewness, with the above
for loop in a single code if
Hi,
Is there a way to easily convert the list of course terms into sequential
integers in the dataframe (see code below)?
eg. 199801 = 1; 199808=2
I know I can use recode but shouldn't which work?
Thanks in advance!
sc = data.frame(c(200208, 200701, 201201))
names(sc) = c(TERM)
TermList =
I'm not quite sure, but I think you might want:
which(TermList %in% sc$TERM)
[1] 11 20 30
instead. Using == ends up with automatic recycling and other things you
probably weren't expecting.
Sarah
On Thu, Jan 22, 2015 at 11:01 AM, Charles Stangor cstan...@gmail.com
wrote:
Hi,
Is there a way
You did not show what answer you expected, but does the following do what
you want?
match(sc$TERM, TermList)
[1] 11 20 30
Making a factor whose levels are TermList may also be useful. (The
exclude=NULL
is to factor doesn't drop NA from the levels).
sc$fTERM - factor(sc$fTERM,
Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Charles
Stangor
Sent: January-22-15 11:01 AM
To: r-help@r-project.org
Subject: [R] 'which' statement for recode?
Hi,
Is there a way to easily convert the list of course terms into sequential
integers
?factor
You might find the description in the Introduction to R that comes with the R
software helpful if the help page seems terse.
Please read the Posting Guide and particular post using plain text format, a
strong in your email program.
Dear all,
I have a data.frame xy that contains numeric data and data_qual which contains
qualitative data which I want to include in a for loop with an if statement
(commented out in the code below).
The if statement should be applied if the ID in data_qual$ID is the same than
in xy$ID.
I am
You have really tied yourself up in a knot here. Last I checked, when A==B,
then B==A. You also need to study the difference between ?if and ?ifelse, since
you are not giving the if function the scalar it expects. For example, i$ID is
a vector of three (identical, due to your use of split)
I believe you are in Circle 8.2.7 of
The R Inferno.
http://www.burns-stat.com/documents/books/the-r-inferno/
Pat
On 28/09/2014 05:49, Kate Ignatius wrote:
Quick question:
I am running the following code on some variables that are factors:
dbpmn$IID1new - ifelse(as.character(dbpmn[,2]) ==
Strange that,
I did put everything with as.character but all I got was the same...
class of dbpmn[,2]) = factor
class of dbpmn[,21] = factor
class of dbpmn[,20] = data.frame
This has to be a problem ???
I can put reproducible output here but not sure if this going to of
help here. I think
Inline.
Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374
Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom.
Clifford Stoll
On Sun, Sep 28, 2014 at 6:38 AM, Kate Ignatius kate.ignat...@gmail.com wrote:
Strange that,
I did put
Apologies - you're right. Missed it in the pdf.
K.
On Sun, Sep 28, 2014 at 10:22 AM, Bert Gunter gunter.ber...@gene.com wrote:
Inline.
Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374
Data is not information. Information is not knowledge. And knowledge
is certainly not
ifelse() often has problems constructing the right type of return value.
if you want to keep the data as a factor (with its existing levels)
use x[condition] - value instead of ifelse(condition, value, x). E.g.,
x - factor(c(Large,Small,Small,XLarge),
levels=c(Small,Med,Large,XLarge))
x
Quick question:
I am running the following code on some variables that are factors:
dbpmn$IID1new - ifelse(as.character(dbpmn[,2]) ==
as.character(dbpmn[,(21)]), dbpmn[,20], '')
Instead of returning some value it gives me this:
c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1))
Playing around
Not reproducible, ball in your court. However, in the meantime, my suggestion
is to not do that. Convert to character before you alter the factor, then
convert back when you are done.
---
Jeff Newmiller
On Sun, 28 Sep 2014 12:49:41 AM Kate Ignatius wrote:
Quick question:
I am running the following code on some variables that are factors:
dbpmn$IID1new - ifelse(as.character(dbpmn[,2]) ==
as.character(dbpmn[,(21)]), dbpmn[,20], '')
Instead of returning some value it gives me this:
Hi,
Please show a reproducible example.
countrydiff - c(Albania, Algeria, Belarus, Canada, Germany)
long_df - data.frame(country_name = c(Algeria, Guyana, Hungary,
Algeria, Canada, Iran, Iran, Norway,Uruguay, Zimbabwe) )
ifelse(long_df$country_name %in% countrydiff,1,0)
# [1] 1 0 0 1 1 0 0 0 0
Dear list-members,
I have the following problem: I have a vector (countrydiff) with length 72
and another vector (long_df$country_name) which is about 12000 long.
Basically what I want to do is to if the factor level (or string name) in
long_df$country_name appears on the countrydiff, then
Dear Arun
Thanks for your reply, it made me realize that the problem was not in the
code but in the levels() of the factors. Some countries had some extra
spacing which made the ifelse() function not work. So if I modify your code
(added space to countrydiff), it will then look something like
Hi Adel,
If the problem is the spacing, then
library(stringr)
1*(long_df$country_name %in% str_trim(countrydiff))
# [1] 1 0 0 1 1 0 0 0 0 0
A.K.
Dear Arun
Thanks for your reply, it made me realize that the problem was
not in the code but in the levels() of the factors. Some countries had
Hello, gncl dzgn,
your problem has a flavor of homework which is usually not delt with on
this list. However, a few comments:
0. The description of your problem is rather vague, in particular, the
meaning of input in the description of your conditions is unclear! (By
the way, your main
Hi everyone,
you might find my question elementary but I am a beginner and unfortunately I
can't fix the problem.
So, I simulate this following algorithm and some values of c are NA. Therefore,
I should add these following two if-statements but I don't know how I should do
it in a for-loop.
Hello.
I have a two statement logical that if NA is returned for the second
statement I want to rely on result of the first statement. I still would
like to use both when I can though.
x - c(1:5)
y - c(1,2,NA,4,5)
x 5 x-y == 0
How can I trick R to refer back to (x 5) where it is NA on the
On 12-12-10 7:55 PM, Hans Thompson wrote:
Hello.
I have a two statement logical that if NA is returned for the second
statement I want to rely on result of the first statement. I still would
like to use both when I can though.
x - c(1:5)
y - c(1,2,NA,4,5)
x 5 x-y == 0
How can I trick R to
On Dec 10, 2012, at 4:55 PM, Hans Thompson wrote:
Hello.
I have a two statement logical that if NA is returned for the second
statement I want to rely on result of the first statement. I still
would
like to use both when I can though.
x - c(1:5)
y - c(1,2,NA,4,5)
x 5 x-y == 0
How can
On Jun 28, 2012, at 09:42 , Rui Barradas wrote:
Hello,
Another way is to use index vectors:
v1.factor - c(S,S,D,D,D,NA)
v2.factor - c(D,D,S,S,S,S)
td2 - test.data - data.frame(v1.factor,v2.factor)
for (i in 1:nrow(test.data) ) {
[... etc ...]
} #End FOR
# Create index
Hi James,
On Thu, Jun 28, 2012 at 12:33 AM, James Holland holland.ag...@gmail.com wrote:
I need to look through a dataset with two factor variables, and depending
on certain criteria, create a new variable containing the data from one of
those other variables.
The problem is, R keeps making
Hello,
Another way is to use index vectors:
v1.factor - c(S,S,D,D,D,NA)
v2.factor - c(D,D,S,S,S,S)
td2 - test.data - data.frame(v1.factor,v2.factor)
for (i in 1:nrow(test.data) ) {
[... etc ...]
} #End FOR
# Create index vectors
na1 - is.na(v1.factor)
na2 - is.na(v2.factor)
# Create
Yeah, the reason I didn't use ifelse is because I've got multiple variables
to manipulate based on the if statement, some factors and some numeric. I
have to look at the factor variables, and based on that, either use one
series of variables or another.
With the multiple if statements I need to
On Thu, Jun 28, 2012 at 8:47 PM, James Holland holland.ag...@gmail.com wrote:
With the multiple if statements I need to check for, I though for statements
with the if/else if conditional statement was better than nested ifelse
functions.
for () gives you a lot of flexibility at the expense of
I need to look through a dataset with two factor variables, and depending
on certain criteria, create a new variable containing the data from one of
those other variables.
The problem is, R keeps making my new variable an integer and saving the
data as a 1 or 2 (I believe the levels of the
On Jun 7, 2012, at 07:28 , Bert Gunter wrote:
Actually, recycling makes the rep(NA,2) business unnecessary. Simply:
dat1[dat1$x==1 dat1$y==1,1:2] - rep(NA,2)
##or
with(dat1,{dat1[x==1 y==1,1:2] - NA;dat1})
will do it.
Or, use the assignment form of is.na:
cond - with(dat1,
.
- Original Message -
From: Daisy Englert Duursma daisy.duur...@gmail.com
To: r-help@R-project.org r-help@r-project.org
Cc:
Sent: Wednesday, June 6, 2012 11:58 PM
Subject: [R] conditional statement to replace values in dataframe with NA
Hello and thanks for helping.
#some data
L3
Hello and thanks for helping.
#some data
L3 - LETTERS[1:3]
dat1 - data.frame(cbind(x=1, y=rep(1:3,2), fac=sample(L3, 6, replace=TRUE)))
#When x==1 and y==1 I want to replace the 1 values with NA
#I can select the rows I want:
dat2-subset(dat1,x==1 y==1)
#replace the 1 with NA
Have you read An Intro to R? If not,please do so before posting
further. The way you are going about things makes me think you
haven't, but ...
This **is** a slightly tricky application of indexing, if I understand
you correctly. Here are two essentially identical ways to do it, but
the second is
Actually, recycling makes the rep(NA,2) business unnecessary. Simply:
dat1[dat1$x==1 dat1$y==1,1:2] - rep(NA,2)
##or
with(dat1,{dat1[x==1 y==1,1:2] - NA;dat1})
will do it.
-- Bert
On Wed, Jun 6, 2012 at 10:21 PM, Bert Gunter bgun...@gene.com wrote:
Have you read An Intro to R? If
Thanks, problem solved.
On Thu, Jun 7, 2012 at 1:58 PM, Daisy Englert Duursma
daisy.duur...@gmail.com wrote:
Hello and thanks for helping.
#some data
L3 - LETTERS[1:3]
dat1 - data.frame(cbind(x=1, y=rep(1:3,2), fac=sample(L3, 6, replace=TRUE)))
#When x==1 and y==1 I want to replace the 1
Hi All,
I have one difficulty in using the conditional if statement
Assume ,
x - -1:4
x
[1] -1 0 1 2 3 4
if x is lees than want I want to add 1 and I used the following command
if(x0) {x=x+1}
Warning message:
In if (x 0) { :
the condition has length 1 and only the first element
You need ifelse() instead of if().
On Wed, Mar 7, 2012 at 2:12 PM, Val valkr...@gmail.com wrote:
Hi All,
I have one difficulty in using the conditional if statement
Assume ,
x - -1:4
x
[1] -1 0 1 2 3 4
if x is lees than want I want to add 1 and I used the following command
Try
ifelse( x 0, x + 1, x)
[1] 0 0 1 2 3 4
See also ?ifelse.
HTH,
Jorge.-
On Wed, Mar 7, 2012 at 2:12 PM, Val wrote:
Hi All,
I have one difficulty in using the conditional if statement
Assume ,
x - -1:4
x
[1] -1 0 1 2 3 4
if x is lees than want I want to add 1 and I used
The simplest method would be:
x[x0] - x[x0]+1
x - -1:4
x
# [1] -1 0 1 2 3 4
x[x0] - x[x0]+1
x
# [1] 0 0 1 2 3 4
I think where Val got confused is in thinking that
if(x0)
is applied separately to each element of x, one at a time.
What actually happens, of course, is that
x - -1:4
x0 # returns TRUE (1) or FALSE (0)
[1] TRUE FALSE FALSE FALSE FALSE FALSE
x+as.numeric(x0)
[1] 0 0 1 2 3 4
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
Now I got results as I wanted.
Thank you all.
On Wed, Mar 7, 2012 at 2:51 PM, AAsk aa2e...@lycos.co.uk wrote:
x - -1:4
x0 # returns TRUE (1) or FALSE (0)
[1] TRUE FALSE FALSE FALSE FALSE FALSE
x+as.numeric(x0)
[1] 0 0 1 2 3 4
__
I want to perform two if functions at the same time:
if(home team away team home team = away team + 7) in R but i am
struggling to work out how to write this correctly.
Thanks for any help.
--
View this message in context:
Hi kerry1912,
And what exactly would you like to do after the if(...) statement? How did
you read your data in? What's the output of str(yourdata)? Please see
http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.htmland
help us to help you.
Regards,
Jorge
On
On Jan 30, 2012, at 9:52 AM, kerry1912 wrote:
I want to perform two if functions at the same time:
if(home team away team home team = away team + 7) in R but i am
struggling to work out how to write this correctly.
Generally newcomers to the R language find that the ifelse function
does
Sorry that post was written in a bit if a rush.
I am writing a function in which I am trying to create a league table from a
data frame of rugby matches with the columns as follows: home team, away
team, home score and away score.
In rugby you can get an extra bonus point if you are the losing
Nested if's are fine in R, but as David said you probably want
ifelse(). This sounds sufficiently homework-y that I'm hesitant to
give example code but it's all over the archives.
Just to head off a problem I see in your pesudo-code; you're going to
want to use ifelse() to construct the points
On 24.12.2011 12:03, reena wrote:
It didn't work. :(
What did not work???
Please do not misuse the R-help mailing list! Its posting guide clearly
asks you to cite the thread and specify reproducible examples that make
other able to help.
Best,
Uwe Ligges
--
View this message in
Hello again.
I don't understand what didn't work.
First, it seems better to use 'nrow', the result is the same
stopifnot(length(x[,1]) == nrow(x))
Then your multiple OR condition.
#if((x[i,1] || x[i,2] || x[i,3] || x[i,4]) 5)
x - matrix(1:24, ncol=4)
for(i in 1:nrow(x))
This is almost Circle 8.1.7 of
'The R Inferno':
http://www.burns-stat.com/pages/Tutor/R_inferno.pdf
but is making the mistake in the
other direction.
On 23/12/2011 22:40, reena wrote:
Hello,
I want to do fisher test for the rows in data file which has value less than
5 otherwise chi square
It didn't work. :(
--
View this message in context:
http://r.789695.n4.nabble.com/if-statement-problem-tp4230026p4230933.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
Hello,
I want to do fisher test for the rows in data file which has value less than
5 otherwise chi square test .The p values from both test should be stored in
one resulted file. but there is some problem with bold if statement. I don't
know how
implement this line properly.
x =
reena wrote
Hello,
I want to do fisher test for the rows in data file which has value less
than 5 otherwise chi square test .The p values from both test should be
stored in one resulted file. but there is some problem with bold if
statement. I don't know how
implement this line
Hello everyone,
I have a (small) issue. I already googled a lot, so I decided to use ifelse
instead of if (){} else{}
All the elements seem to work seperately, but combined in the ifelse
statement, it doesn't seem to work.
#The price function is a function which is normally distributed with
Hi,
You've got several things going on here.
On Mon, Jul 11, 2011 at 3:39 PM, fre fre_stam...@hotmail.com wrote:
Hello everyone,
I have a (small) issue. I already googled a lot, so I decided to use ifelse
instead of if (){} else{}
All the elements seem to work seperately, but combined in
Hi,
I am having some problems using the if statement correctly. I have used it
many times previously so I dona't know what is different with this case.
Here is my problem:
I have a 1X10 matrix of values as follows:
H.MC
[,1]
[1,] 4.257669
[2,] 7.023242
[3,] 4.949857
[4,]
Hi,
matrix has a 2 dimensions.
Is this work:
a-matrix(rep(c(1,2),c(5,5)),ncol=1)
dim(a)
for (i in 1:10)
{
ifelse(a[i,]==1, a[i,]-runif(1,3,4.5), a[i,])
}
a
Andrija
On Tue, Mar 8, 2011 at 1:07 PM, dpender d.pende...@research.gla.ac.ukwrote:
Hi,
I am having some problems using the if
On Mar 8, 2011, at 7:07 AM, dpender wrote:
Hi,
I am having some problems using the if statement correctly. I have
used it
many times previously so I dona't know what is different with this
case.
Here is my problem:
I have a 1X10 matrix of values as follows:
H.MC
[,1]
[1,]
On Tue, Mar 08, 2011 at 04:07:03AM -0800, dpender wrote:
Hi,
I am having some problems using the if statement correctly. I have used it
many times previously so I dona't know what is different with this case.
Here is my problem:
I have a 1X10 matrix of values as follows:
H.MC
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of dpender
Sent: Tuesday, March 08, 2011 4:07 AM
To: r-help@r-project.org
Subject: [R] If Statement
Hi,
I am having some problems using the if statement correctly.
I have
Hi R helpers,
I am trying to use the if statement to generate a truncated random variable
as follows:
if (y[i]==0) { v[i] ~ rnorm(1,0,1) | (-inf ,0) }
if (y[i]==1) { v[i] ~ rnorm(1,0,1) | (0, inf) }
I guess I cannot use | ( , ) to restrict the range of a variable in R.
Could you let me know
25 oktober 2010 2:01
To: r-help@r-project.org
Subject: [R] if statement and truncated distribution
Hi R helpers,
I am trying to use the if statement to generate a truncated random variable
as follows:
if (y[i]==0) { v[i] ~ rnorm(1,0,1) | (-inf ,0) }
if (y[i]==1) { v[i] ~ rnorm(1,0,1) | (0, inf
Price
2010-10-11 99
2010-10-12101
2010-10-13102
2010-10-14103
2010-10-15 99
2010-10-18 98
2010-10-19 97
2010-10-20101
2010-10-21101
2010-10-22101
I have this dataset and I only want to return instances when the Price is
100.
If I use
Need to understand how 'indexing' is done in R:
x - read.table(textConnection( Price
+ 2010-10-11 99
+ 2010-10-12101
+ 2010-10-13102
+ 2010-10-14103
+ 2010-10-15 99
+ 2010-10-18 98
+ 2010-10-19 97
+ 2010-10-20101
+ 2010-10-21101
+ 2010-10-22
Hi Jay,
If x is your data, you could use subset() to do what you want:
subset(x, Price 100)
See ?subset for more information.
HTH,
Jorge
On Sat, Oct 23, 2010 at 9:56 PM, Jason Kwok wrote:
Price
2010-10-11 99
2010-10-12101
2010-10-13102
2010-10-14103
Thanks for the help Jim.
As a new user and member of this mailing list, I'm very impressed with all
the support!
Jay
On Sat, Oct 23, 2010 at 10:21 PM, jim holtman jholt...@gmail.com wrote:
Need to understand how 'indexing' is done in R:
x - read.table(textConnection(
Thanks Jorge. It works.
Is there a way to keep the actual price in the price column instead of
TRUE/FALSE but filtering on when price100?
Thanks,
Jay
On Sat, Oct 23, 2010 at 10:37 PM, Jorge Ivan Velez jorgeivanve...@gmail.com
wrote:
Hi Jay,
If x is your data, you could use subset() to do
On Oct 23, 2010, at 7:44 PM, Jason Kwok wrote:
Thanks Jorge. It works.
Is there a way to keep the actual price in the price column instead of
TRUE/FALSE but filtering on when price100?
Huh? When I use subset I get what you ask for:
subset(x, Price 100)
Price
2010-10-12 101
I'm unable to find the OR operator like other language .. any suggestions?
I want to do If (condition1 OR condition 2){ do something }
Thanks for answering this elementary question.
[[alternative HTML version deleted]]
__
Hi Santosh,
I believe you are looking for |. For example:
if(3 5 | 3 4) {print(TRUE)}
Cheers,
Josh
On Fri, Oct 22, 2010 at 12:51 AM, Santosh Srinivas
santosh.srini...@gmail.com wrote:
I'm unable to find the OR operator like other language .. any suggestions?
I want to do If (condition1
Joshua Wiley wrote:
Hi Santosh,
I believe you are looking for |. For example:
if(3 5 | 3 4) {print(TRUE)}
In an if () statement you use || more often. | is a vector operator
that always evaluates both arguments; || is a scalar operator that quits
if the left hand argument determines
Santosh Srinivas santosh.srini...@gmail.com writes:
I'm unable to find the OR operator like other language .. any suggestions?
I want to do If (condition1 OR condition 2){ do something }
if((condition1) | (condition2)){ do something }
--
aleblanc
Dear list,
I have a question I'm trying to use the following command in R, but it gives
me an error message.The command is:
data-ddply(data,c(year,name), transform, check1=ifelse(check1==1
check2==1, 1,NULL))
so in my data frame I already have the check1 variable, if the conditions
Hi,
Not sure since I've never done it, but shouldn't it be NA instead of NULL?
Ivan
Le 9/17/2010 15:23, n.via...@libero.it a écrit :
Dear list,
I have a question I'm trying to use the following command in R, but it gives
me an error message.The command is:
data-ddply(data,c(year,name),
I have the following code:
-
result - matrix(NA, nrow=1, ncol=5)
for(i in 1:(nsnp-1)) {
for(j in (i+1):nsnp){
tempsnp1 - data.lme[,i]
tempsnp2 - data.lme[,j]
fm1 -
Sounds like you want
help(tryCatch) # Catch the error and do something
help(next) # Go to the next value of the surrounding loop
Hope this helps a little.
Allan
On 31/08/10 19:34, karena wrote:
I have the following code:
these seem something that I am looking for, I will try them, thank you!!
--
View this message in context:
http://r.789695.n4.nabble.com/any-statement-equals-to-goto-tp2402107p2402264.html
Sent from the R help mailing list archive at Nabble.com.
__
Hi, I am a newbie of R, and playing with the ifelse statement.
I have the following codes:
## first,
for(i in 1:3) {
for(j in 2:4) {
cor.temp - cor(iris.allnum[,i], iris.allnum[,j])
if(i==1 j==2) corr.iris - cor.temp
else corr.iris - c(corr.iris, cor.temp)
}
}
this code is working fine.
I
On 07/07/2010 5:58 PM, karena wrote:
Hi, I am a newbie of R, and playing with the ifelse statement.
I have the following codes:
## first,
for(i in 1:3) {
for(j in 2:4) {
cor.temp - cor(iris.allnum[,i], iris.allnum[,j])
if(i==1 j==2) corr.iris - cor.temp
else corr.iris - c(corr.iris, cor.temp)
On Wed, Jul 7, 2010 at 7:22 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote:
On 07/07/2010 5:58 PM, karena wrote:
Hi, I am a newbie of R, and playing with the ifelse statement.
I have the following codes:
## first,
for(i in 1:3) {
for(j in 2:4) {
cor.temp - cor(iris.allnum[,i],
On 07/07/2010 7:32 PM, Gabor Grothendieck wrote:
On Wed, Jul 7, 2010 at 7:22 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote:
On 07/07/2010 5:58 PM, karena wrote:
Hi, I am a newbie of R, and playing with the ifelse statement.
I have the following codes:
## first,
for(i in 1:3) {
On 2010-07-08, at 10:33 , Duncan Murdoch wrote:
On 07/07/2010 7:32 PM, Gabor Grothendieck wrote:
On Wed, Jul 7, 2010 at 7:22 PM, Duncan Murdoch murdoch.dun...@gmail.com
wrote:
On 07/07/2010 5:58 PM, karena wrote:
Hi, I am a newbie of R, and playing with the ifelse statement.
I
that makes sense. thank you, guys!
--
View this message in context:
http://r.789695.n4.nabble.com/ifelse-statement-tp2281576p2281706.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
1 - 100 of 141 matches
Mail list logo