similar to: running count in data.frame

Displaying 20 results from an estimated 10000 matches similar to: "running count in data.frame"

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 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
2008 Mar 31
2
Mouse motion example - help
Hi, I am trying out this example adapted from the wxpython book, but the mouse motion event does not seem to be captured right. What am I doing wrong? Thanks warrior # code below require ''wx'' class MyFrame < Wx::Frame def initialize super(nil, -1, "My Frame", :size => [300,300]) @my_panel = Wx::Panel.new(self, -1) evt_motion(){ |event|
2016 Mar 30
2
Compute the Gini coefficient
Hello, I would like to build a Lorenz curve and calculate a Gini coefficient in order to find how much parasites does the top 20% most infected hosts support. Here is my data set: Number of parasites per host: parasites = c(0,1,2,3,4,5,6,7,8,9,10) Number of hosts associated with each number of parasites given above: hosts = c(18,20,28,19,16,10,3,1,0,0,0) To represent the Lorenz curve: I
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",
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
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
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
2005 Aug 17
7
Volunteer requested: Implement SplitterWindow
About a year ago (ouch!), Robert Carlin submitted a ported version of the wxPython demo/sample. I hoped to include it in wxruby2, but it relies on SplitterWindow, which isn''t in wxruby2 yet. I tried to implement SplitterWindow myself, but got such strange results that I''m thinking I did something wrong. Even though the generated C++ code specified a variable number of
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
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),
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),
2012 Nov 27
5
loop with date
Hello, I tried to construct my very first loop today and completly failed :-( Maybe someone can help me? I have a dataframe somewhat like this one: myframe <- data.frame (Timestamp=c("24.09.2012 09:00", "24.09.2012 10:00", "24.09.2012 11:00", "25.09.2012 09:00", "25.09.2012 10:00", "25.09.2012
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"),
2012 Apr 24
2
Combined grouped and stacked bargraph
Dear R list, I am having some trouble drawing a bar-graph with two groups, both of which are stacked. A sample of my data (IUCN and national conservation status for marine and terrestrial species) look like this: Status IUCN Terrestrial IUCN Marine National CS Terrestrial National CS Marine NE 168 69 16 69 LC 41 6 148 6 NT 5 4 7 4 VU 4 2 7 2 EN 4 2 4 2 CR 1
2010 Jul 12
1
S4 class extends "data.frame", getDataPart sees "list"
R-Devel: When I get the data part of an S4 class that contains="data.frame", it gives me a list, even when the "data.frame" is the S4 version: > d<-data.frame(x=1:3) > isS4(d) [1] FALSE # of course > dS4<-new("data.frame",d) > isS4(dS4) [1] TRUE # ok > class(dS4) [1] "data.frame"
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"),
2012 Jul 02
2
Constructing a list using a function...
Hi All I have a dataframe: myframe<-data.frame(ID=c("first","second"),x=c(1,2),y=c(3,4)) And I have a function myfun: myfun<-function(x,y) x+y I would like to write a function myfun2 that takes myframe and myfun as parameters and returns a list as below: mylist $first [1] 4 $second [2] 6 Could you please help me with this? Doesn't seem like the
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
2005 Apr 03
4
BusyCursor probs in 0.6
The new block version of BusyCursor doesn''t work for me -- some actions in between the { braces } do not get carried out. To illustrate, I have taken the nothing.rbw sample app, and added a couple of lines to it, so the full code now reads: require ''wxruby'' include Wx class MyFrame < Wx::Frame def initialize(title) super(nil, -1, title) end end class