Misunderstanding of functions in R

I have a vector p <- seq(0,1,length=11) That I want to use as the independent variable in the summation If I craft a function that codes the summation by hand f <- function(a){ a^0*(1-a)^5+a^1*(1-a)^4+... } and pass it p, then I get t...
more »

2017-10-04 22:10 (3) Answers

How to sum multiple dataframe's variables by month

I have got a very similar issue addressed here how to sum data by month and store them in the first day of the month The only thing that differs from the above post is that my real data.frame has got 300 variables that need to be grouped and summed...
more »

2017-09-28 10:09 (1) Answers

numpy array sum function

Let's say I have two one dimensional arrays, a and b, of length say n+1 and m+1. I want c to be the an array of the same length as b, with elements equal to the sine of the sum of all a elements to the power b. Written in pseudo code below. c = sum...
more »

2017-09-26 16:09 (2) Answers

Select and show according to the year/monts

can you help me to select, and sum all the values from the table, and show them according to the months/this year? Table looks as follow" | ID | value | reg_date | | 1 | 2 | 2017-01-11 02:26:22 | | 2 | 2 | 2017-03-12 12:22:23 ...
more »

2017-09-21 11:09 (3) Answers

Alternating series using Haskell

I am trying to use Haskell to read in a list and perform an alternating series, so starting with the first element adding every other and subtracting every other from the second element. For instance [1, 2, 3, 4] would be 1-2+3-4=-2. I thought I had...
more »

2017-09-14 21:09 (2) Answers

Different amounts in payment script

I have a payment script. now it works with fixed amounts, for example if the total is 1000 USD and my client wants to pay me with five installments for 200 USD each quota is working perfect. But now I need to know how can I change the code (pdo + MyS...
more »

2017-09-09 03:09 (0) Answers

Django Group_by Date with Sum Data

I need to combing many acct_id's records into a single summary grouped by the "month" field. All the other data like "value" and "cash_in" need to be Sum() class Cashflow ( models.Model ): acct_id = models.ForeignKey ( Acct ) month = models.D...
more »

2017-08-19 08:08 (1) Answers

Calculate sum based on different dates

I'm new to Stackoverflow and I need your help for this problem. I have a table (sql 2014 and use vb.net) like this: ID Codfisc Dal Al 1 xxxxxxx 2017/08/08 2017/08/14 I have developed this code: Dim a As Date = Date.Parse(TextBox2.Te...
more »

2017-08-15 00:08 (0) Answers

conditional sum with dates in column names

Want to calculate conditional sum based on specified dates in r. My sample df is start_date = c("7/24/2017", "7/1/2017", "7/25/2017") end_date = c("7/27/2017", "7/4/2017", "7/28/2017") `7/23/2017` = c(1,5,1) `7/24/2017` = c(2,0,2) `7/25/2017` = c...
more »

2017-08-14 16:08 (3) Answers

Scipy Sparse Cumsum

Suppose I have a scipy.sparse.csr_matrix representing the values below [[0 0 1 2 0 3 0 4] [1 0 0 2 0 3 4 0]] I want to calculate the cumulative sum of non-zero values in-place, which would change the array to: [[0 0 1 3 0 6 0 10] [1 0 0 3 0 6 1...
more »

2017-08-03 21:08 (0) Answers

VBA Sum a Range of Cells

I'm attempting to write a simple VBA macro that will take the active cell's column and the user's input to add a range of cells on a single row together. The range is calculated by adding the integer the user inputs to the active column and that is t...
more »

2017-08-03 17:08 (1) Answers

Large Numpy Scipy CSR Matrix, row wise operation

I want to iterate over the rows of a CSR Matrix and divide each element by the sum of the row, similar to this here: numpy divide row by row sum My problem is that I'm dealing with a large matrix: (96582, 350138) And when applying the operation fr...
more »

2017-07-28 14:07 (2) Answers

Summarize data and keep date column value

I asked a similar question before and got an excellent answer, but needed some more guidance on the topic of summarizing and dates. Summarize and count data in R with dplyr Goal: In my new dataset i have column with dates, when the event occured. W...
more »

2017-07-26 10:07 (2) Answers

Is it possible to skip NA values in "+" operator?

I want to calculate an equation in R. I don't want to use the function sum because it's returning 1 value. I want the full vector of values. x = 1:10 y = c(21:29,NA) x+y [1] 22 24 26 28 30 32 34 36 38 NA x = 1:10 y = c(21:30) x+y [1] 22 24 26 28...
more »

2017-07-25 20:07 (5) Answers

shorten code range array elements

How can I shorten this code? I also tried SUM on a range of array elements but that didn't worked because I don't know the correct syntax. Thanks in advance. Workbooks("items.xlsm").Sheets(1).Cells(r, 107).Value = _ arr(r, 4) + arr(r, 5) + arr(r, 6)...
more »

2017-07-22 20:07 (1) Answers

SUM numbers, but when 0, add 8 instead

I'm trying to write a SUM(IF(zero, add 8), A1:G1) kind of excel function. What it should do: If the cell contains a number, add that number to the sum. If the cell contains a number = 0, add 8 to the sum. if the cell is empty, add nothing to the su...
more »

2017-07-18 12:07 (3) Answers

numpy.sum not returning expected value

I'm working through project euler problems. 'Find the sum of all the primes below two million' I've built a prime checker that I think is pretty fast - any advise on how to improve would be great too. But, what I've spent the last 30mins working ...
more »

2017-06-25 06:06 (1) Answers