> On Jan 8, 2017, at 9:21 PM, Cacique Samurai wrote:
>
> Hello all!
>
> I´m trying to complete the "movimento" column in dataframe based in
> the values of "kmr" column in two sequential lines, as below:
>
> data example (dput in the end of email):
>
> IDkmr movimento
> 510.70
est.s)
test
but assigned in this case is not factor but numeric vector, which seems to me
strange. Maybe somebody could explain this behaviour
Cheers
Petr
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Cacique
> Samurai
> Sent: Monday, Ja
Hello all!
I´m trying to complete the "movimento" column in dataframe based in
the values of "kmr" column in two sequential lines, as below:
data example (dput in the end of email):
IDkmr movimento
510.700 314.20NA
110.700 278.74NA
210.700 278.74N
Hi,
May be this helps:
set.seed(24)
dat1<- data.frame(ID=1:500,value=rnorm(500))
res<- split(dat1,dat1$ID%%2)
A.K.
- Original Message -
From: ravi.raghava1
To: r-help@r-project.org
Cc:
Sent: Wednesday, July 31, 2013 3:46 AM
Subject: [R] Using If loop in R how to extract even a
Hello,
Who told you you need a loop or an if?
even <- function(x) x %% 2 == 0
x <- 1:50
idx <- even(x)
x[idx]
Hope this helps,
Rui Barradas
Em 31-07-2013 08:46, ravi.raghava1 escreveu:
I have 500 ids ; i want to take out even and odd ids separately and store it
another data files.
How can
I have 500 ids ; i want to take out even and odd ids separately and store it
another data files.
How can it be done in R by using *If and for loop* ??
--
View this message in context:
http://r.789695.n4.nabble.com/Using-If-loop-in-R-how-to-extract-even-and-odd-ids-tp4672707.html
Sent from the
HI,
May be this:
RiskTest<-ifelse(EvHint==1 & MinTex==1,1,0)
RiskTest
# [1] 0 0 0 1 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0
A.K.
- Original Message -
From: Virgile Capo-Chichi
To: r-help@r-project.org
Cc:
Sent: Tuesday, November 20, 2012 2:08 PM
Subject: [R] Using if
Dear R users,
A
8 a.m.
To: Virgile Capo-Chichi; r-help@r-project.org
Subject: Re: [R] Using if
?ifelse
Quite distinct from if () {} else {}.
---
Jeff NewmillerThe . . Go Live...
DCN:Basics: ##.
Try this (convert the logical TRUE to the value 1):
> EvHint<-c(0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0)
> MinTex<-c(0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0)
>
> RiskTest <- (EvHint == 1 & MinTex == 1) + 0L
> rbind(EvHint, MinTex, RiskTest)
[,1] [,2]
; Behalf
> Of Virgile Capo-Chichi
> Sent: Tuesday, November 20, 2012 11:09 AM
> To: r-help@r-project.org
> Subject: [R] Using if
>
> Dear R users,
>
> As a new comer to R, I would like to create a new variable using if
> statements but don't know how to do it. Basical
Hi,
Thanks for providing a reproducible example.
On Tue, Nov 20, 2012 at 2:08 PM, Virgile Capo-Chichi
wrote:
> Dear R users,
>
> As a new comer to R, I would like to create a new variable using if
> statements but don't know how to do it. Basically, I have two variables
> (EvHint and MinTex). I
?ifelse
Quite distinct from if () {} else {}.
---
Jeff NewmillerThe . . Go Live...
DCN:Basics: ##.#. ##.#. Live Go...
Live: OO#.
Dear R users,
As a new comer to R, I would like to create a new variable using if
statements but don't know how to do it. Basically, I have two variables
(EvHint and MinTex). I want to create a third variable called RiskTest.
In SPSS, my syntax would look like
Compute RiskTest=0.
if (EvHint=1 &
Hello,
Your example code has a bug, there's no fata.frame called 'AB'. It's
corrected below.
pannigh wrote
>
> Dear list,
> I get the ifelse function to work on a data frame but don't know how to do
> something similar (only more conditions) with the combination of if and
> else like in the exa
Dear list,
I get the ifelse function to work on a data frame but don't know how to do
something similar (only more conditions) with the combination of if and else
like in the example:
A <- c("a","a","b","b","c","c")
B <- c(rep(2,6))
dat <- data.frame(A,B)
dat$C <- if(AB$A=="a") {AB$B^2} else
On Aug 10, 2011, at 7:34 PM, Ward, Michael Patrick wrote:
I used this service several months ago and was very pleased with the
response.
I have a dataframe with several thousand lines and to each line I
need to apply a series of "if else" statements. For each row I need
either a value
Mike,
One thing I noticed that '&&' should be replaced by '&'. The former is
applied to the first element of the vector while the latter applicable
to the whole vector.
HTH
Weidong Gu
On Wed, Aug 10, 2011 at 7:34 PM, Ward, Michael Patrick
wrote:
>
> I used this service several months ago and
I used this service several months ago and was very pleased with the response.
I have a dataframe with several thousand lines and to each line I need to apply
a series of "if else" statements. For each row I need either a value or a
blank/NA. Below is the series of if else statements I have bee
Hi ,
I have a data set with recurrence time (up to four) of myocardial infarction
(MI).
Part of the file is showing below:
Num1Trt Sex TimeT1 T2 T3 T4
10111 1 9
12110 1 59
On 28/06/2010 5:50 AM, Etienne Stockhausen wrote:
Hello everybody,
I'm trying to use a if-statment on a function. For a better
understanding I want to present a small example:
FUN=mean # could also be median,sd or
any other function
if (FUN == mean)
You could also consider
isTRUE(all.equal(FUN, mean))
> isTRUE(all.equal(mean, mean))
[1] TRUE
> isTRUE(all.equal(mean, median))
[1] FALSE
HTH
Keith J
"Patrick Burns" wrote in message
news:4c28777f.1040...@pburns.seanet.com...
> If I understand the problem properly,
> you want something li
If I understand the problem properly,
you want something like this:
function(FUN, ...)
{
FunName <- deparse(substitute(FUN))
if(FunName == "mean") {
...
} else if(FunName == "median") {
...
}
}
Using 'switch' is an alternative to 'i
Hello everybody,
I'm trying to use a if-statment on a function. For a better
understanding I want to present a small example:
FUN=mean # could also be median,sd or
any other function
if (FUN == mean)
plot(...)
if (FUN == median)
plot(...)
On Mon, Aug 11, 2008 at 08:23:19AM +1200, Gareth Campbell wrote:
> Hey team,
>
> If I have a matrix:
>
> 1, 2,
> 3, 4,
> 4, 0,
> 1, 3,
> 0, 3
>
> 2 columns.
>
> I want to write an if command that looks at (in this case) row 3 and looks
> to see if either [3,1] or [3,2] has a zero in it. IF it
Hey team,
If I have a matrix:
1, 2,
3, 4,
4, 0,
1, 3,
0, 3
2 columns.
I want to write an if command that looks at (in this case) row 3 and looks
to see if either [3,1] or [3,2] has a zero in it. IF it does have a zero I
want the zero to be placed in another matrix in the same position. I know
t;wed","thu","fri","sat","sun")
my.df$NewAdm <- my.df$admissions * weight[as.character(my.df$d.o.w)]
my.df
Gabriela
- Original Message -----
From: "Robin Williams" <[EMAIL PROTECTED]>
To:
Sent: Wednesday, July 23, 2008 12:44
Just to clarify,
if you have two data.frame, one with your data, other with data-admissions,
just use
data.merge<-merge(my.df, data.weigth, by.x="data", by.y="data", all=T)
miltinho
On 7/23/08, milton ruser <[EMAIL PROTECTED]> wrote:
>
> Hi Rob Williams
>
> I think it is one way of you do the j
Hi Rob Williams
I think it is one way of you do the job.
Cheers,
miltinho astronauta
brazil
my.df<-data.frame(cbind(data=sample(c("mon","sat","sun"), 20, replace=T),
values=rnorm(20)))
my.df$values<-as.numeric(my.df$values)
data.weigth<-read.table(stdin(), head=T, sep=",")
data,weigt
atistical package. Any
code much appreciated.
-Original Message-
From: Patrick Burns [mailto:[EMAIL PROTECTED]
Sent: 23 July 2008 17:44
To: Robin Williams
Subject: Re: [R] Using if, else statements
You might have found 'ifelse' in S Poetry, which
is one way of solving your problem.
One more try and I quit: This is what happens if someone does not
sent a sample of data you have to create things on the fly without
testing.
days <- list(list("Sat", 1.21), list("Sun", 1.22), list("Mon", 0.91))
for (i in days){
.subset <- data$d.o.w == i[[1]] # subset of data that matches
My fingers slipped on the keyboard. Here what they intended to write.
This sets up a list of the data and the matches on a subset for
processing
days <- list(list("Sat", 1.21), list("Sun", 1.22), list("Mon", 0.91))
for (i in days){
.subset <- data$d.o.w == i[[1]] # subset of data that matc
You would have something that looks like this:
if (data$d.o.w == "Sat") data$admission <- round(data$admission * 1.21)
if (data$d.o.w == "Sun") ...
On Wed, Jul 23, 2008 at 11:44 AM, Robin Williams <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Again I have searched the net and so on, without find
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,
33 matches
Mail list logo