search for: myfram

Displaying 20 results from an estimated 107 matches for "myfram".

Did you mean: myframe
2009 Jun 30
2
Using functions to change values in a data.frame
...code more readable and ensure that every frame is done the same way. However my simple example doesn't work as I expected it to: Here the R example code to cut and paste. The basic idea is to copy positive values of y into p and negative values into l. <START COPY> AddCols = function (MyFrame) { MyFrame$p<-0 MyFrame$l<-0 return(MyFrame) } BinPosNeg = function (MyFrame) { ifelse(MyFrame$y>0, MyFrame$p<-MyFrame$y, MyFrame$l<MyFrame$y) return(MyFrame) } F1 <- data.frame(x=1:10, y=-4:5) F1 F1 <- AddCols(F1) F1 F1 <- BinPosNeg(F1) F1 <END COPY> My re...
2009 Jul 01
2
?max (so far...)
...ense I can create tempt1[1:7] and the max function returns what I expect. How do I do this with row? Simple example attached. hp should be 'highest p', ll should be 'lowest l'. I get an error message "Error in 1:row : NA/NaN argument" Thanks, Mark AddCols = function (MyFrame) { MyFrame$p<-0 MyFrame$l<-0 MyFrame$pc<-0 MyFrame$lc<-0 MyFrame$pwin<-0 MyFrame$hp<-0 MyFrame$ll<-0 return(MyFrame) } BinPosNeg = function (MyFrame) { ## Positive y in p column, negative y in l column pos <- MyFrame$y > 0 MyFrame$p[pos] <- MyFrame$y[pos]...
2009 Jul 01
1
running count in data.frame
...0 1 2 1 0 1 2 3 4 > cumsum(sample(c(-1,1),20,replace=T)) [1] 1 2 1 0 -1 0 -1 -2 -1 -2 -1 -2 -1 -2 -3 -2 -3 -4 -5 -6 However that example doesn't have to read from the data.frame so I tried to leverage on some earlier help today but it isn't working for me. The goal is the MyFrame$lc keeps a running total of events in the MyFrame$l column, and likewise for $pc and $p. It seems that $lc starts off OK until it gets to a 0 and then resets back to 0 which I don't want. The $pc counter never seems to count. I also get a warning message I don't understand so clearly I'...
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-50...
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", "25.09.2012 10:00"), Hunger=c("1","5","2","2"),...
2011 Mar 30
2
summing values by week - based on daily dates - but with some dates missing
...Thanks a lot for your suggestions! The code is below: Dimitri ### Creating example data set: mydates<-rep(seq(as.Date("2008-12-29"), length = 43, by = "day"),2) myfactor<-c(rep("group.1",43),rep("group.2",43)) set.seed(123) myvalues<-runif(86,0,1) myframe<-data.frame(dates=mydates,group=myfactor,value=myvalues) (myframe) dim(myframe) ## Removing same rows (dates) unsystematically: set.seed(123) removed.group1<-sample(1:43,size=11,replace=F) set.seed(456) removed.group2<-sample(44:86,size=11,replace=F) to.remove<-c(removed.group1,remove...
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&...
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",&q...
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 11:00"), Speed=c(1,1,2,5,1,6))...
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), y=1:16) attach(myframe) minimums = by(y, list(factor1, factor2,factor3), min) detach(myframe) The problem is that "minimums&qu...
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 (strpt...
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 the first doesn't work? Ought an error be reported? Thanks, Andrew An...
2017 Aug 19
0
My very first loop!! I failed. May I have some start-up aid?
...le next time. I don't do this kind of analysis... I really don't know what to expect from the functions. The final step in your sequence produces a vector of sixteen values, not 1 value, nor 4 values, so I don't know how to obtain the 4x3 result you said you expected... I got 16x3. myframe <- data.frame( ID = c( "Ernie", "Ernie","Ernie","Ernie","Ernie","Ernie") , Timestamp = c( "24.09.2012 08:00", "24.09.2012 09:00" , "24.09.2012 10:00&q...
2010 Jul 12
1
S4 class extends "data.frame", getDataPart sees "list"
...# ok > class(dS4) [1] "data.frame" # good attr(,"package") [1] "methods" > setClass("A", representation(label="character"), contains="data.frame") [1] "A" > a<-new("A",dS4, label="myFrame") > getDataPart(a) [[1]] # oh? [1] 1 2 3 > class(a@.Data) [1] "list" # hmm > names(a) [1] "x" # sure, that makes sense > a Object of class "A" x 1 1 2 2 3 3 Slot...
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 attach(y) : attempt to set an attribute on NULL what am i doing wrong here? thanks in advance, edwin
2005 Apr 03
4
BusyCursor probs in 0.6
...ew 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 NothingApp < Wx::App def on_init frame = MyFrame.new("Minimal wxRuby App") frame.show BusyCursor.new { message_box("This is a control sample", "About Controls") } end en...
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 pl...
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", "24.09.2012 10:00", "24.09.2012 > 11:00"), Hunger=c(1,1,1,2,2,1) ) > myframe > myframes...
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| on_move(event)} Wx::StaticText.new(@my_panel, -1, :label => "Pos:", :pos => [10, 12]) @posCtrl = Wx::TextCtrl.ne...
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"), Longitude=c("8.481","8.482","8.48...