similar to: how to divide data by week

Displaying 20 results from an estimated 2000 matches similar to: "how to divide data by week"

2012 Apr 17
1
Summary about how to divide data by week
Thank you to Ozgur, who gave me the hints for an easy solution. There are the commands that work for my case: mean(my_dataframe$Freq[my_dataframe$month == 5 & my_dataframe$day %in% c(1:7)]) mean(my_dataframe$Freq[my_dataframe$month == 5 & my_dataframe$day %in% c(8:14)]) ... Stefano Sofia PhD This is the original message: Dear list users, I have a data frame as below specified. From
2018 Mar 21
0
Sum of columns of a data frame equal to NA when all the elements are NA
Should not the result be NULL if you have removed the NA with na.rm=TRUE ? B. > On Mar 21, 2018, at 11:44 AM, Stefano Sofia <stefano.sofia at regione.marche.it> wrote: > > Dear list users, > let me ask you this trivial question. I worked on that for a long time, by now. > Suppose to have a data frame with NAs and to sum some columns with rowSums: > > df <-
2018 Mar 21
0
Sum of columns of a data frame equal to NA when all the elements are NA
On 21/03/2018 11:44 AM, Stefano Sofia wrote: > Dear list users, > let me ask you this trivial question. I worked on that for a long time, by now. > Suppose to have a data frame with NAs and to sum some columns with rowSums: > > df <- data.frame(A = runif(10), B = runif(10), C = rnorm(10)) > df[1, ] <- NA > rowSums(df[ , which(names(df) %in%
2011 Feb 21
1
Query: matrix definition
Dear list users, if within a function I first define a matrix mymat <- matrix(NA, nrow=m, ncol=n) and somewhere afterwards by mistake mymat <- c(1,2,3) this second command deletes the first one. How can I make sure that within the function mymat will always remain the matrix defined at the beginning, without possibility of changing it throughout the code? Secondly, is it possible to define
2013 Apr 15
1
use of simulate.Arima (forecast package)
I would like to simulate some SARIMA models, e.g. a SARIMA (1,0,1)(1,0,1)[4] process. I installed the package 'forecast', where the function simulate.Arima should do what I am trying to do. I am not able to understand how it works Could somebody help me with an example? thank you Stefano Sofia AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu? contenere informazioni
2013 Apr 02
2
Create a vector without using an external 'if statement'
Dear R-users, suppose I have three dataframes like these df1: mydate min_temp 31032013 12 01042013 8 02042013 -999 df2: mydate min_temp 31032013 10 01042013 11 02042013 14 df3: mydate min_temp 31032013 4 01042013 3 02042013 5 where -999 means that the temperature data is not available (at the moment I cannot change it to NA because I am not the db administrator); suppose also that oggi is
2012 Feb 22
2
Query: list within a list
Dear R users, I have difficulty to create a list within a list. Example: with > A <- vector(mode="list", 4) I create a list of 4 elements: > A [[1]] NULL [[2]] NULL [[3]] NULL [[4]] NULL In each element of this list I can store, for example, a matrix: A[[1]] <- matrix ... I need each element of A to be a list (all the lists of the same length), and then store matrices
2018 Mar 21
0
Sum of columns of a data frame equal to NA when all the elements are NA
Surely the result of summation of non-existent values is not defined, is it not? And since the NA values have been _removed_, there's nothing left to sum over. In fact, pretending the the result in that case is zero would appear audacious, no? Cheers, Boris > On Mar 21, 2018, at 12:58 PM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote: > > What do you mean by
2016 Apr 11
2
Query about use of format in strptime
Dear Jim and dear Enrico, thank you for your replies. Unfortunately your hints didn't solve my problem, and I am getting mad. Can I show you my whole process? I will be as quick as possible. I start from a data frame called Snow of the form year month day hh mm hs 2007 11 19 0 0 0.00 2007 11 19 0 30 0.00 2007 11 19 1 0 0.00 2007 11 19 1 30 0.00 2007 11 19 2 0 0.00 2007 11 19 2 30 0.00 2007 11
2023 May 13
2
aggregate wind direction data with wind speed required
Dear list users, I have to aggregate wind direction data (wd) using a function that requires also a second input variable, wind speed (ws). This is the function that I need to use: my_fun <- function(wd1, ws1){ u_component <- -ws1*sin(2*pi*wd1/360) v_component <- -ws1*cos(2*pi*wd1/360) mean_u <- mean(u_component, na.rm=T) mean_v <- mean(v_component, na.rm=T) mean_wd
2016 Apr 11
0
Query about use of format in strptime
Hi Stefano, As the help page says: "The default for the format methods is "%Y-%m-%d %H:%M:%S" if any element has a time component which is not midnight, and "%Y-%m-%d" otherwise. This is because when the result is printed, it uses the default format. If you want a specified output representation: format(strptime(init_day, format="%Y-%m-%d-%H-%M"),"%Y-%M-%d
2023 May 13
1
aggregate wind direction data with wind speed required
?s 15:51 de 13/05/2023, Stefano Sofia escreveu: > Dear list users, > > I have to aggregate wind direction data (wd) using a function that requires also a second input variable, wind speed (ws). > > This is the function that I need to use: > > > my_fun <- function(wd1, ws1){ > > u_component <- -ws1*sin(2*pi*wd1/360) > v_component <-
2018 Mar 21
0
Sum of columns of a data frame equal to NA when all the elements are NA
I see: consistency with additive identity. That makes sense. Thanks. B. > On Mar 21, 2018, at 1:22 PM, peter dalgaard <pdalgd at gmail.com> wrote: > > No. The empty sum is zero. Adding it to another sum should not change it. Nothing audacious about that. This is consistent; other definitions just cause trouble. > > -pd > >> On 21 Mar 2018, at 18:05 , Boris
2018 Mar 21
5
Sum of columns of a data frame equal to NA when all the elements are NA
Dear list users, let me ask you this trivial question. I worked on that for a long time, by now. Suppose to have a data frame with NAs and to sum some columns with rowSums: df <- data.frame(A = runif(10), B = runif(10), C = rnorm(10)) df[1, ] <- NA rowSums(df[ , which(names(df) %in% c("A","B"))], na.rm=T) If all the elements of the selected columns are NA, rowSums
2018 Mar 21
3
Sum of columns of a data frame equal to NA when all the elements are NA
What do you mean by "should not"? NULL means "missing object" in R. The result of the sum function is always expected to be numeric... so NA_real or NA_integer could make sense as possible return values. But you cannot compute on NULL so no, that doesn't work. See the note under the "Value" section of ?sum as to why zero is returned when all inputs are removed.
2018 Mar 21
2
Sum of columns of a data frame equal to NA when all the elements are NA
No. The empty sum is zero. Adding it to another sum should not change it. Nothing audacious about that. This is consistent; other definitions just cause trouble. -pd > On 21 Mar 2018, at 18:05 , Boris Steipe <boris.steipe at utoronto.ca> wrote: > > Surely the result of summation of non-existent values is not defined, is it not? And since the NA values have been _removed_,
2016 Apr 11
3
Query about use of format in strptime
Dear R-list users, I need to use strptime because I have to deal with date with hours and minutes. I read the manual for strptime and I also looked at many examples, but when I try to apply it to my code, I always encounter some problems. I try to change the default format, with no success. Why? How can I change the format? 1. init_day <- as.factor("2015-02-24-00-30")
2011 Sep 30
0
two simple questions about MCMCpoissonChange
Dear R users, two quick questions about MCMCpoissonChange of the MCMCpack: 1. my data is stored into a vector (e.g. my_data), and as input for MCMCpoissonChange I need either a formula or a data frame. If I simply transform my vector to a data frame with data.frame(my_data), it does not work. If I use the formula my_data~1, then I get the following error: 'You have to prior for lambda (c0 and
2018 Mar 21
1
Sum of columns of a data frame equal to NA when all the elements are NA
"I see: consistency with additive identity. " Ummm, well: > 1+NULL numeric(0) > sum(1,NULL) [1] 1 Of course, there could well be something here I don't get, but that doesn't look very consistent to me. However, as I said privately, so long as the corner case behavior is documented, which it is, I don't care. Cheers, Bert Bert Gunter "The trouble with
2017 Nov 23
0
How to produce rainfall maps
Thank you Sarah and Mike for your explanations. My final objective is to produce maps (png image or any kind of extension I can import in LaTeX) where rainfall data are interpolated, using the Inverse Distance method or Kriging. My input file (pointfile.csv in the reported example) reports the station code, lat and long of the meteorological station and the rainfall value (which might be the