Recode a character variable based on a string index - character

I feel like this should be simple, but I couldn't find any solutions out there that I could understand. I am trying to index a character variable and recode it into a cleaned character variable.
Example:
Title <-c("Regional Administrator", "Regional Administrator Region 1", "Deputy Regional Administrator")
df<-ra_survey(Title)
df$Title[df$Title INCLUDES "Regional Administrator] <- "Regional Administrator"

Related

TMLanguage, what does captures do?

I am working on a tm language project for vscode and I'm wondering what the captures property on a pattern does exactly.
I can't seem to figure out what the indexes of the captures object stand for and I can't find any information on it online.
Example:
{
"match": "(group 1)(group2)"
"captures": {
"0": {
"name": "Name of first capture group? What does 0 mean here?"
}
}
}
The "captures" key is documented here, in the "Rule Keys" section (12.3):
https://macromates.com/manual/en/language_grammars
The name is not the name of the first capture group. It is just a string that specifies the name of the style to apply to the characters that were matched by that capture group. When I say "capture group", I am referring to a matching left paren and right paren in your regular expression.
Using the "captures" key is a relatively complex way to assign style names to characters in the document. It allows you to specify different styles to different portions of the text matched by the regular expression. A simpler way is to just use the "name" key, which will apply the style to all of the matched text.

Is There a Way to do a Spanish/English MailMerge?

I have an SSRS report that has Spanish and English text boxes. If the dataset row is a Spanish speaking person, an expression in each Spanish textbox shows that and hides the English textbox. These textboxes are exactly placed over each other.
My boss wants me to use SSRS to generate an Excel spreadsheet from the dataset(this is not hard) and use Word template for a mail merge. However, I am having trouble trying to figure out if I can hide all English when row is a Spanish row and vice versa. These are health clients of Spanish and English nationality.
I can do mail merges attached to a Recordset, I can do one in English, one in Spanish. I am trying to avoid this and have it all in one Mail Merge.
Areas marked in red will change to Spanish translation and/or date format. The dates are a no-brainer I can use a conditional IIF, however the formatted body I have no solution for, based on value in Field "CL_Language" which is either "Spanish" or "English".
====================================
The merge fields for dates and greeting are easy. There is no merge field for the text. And yes, only option might be for 2 separate reports with different Recordsets.
It's not clear what the actual issue is but...
Instead of hiding textboxes, which could cause problems when exporting etc., why not set a single textbox to the correct language text using an expression?
Something along the lines of
=IIF(Fields!Language.Value = "English", Fields!MyEnglishText.Value, FieldsMySpanishText.Value)
I found a solution. But it could be very difficult for the client to create. It involves hitting Ctrl + F9 which will create curly brackets {}.
Inside those curly brackets an IF statement is placed and I just pasted the whole Spanish formatted body in the true area, and the whole English body in the false area.
{IF "CL_Language" = "Spanish" "spanish body text here" "english body text here"}
Very strange syntax and you need to right click on the area to see choices like "Toggle Field Codes" (IF statement get's hidden), "Edit Field", and "Update Field". With Edit Field and Update Field you get a popup with the fields in your recordset.
If you saw the examples in my question, you can see that is some big clunky text AND . . .inside of it is a merge field that works! The Excel recordset comes already with the month name in correct language for each row.
Since it is not smart to include links that might expire, I am including the Google text I used to find this solution. Then I took a chance on a huge formatted chunk of text with a merge field inside of it.
Google this: "If Merge Field then"
Now is this a viable solution for the client versus just having a Word template for each language?
I think this is too difficult and I even duck when running it. Also, once it's working, if I look at the toggled code, the Conditional field no longer says the field name, but the value in the field, go figure.
{IF "Spanish" = "Spanish" or {IF "English" = "Spanish" instead of {IF "CL_Language" = "Spanish" or {IF "CL_Language" = "English"
Here is how to access the fields using right click. (remember, your curly brackets HAVE to be created with Control + F9).

Word Vba : how to get the name of a style in foreign language

"Heading 2" style in French is "Titre 2": how to get "Titre 2" knowing "Heading 2" ?
I searched on Google and found this
https://msdn.microsoft.com/en-us/vba/word-vba/articles/style-namelocal-property-word
Unfortunately that's not what I want.
When working with the built-in styles always use the enumeration. The code below will print the localized name of Heading 2 to the Immediate window.
Debug.Print ActiveDocument.Styles(wdStyleHeading2).NameLocal
https://msdn.microsoft.com/en-us/vba/word-vba/articles/wdbuiltinstyle-enumeration-word
Also, when your document is going international, and you are using chapter names in the header or footer, don't use
{ StyleRef "Heading 1" }
because when the document is shown in a German MS Word, it wouldn't understand "Heading" but expect "Überschrift" instead.
However, there's an international version, too. Just use
{ StyleRef 1 }
without quotes around the heading number.
You can't reference "Titre 2" as "Heading 2". Instead, see 'WdBuiltinStyle Enumeration'. Knowing these constants for the most part means you don't need to know the local names and, when you do, you can retrieve them via .NameLocal.
See also 'WdListNumberStyle Enumeration', 'WdCaptionNumberStyle Enumeration', 'WdNoteNumberStyle Enumeration', 'WdApplyQuickStyleSets Enumeration', and 'WdStyleType Enumeration' in the Word VBA help file.

Replace 2 terms in one go?

Happy eclipse mars user here.
I often copy & paste code from one class file to another. Next i replace keywords with new keywords, for example i replace:
User with Box
user with box
I use "find and replace" dialog (CTRL+F) to do the replace.
Now i enter "User" in "Find" field and "Box" in "replace with" field, and next i do the same with "user" and "box".
Is it possible to replace "User" with "Box" and "user" with "box" in one go?
you can not do "find and replace" in one go as eclipse support reg expression in find string , but not in replace string.
Better you do it by refactoring or you can do "find and replace" one by one by keeping Case sensitive check on.

How to prevent "."(dot) from cancelling autocomplete in Sublime Text 2?

I have defined some keywords for a proprietary language I use at work:
{ "match": "\\b(util.tickettimelimit|util.user_ip|util.server_name|util.today)\\b",
"name": "keyword.source.GTX2",
"comment": "Tags"
}
I also have a completion file:
{
"scope": "source.GTX2",
"completions":
[
"util.server_name",
"util.tickettimelimit",
"util.today",
"util.user_ip"
]
}
When I start typing "util" I see the correct autocomplete options:
But as soon as I enter the "."(dot) autocomplete options go away:
Is there a way to change this behavior? I just want the keywords to be trated as a whole thing and ignore the dots.
Thanks!
I've looked everywhere I can, and it seems the auto-complete code is embedded within the executable itself (at least on Windows, I haven't checked my Mac yet), and not in one of the numerous external .py files scattered around, so I can't even see the parameters for how auto-completion is performed. I looked through the default Packages/Default/Preferences.sublime-settings file and while there are several options relating to auto-complete, there are none relating to what we're looking for. While looking through the Default (Windows).sublime-keymap file in the same directory, I tried adding the following:
{ "keys": ["."], "command": "hide_auto_complete", "context":
[
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
},
but alas it didn't work. There are a number of auto_complete commands there, and while this looked the most promising I haven't tried the rest.
I haven't exhaustively looked through the source and config files for the nifty SublimeCodeIntel plugin (also available through Package Control), so it's possible you might be able to find an option there. You'd probably have to completely disable the built-in auto-complete functionality first, so it doesn't override SCI.
So, I guess for now there's not much you can do. You can always leave a feature request and see if it makes it into Sublime Text 3, or search/open a thread on the Sublime Text Forum and see if anyone else has any suggestions. Good luck!
What I think #Ashish is alluding to is the word_separators setting. You will want to create a syntax specific preference (Preferences -> Settings - More -> Syntax Specific - User). Create a word_separators entry with the dot removed (Copy from the default preferences as the base). This will give you the behavior you want but there are some things to note. The dot, obviously, will not be treated as a word separator, which will change some behavior.
I'll use java as an example. If I had a variable foo, with some method bar, I could enter foo.b and bar would be shown as a completion. Without the dot as a separator, you will not see this.
Another example, perhaps easier to understand is when selecting words. If you use ctrl/cmd + d to select the word, it selects words, bound by word separators. So if I had foo.ba|r, where the | represents the cursor position and used ctrl/cmd+d it would select bar. With the dot removed as a word separator, foo.bar would be selected.
Let me know if I can clarify anything.
It's a little late but I hope this can help, create a new plugin and add this code:
import re
myObjects = {"util": ["server", "tickettimelimit", "today", "user_ip"]}
class CustomAutocomplete(sublime_plugin.EventListener):
def on_query_completions(self, view, prefix, locations):
if not view.match_selector(0, "source.GTX2"):
return
if prefix == "":
# get the last word in the current line
currentposition = view.sel()[0].begin()
currentline = view.full_line(currentposition)
text = view.substr(currentline)
words = re.findall("\w+", text)
lastword = words[-1]
if lastword in myObjects.keys():
# return a list of tuples, it represents snippets
# the first element is the trigger and the second one
# is the content
return [(x, x) for x in myObjects[lastword]]
return []
And add the next key in the user settings:
"auto_complete_triggers":
[
{
"characters": ".",
"selector": "source.GTX2"
}
]
Don't press . (dot) else you will need to type at least one character after dot so list can appear again. Using Brackets or Dot tells Sublime Text 2 that user has completed typing.
example: if I type for then sublime will show dropdown list but if I type for( list will disappear.
Click on Preferences > Settings - User, then copy and paste the following
// Characters that are considered to separate words – does not include periods.
// Place comma at the end of the line if there are multiple keybindings.
"word_separators": "/\\()\"‘-:,;~!##$%^&*|+=[]{}`~?"
From this webpage:
http://tomschenkjr.net/using-sublime-text-2-for-r/