Setting Data Transformer for $ also makes input $ required - google-app-maker

If you set a data transformer for example: #formatNumber('$#.00')
It then requires you to also use the $ when doing input. Is there a way to not require the $?

Yes, you should be able to just omit the "$" from the format pattern:
formatNumber('#.00')

Related

Can drop=FALSE be passed to $?

I tried `$`(mtcars,cyl,drop=FALSE), but this threw an error. I know that in practice you would use [ or [[ instead, but I'm curious, can drop=FALSE be passed to $?
The $ function doesn't have a drop= parameter. While they are used for similar things, the $ function is distinct from the [ function which does have a drop= parameter.
I'm assuming that you are only interested in the case for using $ with data.frames, but there's actually no special data.frame method for $, it just treats the data.frame like a list. And drop= wouldn't make as much sense in the case of a generic list.

Aside from partial matching, can the $ operator do anything that [ and [[ cannot?

I believe the following to be true of the $ operator:
It allows names to be partially matched. For example, data$Sky can match data$Skywalker if there is no Sky name in use.
It cannot be used for atomic vectors, unlike [ and [[.
It cannot be combine with operators like -. There is no valid syntax like mtcars$-mpg. [ and [[ cannot do this with names either, but mtcars[,-1] works.
It is for names only.
Partial matching aside, for a data frame, data$name is equivalent to data[,"name"] e.g. mtcars$cyl is the same as mtcars[,"cyl"]. I'm pretty sure that data[["name"]] is also equivalent, e.g. mtcars[["cyl"]].
Partial matching aside, for a named list that is not a data frame, data$name is the same as data[["name"]].
Does this mean that if I don't care about partial matching, I can always replace $ with [ or [[? Or is there some functionality that I've missed?
For base R, my best guess comes from the documentation for $. The following quotes are the most relevant:
$ is only valid for recursive objects
$ does not allow computed indices, whereas [[ does. x$name is equivalent to x[["name", exact = FALSE]]. Also, the partial matching behavior of [[ can be controlled using the exact argument.
the default behaviour is to use partial matching only when extracting from recursive objects (except environments) by $. Even in that case, warnings can be switched on by options(warnPartialMatchDollar = TRUE).
So it seems that the documentation confirms my belief that, aside from partial matching, $ is just syntactic sugar. However, there are four points where I am unsure:
I never put too much faith in R's documentation. Because of this, I'm sure that an experienced user will be able to find a hole in what I've said.
I say that this is only my guess for base R because $ is a generic operator and can therefore have its meaning changed by packages, tibbles being a common example.
$ and [ can also be used for environments, but I have never seen anyone do so.
I don't know what "computed indices" are.
According to a book on advanced R, the $ and the [ operator are the same on dataframes (not on lists) except from the partial matching. It states
$ is a shorthand operator: x$y is roughly equivalent to x[["y"]].
...The one important difference between $ and [[ is that $ does
(left-to-right) partial matching:
Here is the quote: Section 4.3.2 of the next link:
https://adv-r.hadley.nz/subsetting.html#section-1

Firebase functions config is truncating my api key string

I am trying to set an environment variable in firebase functions like this:
firebase functions:config:set clientsecret="abc123$efgh"
However, when I use:
firebase functions:config:get
I am seeing all of my settings, but it looks like my clientsecret value is getting truncated after the $ character.
{
"myservice": {
"clientid: "1234567"
"clientsecret": "abc123"
}
}
Is there a way I should be escaping or encoding the $ so the entire string is stored? Thank you for any suggestions!
The problem isn't with Firebase or Cloud Functions. The problem is the $ character. That's a special shell character that takes the letters after it and assumes it's a shell variable. So, your command is telling the shell that you want to insert the value of variable efgh into the command line. Since that variable is probably not defined, you're getting an empty string in its place. So, $efgh is yielding an empty string.
If you want to use $ in a shell command line like this, you're going to have to escape it. There is a lot to know about this. Maybe the easiest thing is to simply escape the $ itself with a backslash:
firebase functions:config:set clientsecret="abc123\$efgh"

parsed-literal with inline highlighting

I'm trying to format an environment variable definition with a few variable parameters that I want to highlight. So I'm using a parsed literal block that includes in-line highlighting:
.. parsed-literal::
$ export MYVAL=http://*<user_name>*:*<user_password>*#127.0.0.1:*<port>*/*<resource>*
I'm expecting each of the bracketed parameters to be italicized, but instead I'm getting some extra asterisks in the output. Is there a better way to do this?
If you add backslash-escaped whitespace before and after #127.0.0.1:, it will work:
$ export MYVAL=http://*<user_name>*:*<user_password>*\ #127.0.0.1:\ *<port>*/*<resource>*
See http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#character-level-inline-markup.

Indexing using $ and arguments?

I am very new to R and trying to figure out how to use indexing with $. If I wanted to add an argument, say drop(), how do I use $ with arguments? I tried:
subset <- mydata_df$variable1[drop=FALSE]
This doesn't seem to work.
If you look at the ?"[.data.frame" help page, you'll see that the $ operator is distinct from the [ operator and only the latter has the drop= argument. Thus the correct syntax for such an extraction is
mydata_df[, "variable1", drop=FALSE]

Resources