On Nov 10, 2012, at 2:07 PM, scoyoc wrote:
> I want my for loop to test for the presence of a term in a vector and return
> a value to a new vector. I'm not writing it correctly though. Here's what I
> have...
>
>> testfor = letters[1:5]
>> x = c("a", "b", "e", "f", "g")
>> result = rep(NA, leng
I want my for loop to test for the presence of a term in a vector and return
a value to a new vector. I'm not writing it correctly though. Here's what I
have...
> testfor = letters[1:5]
> x = c("a", "b", "e", "f", "g")
> result = rep(NA, length(testfor))
>
> for (i in testfor){
+ v = any(x == t
34 2946 2010 2.251
-Original Message-
From: arun [mailto:smartpink...@yahoo.com]
Sent: Tuesday, October 30, 2012 1:57 PM
To: Meredith, Christy S -FS
Cc: R help; William Dunlap
Subject: Re: [R] help with for loop: new column giving count of observation for
each SITEID
HI,
You c
Message -
> From: William Dunlap
> To: "Meredith, Christy S -FS"
> Cc: "r-help@r-project.org"
> Sent: Tuesday, October 30, 2012 3:43 PM
> Subject: Re: [R] help with for loop: new column giving count of observation
> for each SITEID
>
> Your data w
;
Cc: "r-help@r-project.org"
Sent: Tuesday, October 30, 2012 3:43 PM
Subject: Re: [R] help with for loop: new column giving count of observation for
each SITEID
Your data was, in R-readable format (from dput())
d <- data.frame(
RchID = 1:9,
site = factor(c(&qu
20021
> 8 C 20032
> 9 C 20043
>
>
> Thanks so much for you help!
>
> -Original Message-
> From: William Dunlap [mailto:wdun...@tibco.com]
> Sent: Tuesday, October 30, 2012 1:07 PM
> To: Meredith, Christy S -FS; r-help@R-proje
Software
wdunlap tibco.com
> -Original Message-----
> From: Meredith, Christy S -FS [mailto:csmered...@fs.fed.us]
> Sent: Tuesday, October 30, 2012 12:20 PM
> To: William Dunlap
> Subject: RE: [R] help with for loop: new column giving count of observation
> for each
>
, Christy S -FS; r-help@R-project.org
Subject: RE: [R] help with for loop: new column giving count of observation for
each SITEID
Is this what you want?
> withinGroupIndex <- function(group, ...) ave(integer(length(group)), group,
..., FUN=seq_along)
> site <- c("A",
.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of Meredith, Christy S -FS
> Sent: Tuesday, October 30, 2012 11:17 AM
> To: r-help@R-project.org
> Subject: [R] help with for loop: new column giving count of observation for
> each SITEID
>
>
> Hello,
> I think th
Hello,
I think this is easy, but I can't seem to find a good way to do this in the R
help. I have a list of sites, with multiple years of data for each site id. I
want to create a new column that gives a number describing whether it is the
1st year ("1" ) the data was collected for the site, th
elp-boun...@r-project.org] On
Behalf Of jim holtman
Sent: Friday, January 01, 2010 5:25 PM
To: Rafael Moral
Cc: r-help
Subject: Re: [R] help with for loop
Look at your function; it is returning exactly what you are asking for:
x.dif <- c(diff(my.vec), diff(my.vec, lag=i)) # the first and last values
Y
diff.zoo in the zoo package can take a vector of lags:
library(zoo)
z <- zoo(seq(10)^2)
diff(z, 1:4)
There are three vignettes (pdf documents) that come with zoo that have
more info on the package.
On Fri, Jan 1, 2010 at 8:16 PM, Rafael Moral
wrote:
> Dear useRs,
>
> I want to write a function
Look at your function; it is returning exactly what you are asking for:
x.dif <- c(diff(my.vec), diff(my.vec, lag=i)) # the first and last values
You probably want something like this:
dif <- function(my.vec) {
x.diff <- diff(my.vec)
for(i in 2:(length(my.vec)-1)) {
x.dif <- c(x.diff, diff(my.v
Dear useRs,
I want to write a function that generates all the possible combinations of
diff().
Example:
If my vector has length 5, I need the diff() until lag=4 ->
c(diff(my.vec), diff(my.vec, lag=2), diff(my.vec, lag=3), diff(my.vec, lag=4))
If it has length 4, I need until lag=3 ->
c(diff(my.
On Sep 14, 2009, at 5:14 PM,
wrote:
thank you all for your help. I do know how to use which() but my
problem is that I am writing a function in which this is just part
of it. After seeing the (a-b)[bfor which is negative and which is positive.
Can you explain what you mean? There are
e...@msn.com
> Cell Phone: 510-371-4717
>
>
>
>
> --
> From: www...@gmail.com
> Date: Mon, 14 Sep 2009 16:35:23 -0300
> Subject: Re: [R] Help with for loop
> To: dwinsem...@comcast.net
> CC: jorgeivanve...@gmail.com; r-help@r-project.org; edche...@gmail.com
>
>
> Or:
thank you all for your help. I do know how to use which() but my problem is
that I am writing a function in which this is just part of it. After seeing the
(a-b)[b wrote:
On Sep 14, 2009, at 3:02 PM, Jorge Ivan Velez wrote:
Hi Edward,
Here is a suggestion:
a = c(4,5,1,7,8,12,39)
b =
Or:
(a - b)[b < a]
On Mon, Sep 14, 2009 at 4:16 PM, David Winsemius wrote:
>
> On Sep 14, 2009, at 3:02 PM, Jorge Ivan Velez wrote:
>
> Hi Edward,
>> Here is a suggestion:
>>
>> a = c(4,5,1,7,8,12,39)
>> b = c(3,7,8,4,7,25,78)
>> d <- a-b
>> d[which(d>0)]
>> # [1] 1 3 1
>>
>
> #Or even:
> d <-
On Sep 14, 2009, at 3:02 PM, Jorge Ivan Velez wrote:
Hi Edward,
Here is a suggestion:
a = c(4,5,1,7,8,12,39)
b = c(3,7,8,4,7,25,78)
d <- a-b
d[which(d>0)]
# [1] 1 3 1
#Or even:
d <- (a-b)[which((a-b)>0)]
d
#[1] 1 3 1
HTH,
Jorge
On Mon, Sep 14, 2009 at 2:50 PM, Edward Chen
wrote:
Hi Edward,
Here is a suggestion:
a = c(4,5,1,7,8,12,39)
b = c(3,7,8,4,7,25,78)
d <- a-b
d[which(d>0)]
# [1] 1 3 1
HTH,
Jorge
On Mon, Sep 14, 2009 at 2:50 PM, Edward Chen wrote:
> I have a code:
> *a = c(4,5,1,7,8,12,39)
> b = c(3,7,8,4,7,25,78)
> d =a-b
> for(i in 1:length(d)){
> if(d[i]>0){x
, 78)
d <- a - b
which(d > 0)
Erik
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Edward Chen
Sent: Monday, September 14, 2009 1:50 PM
To: r-help@r-project.org
Subject: [R] Help with for loop
I have a code:
*a = c(
I have a code:
*a = c(4,5,1,7,8,12,39)
b = c(3,7,8,4,7,25,78)
d =a-b
for(i in 1:length(d)){
if(d[i]>0){x = list(d[i])
print(x)}
else{y = list(d[i])
print(y)}}
the results are:
[[1]]
[1] 1
[[1]]
[1] -2
[[1]]
[1] -7
[[1]]
[1] 3
[[1]]
[1] 1
[[1]]
[1] -13
[[1]]
[1] -39
which will tell me what
Hi,
On Sep 11, 2009, at 6:35 PM, Edward Chen wrote:
example code:
P = function(whichday,columns){
y = which(pvalue[,whichday]0){
#diffbig = meandayxx0)
x[i] = raw_urine[x_index[i],1]
dayx[i]= raw_urine[x_index[i],day1_ind]
dayy[i] = raw_urine[x_index[i],columns]
jpeg("test 1.jpg",width=800, hei
example code:
P = function(whichday,columns){
y = which(pvalue[,whichday]0){
#diffbig = meandayxx0)
x[i] = raw_urine[x_index[i],1]
dayx[i]= raw_urine[x_index[i],day1_ind]
dayy[i] = raw_urine[x_index[i],columns]
jpeg("test 1.jpg",width=800, height = 800)
matplot(x[i],dayx[i],lwd = 3,pch=1,col = "bla
24 matches
Mail list logo