Comments (3)
@ervanSTRI,
I noticed some issues that may make your code run much faster. In three places, the code grows objects instead of pre-allocating an object with the required structure (number of columns, rows, list elements, etc.) and then modifying each element in place. See my comments and let me know if it's unclear.
Generally, you can completely avoid this issue with lapply(). If you still need a for loop, then ensure to create an object with all the elements that will later be replaced (instead of created) inside the for loop.
from agbfluxes.
Ok. I now see your code and comments. First question: why does the online version differ from the one I have in my package? I've seen the first occurrence you are referring to, but wonder if it saving a lot of time in filling vs cbind-ing a data-frame. I'll give it a try.
from agbfluxes.
Lines 118, 675, and 845 in AGBfluxes_functions.R.
The source of receiving_df()
is here. This is just a slightly different way to do what you were doing before. Notice that the dataframe it creates has only one row, when instead it should have as many rows as the object you will return. Maybe your need expand.grid()
or similar.
I would start by fixing the receiving data-structure, and checking if it really improves how fast the code runs. If you achieve better performance, then transforming the code to lapply()
(and fridns) won't make it faster -- only more readable. In short, the advantage of lapply()
and friends are these:
- It creates the receiving data-structure internally (so you don't have to do it and you avoid mistakes).
- It is more readable.
To learn more about the transition from for loops to lapply()
and friends see this 12' video: https://youtu.be/GyNqlOjhPCQ
These things are often better shown than explained. But I can't help much until I'm able to run your code and produce an output I can test against. Without that, any change I do may brake something inadvertently. Issue #20 is the priority.
from agbfluxes.
Related Issues (20)
- Create regression tests to allow changing your code confidently HOT 3
- Restructure .R files HOT 3
- Can't install the package HOT 3
- PRIORITY: Help me run data_preparation() HOT 9
- Error in assignWD(df, WD = WD) : object 'WD' not found
- Fix warnings and notes after running devtools::check(). HOT 5
- Join forces to develop taper correction HOT 1
- Extract out functionality to produce side effects
- Give sensible defaults to simplify the interface
- Make the primary input to be the path to the data. HOT 1
- Extract argument as function.
- Remove or rename `df`
- Document changes HOT 5
- Provide documentation as to what this code does HOT 1
- Test styler syntax for data.table
- Integrate work by Mauro and Ervan HOT 1
- Update data/
- Explore likely speed bottleneck
- Failed to build the package HOT 8
- Error: package or namespace load failed for 'AGBfluxes' in namespaceExport(ns, exports) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from agbfluxes.