Displaying 20 results from an estimated 500 matches similar to: "loop with date"
2012 Oct 25
2
mean of a value of the last 2 hours
Hello,
I have a data frame somewhat like that:
myframe <- data.frame (ID=c("Ernie", "Ernie", "Ernie", "Bert", "Bert",
"Bert"), Timestamp=c("24.09.2012 09:00", "24.09.2012 10:00", "24.09.2012
11:00"), Hunger=c(1,1,1,2,2,1) )
myframestime <- as.POSIXct (strptime(as.character(myframe$Timestamp),
2012 Dec 17
2
calculate a "rolling mean" including standard deviation
Hello everyone,
I have a data frame somewhat like this one:
myframe <- data.frame (Timestamp=c( "24.09.2012 06:00", "24.09.2012 07:00",
"24.09.2012 08:00",
"24.09.2012 09:00", "24.09.2012 10:00",
"24.09.2012 11:00",
"24.09.2012 12:00",
2012 Dec 07
0
apply a function at: dateX, dateX+1, dateX+2, ....
Dear knowing people,
Dennis Murphy helped me a lot with my first loop last week. Thanks again - I
could have made more than 10 "Thank-You cakes" in the time it saved me!
But now I want to complicate the thing. My ideas didn't work. Let's see if
anyone is smarter ;-)
The following packages are needed:
library(adehabitatHR)
library(rgdal)
library(plyr)
# My dataframe looks
2012 Sep 26
2
average environmental data if AnimalID and Time is duplicated
Hello,
I tried for about three hours now to solve this problem but I can't figure
it out. I am sure someone knows how do it. At least I hope so.
I have a data frame somewhat like this:
myframe <- data.frame (ID=c("Ernie", "Ernie", "Bert", "Bert"),
Timestamp=c("24.09.2012 09:00", "24.09.2012 09:00", "24.09.2012 10:00",
2017 Aug 19
4
My very first loop!! I failed. May I have some start-up aid?
Dear all,
I have a data similar to this:
myframe<- data.frame (ID=c("Ernie", "Ernie","Ernie","Ernie"),
Timestamp=c("24.09.2012 08:00", "24.09.2012 09:00", "24.09.2012 10:00",
"25.09.2012 10:00"), Longitude=c("8.481","8.482","8.483","8.481"),
2017 Aug 19
0
My very first loop!! I failed. May I have some start-up aid?
Thank you for providing the example code... for the request of running it
multiple times it would have helped if you could have confirmed that the
example ran through without errors... there were a lot of mistakes in it.
Look into using the reprex package to check your example next time.
I don't do this kind of analysis... I really don't know what to expect
from the functions. The
2012 Oct 26
0
mean of a value of the last 2 hours using plyr (Thank you)
Hi dear three helpers,
Thanks a lot! Your solutions worked great. Again I learned a lot.
Tagmarie
Am 25.10.2012 18:36, schrieb Felipe Carrillo:
> Another option using plyr,
> library(plyr)
> myframe <- data.frame (ID=c("Ernie", "Ernie", "Ernie", "Bert", "Bert",
> "Bert"), Timestamp=c("24.09.2012 09:00",
2002 Sep 09
1
multiple "keys" in Trellis plots?
My xyplot has a number of panels, and I'd like a separate key for each
rather than a single key for the entire set. However, I cannot find a way to
pass multiple key definitions to xyplot's "key" argument.
Allow me to throw out a simple example:
require(methods)
require(lattice)
## define sample data
myFrame1 <- data.frame(a=1:100, b=rep(1:10,10), c=unlist(lapply(1:10, rep,
2012 Nov 09
3
if between 500-600 give 550
I have a data frame somewhat like this:
myframe <- data.frame (ID=c(2,3,4,5), Hunger =c(415,452,550,318 ))
myframe
Now I would like to add a column to the right which summarizes the values
for Hunger somewhat to reduce the number of values: If the values for Hunger
are between
300-400 I would like to insert the number 350,
between
400-500 insert 450
between
500-600 insert 550
Does
2017 Aug 19
0
My very first loop!! I failed. May I have some start-up aid?
[answers inline]
On 18 August 2017 at 20:08, Dagmar <Ramgad82 at gmx.net> wrote:
>
> myframe<- data.frame (ID=c("Ernie", "Ernie","Ernie","Ernie"),
> Timestamp=c("24.09.2012 08:00", "24.09.2012 09:00", "24.09.2012 10:00",
> "25.09.2012 10:00"),
2009 Apr 09
2
better way of recoding factors in data frame?
Hi all,
I apologize in advance for the length of this post, but I wanted to make sure I was clear.
I am trying to merge two dataframes that share a number of rows (but some are unique to each data frame). Each row represents a subject in a study. The problem is that sex is coded differently in the two, including the way missing values are represented.
Here is an example of the merged dataframe:
2012 Sep 17
6
count NAs per week
Even though I work with R since a year or so I still struggle with simple
problems. I hope someone can help me with this. Been trying for days and am
a little frustrated now.
I have a data frame somewhat like the one bellow:
dattrial<-data.frame(a=c(1,NA,rnorm(4,10)), Week=c(3,3,3,4,4,4))
I want to know how many NAs I have in week 3 and in week 4.
--
View this message in context:
2009 Jun 30
2
Using functions to change values in a data.frame
I'm having trouble with something that looks easy. (And I'm sure it
will be easier within about 1 minute of receiving my first response.)
Thanks in advance.
I have a collection of data frames that I need to add columns, do some
calculations and then fill in the new columns. Since I have a large
number of similar data frames I want to do this with functions to make
the code more readable
2009 Jul 01
2
?max (so far...)
Hi,
I have a data.frame that is date ordered by row number - earliest
date first and most current last. I want to create a couple of new
columns that show the max and min values from other columns *so far* -
not for the whole data.frame.
It seems this sort of question is really coming from my lack of
understanding about how R intends me to limit myself to portions of a
data.frame. I get the
2009 Jul 01
1
running count in data.frame
Hi,
I need to keep a running count of events that have happened in my
data.frame. I found a document called usingR that had an example of
doing this for random coin flips and I tried to modify it. It seems to
sort of work in the beginning, but then it stops and I don't
understand why. I'm trying to duplicate essentially the Excel
capability of =SUM($A$1:$A(Row number))
The example
2011 Mar 30
2
summing values by week - based on daily dates - but with some dates missing
Dear everybody,
I have the following challenge. I have a data set with 2 subgroups,
dates (days), and corresponding values (see example code below).
Within each subgroup: I need to aggregate (sum) the values by week -
for weeks that start on a Monday (for example, 2008-12-29 was a
Monday).
I find it difficult because I have missing dates in my data - so that
sometimes I don't even have the
2010 Aug 13
3
transforming dates into years
Hello!
If I have in my data frame MyFrame a variable saved as a Date and want
to translate it into years, I currently do it like this using "zoo":
library(zoo)
as.year <- function(x) as.numeric(floor(as.yearmon(x)))
myFrame$year<-as.year(myFrame$date)
Is there a function that would do it directly - like "as.yearmon" -
but for years?
Thank you!
--
Dimitri
2010 Jan 12
3
How to get minimum value by group
I'd like to get a long data set of minimum values from groups in another data
set.
The following almost does what I want. (Note, I'm using the word factor
differently from it's meaning in R; bad choice of words)
myframe = data.frame(factor1 = rep(1:2,each=8), factor2 =
rep(c("a","b"),each=4, times=2), factor3 = rep(c("x","y"),each=2, times=4),
2002 Jul 18
3
Oddity with names
Hi all,
I'm using R 1.5.1 on Windows 2000. The following snippet of code doesn't
seem to do anything - no error is reported, and there is no name change.
names(myFrame[,c(1:3)]) <- c("name1", "name2", "name3")
This code however works nicely:
names(myFrame)[c(1:3)] <- c("name1", "name2", "name3")
Can anyone suggest why
2004 Oct 11
2
question on function argument
dear all,
i've looked at the r-intro (chapter 10, writing your own functions)
and searched the r-help archives but am still stuck at the following.
i have a simple function, something like:
myhist<-function(yvar) {
y<-subset(myframe,yvar>1 & yvar<=150000,select=yvar)
attach(y)
hist(yvar)
}
calling it as follows:
myhist(x1)
gives the following error:
Error in