Twitter Data API access in RSTUDIO

Get access to the Twitter API:

Create an APP, as documented here:

Annotation 2019-11-05 073528

Click on “Details”, then “Keys and tokens”

Annotation 2019-11-05 073800

(The credentials listed above will not work)

Use the generated credentials as below:

So where did the URL in GET come from?

The API Reference contains these instructions:

Annotation 2019-11-05 080500.png

Coming Soon:

Please follow the blog to get updates!

Projects from COURSERA Data Science Specialization ETA: 10 November 2019

“Simplest Way Possible” series: p-value and R-squared, what they are and how to use them in Data Analysis ETA: 20 November 2019

Oracle OLAP functions overview ETA: 30 November 2019




MySQL Custom Install on Windows Startup Issue

OS: MS Windows 10

MySQL: Developer Computer configuration 8.0

Other: Custom path install, configured to NOT work as a service

Considerations: The software was recently installed, and ran properly when it was started through the installer. Nothing was changed on the installation of the software, but the host has been restarted

Issue: MySQL server will not start through the Workbench, and running


will generate issue with missing data directory. If this data directory is not the correct %Program Data% specified, this means that the mysqld.exe does not have access to configuration file


Solution: Place a copy of file my.ini in the root directory of Windows

(ie "C:\Windows").

Execute mysqld.exe once again and minimize its terminal



xmlTreeParse Fails with error “XML content does not seem to be XML”

Code below is run in RSTUDIO.

  • fileURL is the variable that holds the internet location of the XML file in question
  • doc is the variable to store the output of xmlTreeParse

> fileUrl doc <- xmlTreeParse(fileUrl,useInternal=TRUE)
Error: XML content does not seem to be XML: ‘;

SOLUTION: Install package RCurl and use function getURL on the link to the XML file  first

WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
also installing the dependency ‘bitops’

trying URL ‘;
Content type ‘application/zip’ length 38894 bytes (37 KB)
downloaded 37 KB

trying URL ‘;
Content type ‘application/zip’ length 2968691 bytes (2.8 MB)
downloaded 2.8 MB
> library(RCurl)
Loading required package: bitops
> xData <- getURL (fileUrl)
> doc <- xmlTreeParse(xData)
> doc

[HOWTO] 100% CPU on Windows 10 Home, MSI Gaming Laptop (GP62MVR 7RFX Leopard PRO)

Read just this:

If you have already reset the laptop’s power plan settings, and have set a AUTO fan speed within MSI Dragon Center, probably nothing else needs be done.

Description of problem:

Windows Task Manager shows CPU to be 100% used, most of the load is by a Windows process. The issue occurs on an MSI laptop, which has MSI own management software, such as System Control Manager (SCM) and/or MSI Dragon Center.


MSI’s own applications interact with MS Windows power plans to set up the operating parameters of the system: Fan(s) speed counted in rpm, settings for battery life vs performance, timeouts. WIN10 will also switch power plans when the laptop is getting plugged/unplagged from its charger, which also alters the behavior of the fans. MSI Dragon Center and Windows power management are very tightly knit. Also there seems to be a connection between the power plan and CPU consumption. The more performance oriented is the power plan, the higher the CPU consumption will be. The main finding is that the CPU 100% does not relate to any specific process, but the power plan in effect.

Ways to not see 100% in Task Manager:

Step 1, this is how Task Manager looks now:


…and this is how SCM looks, with Dragon Center installed:



Step 2: Uninstall MSI Dragon Center

…and this is how SCM looks now:


Notice how the section with the different “modes” appeared. Now let’s select any mode other than “ECO off”, and get a screenshot of MS Task Manager





…quite a difference. There is an immediate, notable difference with the fans speed, the laptop becomes immediately quiet. What else has happened?

Right-click on the Windows logo on Your screen, select “Power Options” and at the following screen “Additional power settings”. There, is a new power plan, created by SCM, and named after the selected “mode”, for example mine is called “Gaming”. I tried to compare the detailed configuration of this plan (“Change plan settings”) with the one that is causing the CPU to peak, and i was unable to find the exact parameter that creates the whole issue. In fact, the new power plan is quite “aggressive” in some of its settings (acccessed by “Change plan settings” under Control Panel > Hardware and Sound > Power Options > Edit Plan Settings )


So what now?

With MSI Dragon Center installed again, there is no way to create further SCM power plans. Using the Windows default ones will revert to 100% CPU, but look:



What is correct?

If anybody knows, and feels confident of their Hardware/Windows skills, please leave a comment. For myself, i have decided to leave a less restricted plan for the fans, accepting to see the CPU 100% message, which i somehow thing is not crucial. This, because i am worried that trying to demote the cooling system might affect the well-being of the motherboard of my Leopard. I suppose, the choice is yours.

How to exit Debug Browser in R

This works if you have enabled debugging for a single command/function, and you are not aware how to exit the Browser prompt. To save you the trouble, popular Googles that ask you to f or Q or ESC or q() simply do not work. The behavior of debug command is identical in RStudio and the R prompt, at least in Windows 10 that i tested.

Here are two examples of enabling/disabling debug.

First we use a random sapply command:

> sapply(split(mtcars$mpg, mtcars$cyl), mean)
4 6 8
26.66364 19.74286 15.10000

Now we turn debugging on:

> debug(sapply)

and, as expected, nothing happens until we try to run sapply again:

> sapply(split(mtcars$mpg, mtcars$cyl), mean)
debugging in: sapply(split(mtcars$mpg, mtcars$cyl), mean)
debug: {
FUN <-
answer <- lapply(X = X, FUN = FUN, ...)
if (USE.NAMES && is.character(X) && is.null(names(answer)))
names(answer) <- X if (!isFALSE(simplify) && length(answer)) simplify2array(answer, higher = (simplify == "array")) else answer } Browse[2]>

There are two things to type here. The first is the command undebug(). In this case will be sapply. Then, Q exits the Browser prompt, and we can run the function outside of debug mode again. Let’s see:

Browse[2]> undebug(sapply)
Browse[2]> Q
> sapply(split(mtcars$mpg, mtcars$cyl), mean)
4 6 8
26.66364 19.74286 15.10000

Identically with ls()

[1] "am" "carb" "cyl" "disp" "drat" "gear" "hp" "mpg" "qsec" "vs"
[11] "wt"
> debug(ls)
> ls(mtcars)
debugging in: ls(mtcars)
debug: {
if (!missing(name)) {
pos <- tryCatch(name, error = function(e) e)
if (inherits(pos, "error")) {
name <- substitute(name)
if (!is.character(name))
name <- deparse(name)
warning(gettextf("%s converted to character string",
sQuote(name)), domain = NA)
pos <- name
all.names <- .Internal(ls(envir, all.names, sorted))
if (!missing(pattern)) {
if ((ll <- length(grep("[", pattern, fixed = TRUE))) &&
ll != length(grep("]", pattern, fixed = TRUE))) {
if (pattern == "[") {
pattern <- "\\["
warning("replaced regular expression pattern '[' by '\\\\['")
else if (length(grep("[^\\\\]\\[<-", pattern))) {
pattern <- sub("\\[<-", "\\\\\\[<-",
warning("replaced '[<-' by '\\\\[<-' in regular expression pattern") } } grep(pattern, all.names, value = TRUE) } else all.names }

Browse[2]> Q
> ls(mtcars)
[1] "am" "carb" "cyl" "disp" "drat" "gear" "hp" "mpg" "qsec" "vs"
[11] "wt"