Description Usage Arguments Value Examples
View source: R/dssDeriveColumn.R
The new column is calculated from a formula that can contain arithmetic operators and a (very) limited number of R functions. At the moment the permitted functions are: abs, round, ceiling, floor, trunc, signif, length, as.Date, as.character, as.numeric. The administators of remote nodes can make more functions available with a procedure described in the help of the function .init in the package dsSwissKnife (?dsSwissKnife:::.init)
1 2 3 4 5 6 7 8 |
df |
a character, the name of the dataframe |
formula |
a character, the formula used to calculate the new column. It can reference columns from the dataframe, or other objects in the session |
datasources |
same as in datashield.assign |
async |
same as in datashield.assign |
wait |
same as in datashield.assign |
new.col |
a character, the name of the new column |
It doesn't return anything, the dataframe in the server session will now contain the new column.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # open a local pseudo connection:
opals <- dssCreatePseudoServers(servers = 1, tie_first_to_GlobalEnv = TRUE)
data('iris')
#now play around:
dssDeriveColumn('iris', 'new_col', 'Sepal.Length/round(2.2)', datasources = opals)
str(iris)
dssDeriveColumn('iris', 'new_col2', 'iris$Sepal.Length/abs(-2)', datasources = opals)
str(iris)
a <- iris$Petal.Length
dssDeriveColumn('iris', 'new_col3', 'a/abs(-2)', datasources = opals)
str(iris)
# this will fail:
dssDeriveColumn('iris', 'new_col', 'Sepal.Length[1]', datasources = opals)
# as will this
dssDeriveColumn('iris', 'new_col', 'rnorm(length(iris$Sepal.Length), mean = mean(iris$Sepal.Length),1)', datasources = opals)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.