Replies: 3 comments
-
|
For an example of what I am talking about : addWindDirStrength<-function(location = "Arras", windMatch,
windLocCol = location, windDirCol, windStrengthCol){
windDir<-eval(substitute(fsubset(windMatch, windLocCol==location, windLocCol, windDirCol, windStrengthCol)))
return(windDir)
}
winDS<-data.frame(
location = c("Arras", "Angers"),
windDir1 = c("SE", "NE"),
windDir2 = c ("NW", "N"),
windStrength1 = c("weak", "weak"),
windStrength2 = c( "very weak", "moderate")
)
addWindDirStrength(
location = "Arras",
windMatch = windMatch, windLocCol = location,
windDirCol = windDir1, windStrengthCol = windStrength1)
var1Name<-"windStrength1"
as.name(var1Name)
addWindDirStrength(
location = "Arras",
windMatch = windMatch, windLocCol = location,
windDirCol = windDir1, windStrengthCol = as.name(var1Name))The first example works, but if I get the column name through a string, I do not know how to pass it ! |
Beta Was this translation helpful? Give feedback.
-
|
It seems that Works. Would it be the proper way to do it (is this your way to do it)? |
Beta Was this translation helpful? Give feedback.
-
|
Sorry, this slipped my attention. Please read section 3.2 of the arXiv article. There are efficient ways to program without NSE or metaprogramming in collapse. In your case, you could use |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
First of all thank you for this very useful package.
I read the documentation, and every thing is great when analyzing data via scripts.
But I'm trying to use collapse functions inside functions of a package I'm building to analyze my data, and I don't know how to do this in an efficient way. Using eval, substitute, quoting and arsing seems quite tedious compared to standard evaluation with base R.
Data.table developed the env notion within the use of brackets. What is the best way to proceed with collapse when trying to code a package ?
If some authors or users of collapse would like to show some examples where variable names are passed as arguments of a function which uses fsubset, for instance, I would be rather grateful.
Beta Was this translation helpful? Give feedback.
All reactions