similar to: ?max (so far...)

Displaying 20 results from an estimated 1000 matches similar to: "?max (so far...)"

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
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
2010 Jun 09
2
Help needed on "switch" function
Hi all, Here I am trying to implement the switch() function to choose value of a variable depending on the value of an input variable :   temp1 <- "1"               temp1.name <- switch(temp1,                                   1 == "aa",                                   2 == "bb",                                   3 == "cc",
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
2009 Feb 11
2
sorting a matrix by the column
this is a bad question but I can't figure it out and i've tried. if i sort the 2 column matrix , temp1, by the first column, then things work as expected. But, if I sort the 1 column matrix, temp2, then it gets turned coerced to a vector. I realize that I need to use drop=FALSE but i've put it in a few different places with no success. Thanks. temp1 <-
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
2009 Feb 11
2
error in my previous message
i'm sorry. i had an error in my previous code because i left out a letter in the rownames. while fixing that, i also found a solution. so i'm sorry for the confusion. below is my fix. temp2 <- matrix(rnorm(10),nc=1,nrow=10) rownames(temp2) <-
2006 Jan 04
3
matrix math
I am using R 2.1.1 in an windows XP environment. I have 2 dataframes, temp1 and temp2. Each dataframe has 20 variables (“cocolumns") and 525 observations (“rows”). All variables are numeric. I want to create a new dataframe that also has 20 columns and 525 rows. The values in this dataframe should be the sum of the 2 other dataframe. (i.e. temp1$column
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),
2009 May 15
4
replace "%" with "\%"
Dear all, I'm trying to gsub() "%" with "\%" with no obvious success. > temp1 <- c("mean", "sd", "0%", "25%", "50%", "75%", "100%") > temp1 [1] "mean" "sd" "0%" "25%" "50%" "75%" "100%" > gsub("%",
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),
2005 May 20
4
issues with identical()
Hi all, hope you having a nice day, I ahve this weird results with identical (probably I am not understanding correctly what it does ...) I have these two data frames and I issue : > identical(temp, temp1) [1] FALSE However, these data frames are Nx2 and when I issue: > identical(temp[,2], temp1[,2]) [1] TRUE > identical(temp[,1], temp1[,1]) [1] TRUE and the results from str >
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
2013 Mar 29
1
multiple plots and looping assistance requested (single plot)
HI Irucka, Please check this: temp<- structure(list(`:Bostoncitydata` = structure(list(Month = c(1L, 2L, 3L, NA), Data1 = c(1.5, 12.3, 11.4, NA), Data2 = c(9.1342, 12.31, 3.5, NA)), .Names = c("Month", "Data1", "Data2"), class = "data.frame", row.names = c(NA, -4L)), `:Chicagocitydata` = structure(list(Month = c(1L, 2L, 3L, 4L, 5L, NA), Data1 = c(1.52,
2011 Mar 09
2
Anomaly with unique and match
I stumbled onto this working on an update to coxph. The last 6 lines below are the question, the rest create a test data set. tmt585% R R version 2.12.2 (2011-02-25) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-unknown-linux-gnu (64-bit) # Lines of code from survival/tests/singtest.R > library(survival) Loading required package: splines
2008 Aug 26
1
parse and eval character vector
Dear R-help, I have a character vector, some elements will be numeric, some not, and some even empty. E.g.: temp1 <- c("abcd"," 2 ","") I'm only interested in the numeric elements, the rest I can just throw away. It is easy enough to loop through the vector: temp <- try(eval(parse(text=temp1[1])), silent=TRUE); class(temp) # try-error temp <-
2012 Oct 31
2
Aggregate Table Data into Cell Frequencies
R-help - I have this set of aggregated tables (sample data below via dput()). And I would like to have delayValue as the column variables with the "temp" (temp1, temp2, temp3) values as the row variables. However I would like to have the temp variables *aggregated into single rows* so that I have the frequency ("Freq" | counts) of each time each "delayValue" occurs