Thanks alot B77S. That was a critical post.
--
View this message in context:
http://r.789695.n4.nabble.com/if-else-statements-in-data-frame-tp3454646p3455077.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailin
Thanks for the answers. They were very helpful. I did it like below.
data$z <- ifelse(data$x == "A" & data$y == "A", "NA", "B").
That is enough for today. I guess I learned a enough today. Thanks to
everbody who tried to help.
--
View this message in context:
http://r.789695.n4.nabble.com/i
Hi ozgrerg,
I am not a "good" R user, but according to me you can do this;
data <- data.frame(x=c("A","A","B","A"), y=c("A","B","B","B"))
for (i in 1:nrow(data)){
if(data$x[i]=="B"||data$y[i]=="B") z[i]=c("B")
else
z[i]=c("NA")
}
cbind(data,z)
--
View this message in context:
http://r.789695.n
Dear R experts, I have again a problem. Let I have a data frame like below:
x y
--
A A
A B
B B
A B
where x and y are the column names. I want to create a new column z where it
is elements
will be like that, if at each row has there at least one 'B', then z wi
tj wrote:
>
> Thanks Sam for the short but very helpful answer. That's what I only want
> to know.
> Thanks.=)
>
> ~tj
>
Even though you got the answer you were looking for, I would still browse
the material Matthew posted. The "Introduction to R" is a standard R manual
that helped me g
Thanks Sam for the short but very helpful answer. That's what I only want to
know.
Thanks.=)
~tj
--
View this message in context:
http://n4.nabble.com/If-else-statements-tp1678705p1679187.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version
The short answer is yes, you can, but your syntax is wrong. You need
to make sure you wrap your conditions inside brackets, and use {, not
(, to delineate your if statements.
> for (v in 1:6) {
> for (i in 2:200) {
> if (v==1){
if (max(x*v-y*v)>1)
break()
}
}
}
et cetera
On Tue, M
Thanks Matthew... I will read your suggested articles/files.
I hope, i will be able to figure out what should be done with this.
=)
~tj
--
View this message in context:
http://n4.nabble.com/If-else-statements-tp1678705p1679073.html
Sent from the R help mailing list archive at Nabble.com.
___
Here are some references. Please read these first and post again if you are
still stuck after reading them. If you do post again, we will need x and y.
1. Introduction to R : 9.2.1 Conditional execution: if statements.
2. R Language Definition : 3.2 Control structures.
3. R for beginners by E Par
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 b
10 matches
Mail list logo