'Dynamic R objects using apply functions
I've got a long R code now and I'm trying to make it more readable.
Below is a small chunk from my code -
U2OverlayG1 <- GrowthorDiff(U2Overlay, Metadata, 1)
U1OverlayG1 <- GrowthorDiff(U1Overlay, Metadata, 1)
BLOverlayG1 <- GrowthorDiff(BLOverlay, Metadata, 1)
D1OverlayG1 <- GrowthorDiff(D1Overlay, Metadata, 1)
D2OverlayG1 <- GrowthorDiff(D2Overlay, Metadata, 1)
U2G1 <- GrowthorDiff(U2, Metadata, 1)
U1G1 <- GrowthorDiff(U1, Metadata, 1)
BLG1 <- GrowthorDiff(BL, Metadata, 1)
D1G1 <- GrowthorDiff(D1, Metadata, 1)
D2G1 <- GrowthorDiff(D2, Metadata, 1)
As you'd observe, there is a lot of repetition and I'm wondering if this could be automated using apply functions or a better way (if there exists one). When I try creating dynamic objects using the paste/paste0 function, it returns a string rather than an object. Similarly, I want dynamic objects in both LHS and RHS, i.e., D2G1 and D2 (parameter of function GrowthorDiff) should be dynamic. Any help is much appreciated
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
