grep Exclude Example in R

Just finished a Coursera data science course. In one of the assignments, we need to clean up the weather event types. I was struggling with the grep function. For example, I want to find the event types which have “strong wind” in them, but I want to exclude “marine strong wind”. Finally found one example online, which uses the ?! in Perl to exclude matches. Here is one example:

events <- c("Strong Wind", "Wind", "Marine Strong Wind")
events[grep("^(?=.*strong.wind)", events, = T, perl = T)]
## [1] "Strong Wind"        "Marine Strong Wind"
events[grep("^(?=.*strong.wind)(?!.*marine)", events, = T, perl = T)]
## [1] "Strong Wind"

The first grep function finds any strings with strong wind in them and it finds both “Strong Wind” and “Marine Strong Wind”. In order to exclude the “Marine Strong Wind”, we use (?!.*marine) as part of the argument to the grep function.


How to Delete Previous Version of Windows on Windows 10

After I upgraded my Asus X205TA to Windows 10, I found that I only have a few MB left on the system drive. I had to delete the temporary previous version of Windows to save disk space. The system even reminds you to do so. If you did not see the prompt, follow these instructions:

  1. Click on the Windows button
  2. Type storage
  3. Click on Storage
  4. Click on This PC (C:)
  5. Scroll down and click on Temporary Files
  6. Scroll down and click on Delete previous versions
  7. Click on Delete

If the Storage settings does not appear in the search results. You can click on Windows button and click on Settings. Type storage in the Find a setting box on the top right corner.  After the Storage settings is found, just follow the steps 3 to 7 to delete the previous version of Windows.


How to Refresh or Reset Your PC on Windows 10

There are times when you want to reset your PC. On Windows 8, it’s two different tools. Refresh PC keeps your personal files while Reset PC delete personal files and reset the PC to factory state. On Windows 10, there is one tool called Reset this PC with two options. Here are the steps.

  1. Click on Windows button.
  2. Type reset.
  3. Click on Reset this PC.
  4. Click on Get started.
  5. Click on Keep my files or Remove everything.
  6. Click on Reset.

How to Upgrade to Windows 10 Manually

If you are like me who cannot wait for the notification of Windows 10 download, you can upgrade your Win 7 or 8 machines to Win 10 now. Before you begin, make sure you have at least 16GB of free disk space on a 32bit machine or 20GB for a 64bit machine.

Download the media creation tool from this link.

Double click on the downloaded file and follow the instructions to upgrade your machine.

Windows 10 Activation using Command Line Utility slmgr

Windows 10 uses the same command line utility slmgr as Windows 7 for activation with a MAK (Multiple Activation Key). Follow these simple steps to activate your Windows 10.

  1. Open up an elevated command prompt.
  2. Enter the following
    slmgr -ipk your-mak-key-here
    slmgr -ato

That’s it. To learn more about this command, type the following command.

slmgr /?