goeg | Source code for the book
kandi X-RAY | goeg Summary
kandi X-RAY | goeg Summary
Programming in Go by Mark Summerfield. Copyright 2011-12 Qtrac Ltd. All the programs, packages, and associated files in this archive are licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License. You can get a copy of the License at: (The License is also included in this archive in file LICENSE-2.0.txt.). Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. All the book's examples are designed to be educational, and many are also designed to be useful. I hope that you find them helpful, and are perhaps able to use some of them as starting points for your own projects.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- drawLine draws a line .
- makeSizerFunc returns a function that returns the function s dimensions .
- TarFileList returns a list of files named by filename .
- ssizer returns the width and height of an image
- americanise reads from inFile and writes to outFile .
- GOMAXPROCS gompile command line args .
- utf16toutf8 reads utf8 bytes from infile .
- CommonPathPrefix returns the common prefix of paths .
- readPlsPlaylist parses a pls playlist
- size images .
goeg Key Features
goeg Examples and Code Snippets
Community Discussions
Trending Discussions on goeg
QUESTION
I am trying to create the adstock effect for some variable (adstock is defined as value of the previous observation + value of previous observation*adstock rate). I have a table abc that has two columns: GEOG (A, B ,C) and GRPs (1 to 6) for a total of 18 observations. I would like to create a variable b by taking the first obs of the first GEOG and adstocking it by say .5. Then when I get to the first obs of the second GEOG, reinitialize it=to GRPs and do it again. I created a code that works really well with only one geography. But I cannot figure out how to do it BY geography. Coming from a different statistical language, I am still wrapping my head around the way R works. Can anyone help? Thanks in advance. Here is the code that works for one GOEG:
...ANSWER
Answered 2017-Jul-03 at 07:17transfo <- function(df, rate1 = 0.5, rate2 = 0) {
b <- df[["a"]]
for (i in seq_along(b)) {
if (i == 2) {
b[i] <- b[i] + rate1 * b[i-1]
} else if (i > 2) {
b[i] <- b[i] + rate1 * b[i-1] + rate2 * b[i-2]
}
}
df[["b"]] <- b
df
}
abc %>%
group_by(GEOG) %>%
nest() %>%
mutate(data = map(data, transfo)) %>%
unnest(data)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install goeg
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page