Skip to main content

Day 14 Swirl

install.packages("swirl")

https://github.com/swirldev/swirl_courses#swirl-courses

https://en.wikipedia.org/wiki/YAML
http://yaml.org/

| You can exit swirl and return to the R prompt (>) at any time by pressing the Esc key. If you are
| already at the prompt, type bye() to exit and save your progress. When you exit properly, you'll see a
| short message letting you know you've done so.

| When you are at the R prompt (>):
| -- Typing skip() allows you to skip the current question.
| -- Typing play() lets you experiment with R on your own; swirl will ignore what you do...
| -- UNTIL you type nxt() which will regain swirl's attention.
| -- Typing bye() causes swirl to exit. Your progress will be saved.
| -- Typing main() returns you to swirl's main menu.
| -- Typing info() displays these options again.

| Let's get started!

sqrt() function and to take the absolute value, use the abs() function

Vector of unequal length Artihmetic Operations
If the vectors are of different lengths,
| R 'recycles' the shorter vector until it is the same length as the longer vector.
| When we did z * 2 + 100 in our earlier example, z was a vector of length 3, but technically 2
| and 100 are each vectors of length 1.

...

  |==========================================================================                       |  76%

| Behind the scenes, R is 'recycling' the 2 to make a vector of 2s and the 100 to make a vector
| of 100s. In other words, when you ask R to compute z * 2 + 100, what it really computes is
| this: z * c(2, 2, 2) + c(100, 100, 100).


Shortcuts
 In many programming environments, the up arrow will cycle through previous commands. Try
| hitting the up arrow on your keyboard until you get to this command (z * 2 + 100), then
| change 100 to 1000 and hit Enter. If the up arrow doesn't work for you, just type the
| corrected command.

| You can type the first two letters of the variable name, then hit the Tab key (possibly more
| than once). Most programming environments will provide a list of variables that you've
| created that begin with 'my'. This is called auto-completion and can be quite handy when you
| have many variables in your workspace. Give it a try. (If auto-completion doesn't work for
| you, just type my_div and press Enter.)

List all the files in your working directory using list.files() or dir().

Use dir.create() to create a directory in the current working directory called "testdir".

> dir.create("testdir")
Create a file in your working directory called "mytest.R" using the file.create() function.

>
> file.create("mytest.R")
list.files() shows that the directory only contains mytest.R.

> list.files()

| Create a directory in the current working directory called "testdir2" and a subdirectory for
| it called "testdir3", all in one command by using dir.create() and file.path().

> dir.create(file.path('testdir2','testdir3'))
Warning message:
In dir.create(file.path("testdir2", "testdir3")) :
  cannot create dir 'testdir2\testdir3', reason 'No such file or directory'

| You're close...I can feel it! Try it again. Or, type info() for more options.

| dir.create(file.path('testdir2', 'testdir3'), recursive = TRUE) will do the trick. If you
| forgot the recursive argument, the command may have appeared to work, but it didn't create
| the nested directory.

> dir.create(file.path('testdir2','testdir3'),recursive = TRUE)

 That gave us every integer between (and including) 1 and 20. We could also use it to create a
| sequence of real numbers. For example, try pi:10.

> pi:10

| Remember that if you have questions about a particular R function, you can access its
| documentation with a question mark followed by the function name: ?function_name_here.
| However, in the case of an operator like the colon used above, you must enclose the symbol in
| backticks like this: ?`:`. (NOTE: The backtick (`) key is generally located in the top left
| corner of a keyboard, above the Tab key. If you don't have a backtick key, you can use
| regular quotes.)

This gives us the same output as 1:20. However, let's say that instead we want a vector of
| numbers ranging from 0 to 10, incremented by 0.5. seq(0, 10, by=0.5) does just that. Try it
| out.

| Another option is to use seq(along.with = my_seq).

If we're interested in creating a vector that contains 40 zeros, we can use rep(0, times =
| 40). Try it out.

> rep(0,time = 40)
 [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

| Try again. Getting it right on the first try is boring anyway! Or, type info() for more
| options.

| Type rep(0, times = 40) to make a vector containing 40 zeros.

> rep(0,times = 40)

Right now, my_char is a character vector of length 3. Let's say we want to join the elements
| of my_char together into one continuous character string (i.e. a character vector of length
| 1). We can do this using the paste() function.

...

  |======================================================                                |  63%

| Type paste(my_char, collapse = " ") now. Make sure there's a space between the double quotes
| in the `collapse` argument. You'll see why in a second.

> paste(my_char,collapse = " ")

 For a slightly more complicated example, we can join two vectors, each of length 3. Use
| paste() to join the integer vector 1:3 with the character vector c("X", "Y", "Z"). This time,
| use sep = "" to leave no space between the joined elements.

> paste(c(1:3),c("X","Y","Z"),sep = "")
[1] "1X" "2Y" "3Z"

| That's a job well done!

LETTERS is a predefined variable
| in R containing a character vector of all 26 letters in the English alphabet.


To make things a little more interesting, lets create a vector containing 1000 draws from a
| standard normal distribution with y <- div="" rnorm="">

> y <- div="" rnorm="">

| That's a job well done!

  |==========================                                                            |  30%

| Next, let's create a vector containing 1000 NAs with z <- 1000="" div="" rep="">

> z <- 1000="" div="" rep="">

| That's correct!

  |==============================                                                        |  35%

| Finally, let's select 100 elements at random from these 2000 values (combining y and z) such
| that we don't know how many NAs we'll wind up with or what positions they'll occupy in our
| final vector -- my_data <- 100="" c="" div="" sample="" y="" z="">

> my_data <- 100="" c="" div="" sample="" y="" z="">

In our previous discussion of logical operators, we introduced the `==` operator as a method
| of testing for equality between two objects. So, you might think the expression my_data == NA
| yields the same results as is.na(). Give it a try.

> my_data==NA
  [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
 [31] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
 [61] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
 [91] NA NA NA NA NA NA NA NA NA NA

| Keep up the great work!

  |====================================================                                  |  60%

| The reason you got a vector of all NAs is that NA is not really a value, but just a
| placeholder for a quantity that is not available. Therefore the logical expression is
| incomplete and R has no choice but to return a vector of the same length as my_data that
| contains all NAs.

x[!is.na(x) & x > 0]

Now, let's check that vect and vect2 are the same by passing them as arguments to the
| identical() function.

> identical(vect,vect2)

Now we'll use the cbind() function to 'combine columns'. Don't worry about storing the result
| in a new variable. Just call cbind() with two arguments -- the patients vector and my_matrix.

> cbind(patients,my_matrix)
     patients                       
[1,] "Bill"   "1" "5" "9"  "13" "17"
[2,] "Gina"   "2" "6" "10" "14" "18"
[3,] "Kelly"  "3" "7" "11" "15" "19"
[4,] "Sean"   "4" "8" "12" "16" "20"

| You are quite good my friend!

Subsetting Function
http://www.statmethods.net/management/subset.html


http://stackoverflow.com/questions/3445590/how-to-extract-a-subset-of-a-data-frame-based-on-a-condition-involving-a-field

Comments

  1. Good post and informative. Thank you very much for sharing this good article, it was so good to read and useful to improve my knowledge as updated, keep blogging. Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.

    oracle training in chennai

    oracle training institute in chennai

    oracle training in bangalore

    oracle training in hyderabad

    oracle training

    oracle online training

    hadoop training in chennai

    hadoop training in bangalore

    ReplyDelete

Post a Comment

Popular Reads

Day 15 GCP Recommendations , Cloud SQL PySpark DataProc

Collaborative Filtering - RDD-based API https://spark.apache.org/docs/latest/mllib-collaborative-filtering.html PySpark https://spark.apache.org/docs/0.9.0/python-programming-guide.html Managed Hadoop & Spark https://cloud.google.com/dataproc/ Fully-Managed PostgreSQL  BETA  & MySQL https://cloud.google.com/sql/ Cloud sql can run 1 petabit per second

Day 18 GCP DataLab, Big Query from Client Side , Pandas- Python

'sudo su -' vs 'sudo -i' vs 'sudo /bin/bash' - when does it matter which is used, or does it matter at all? https://askubuntu.com/questions/376199/sudo-su-vs-sudo-i-vs-sudo-bin-bash-when-does-it-matter-which-is-used docker ps  will show only running containers by default. To see all containers:  docker ps -a https://docs.docker.com/v1.11/engine/reference/commandline/ps/ https://8081-dot-2337103-dot-devshell.appspot.com/tree/datalab root1234 - paraphrase DataLab gives the ability to share a notebook with other people , at the same time use the cloud for computing n storage. https://cloud.google.com/bigquery/docs/reference/libraries#client-libraries-usage-python https://github.com/google/google-api-javascript-client http://stackoverflow.com/questions/12479895/obtaining-bigquery-data-from-javascript-code Python Data Analysis Library http://pandas.pydata.org/

Day 13 - Microsoft artificial Intelligence | Arduino Robotic Kit

Using Visual Studio for python -- back to debugging mode , feels amazing. So finally after managing to get 4 18650 batteries , 2 of them are discharged , now not sure how to recharge them. Good Resources for AI https://blog.goodaudience.com/learn-ai-for-free-5b186cde3990 Python Math Operators https://www.digitalocean.com/community/tutorials/how-to-do-math-in-python-3-with-operators Reading an Input form cmd line with python https://stackoverflow.com/questions/70797/user-input-and-command-line-arguments Convert string to int in Python https://guide.freecodecamp.org/python/how-to-convert-strings-into-integers-in-python/ https://www.programiz.com/python-programming/if-elif-else

Day 20 Google APIs, Google Application Default Credentials

Searching for objects attribute value, it has to be Datastore . Remember that BigTable, you can only search by key.  High-throughput writes of wide-column data. Well, that is BigTable , right, because it's supporting high-throughput writes.  Warehousing structured data. So what's the data warehouse technology on Google Cloud? That's, which one, BigQuery .  To create and test new machine learning methods. Well, if you're writing new machine learning methods, then TensorFlow .  Develop Big Data algorithms interactively in Python.Well, interactive development in Python is done best with Datalab .   Well, interactive No-ops, custom machine learning applications at scale. No-ops ML at scale, then that's a role for Cloud ML.  Automatically reject inappropriate image content. Rejecting image content where it is inappropriate. Well, that could be the Vision API. So you could use a Vision API to basically see if this is safe content or not safe...

Day 8 - Microsoft AI | Arduino Robotic Kit

Arduino Robotic Kit https://photos.app.goo.gl/Ng6MmaRnxHHWUHpJ6 Just got my Arduino robotic kit , quite excited :-) , Let us start exploring the various components. HC SR 04 Ultrasonic Ranging Module https://www.mouser.com/ds/2/813/HCSR04-1022824.pdf HC - SR04 provides 2cm - 400cm non-contact measurement function, the ranging accuracy can reach to 3mm Vcc , Trigger , Echo n Ground  You only need to supply a short 10uS pulse to the trigger input to start the ranging, and then the module will send out an 8 cycle burst of ultrasound at 40 kHz and raise its echo. The Echo is a distance object that is pulse width and the range in proportion https://randomnerdtutorials.com/complete-guide-for-ultrasonic-sensor-hc-sr04/ https://www.arduino.cc/en/Reference/Libraries https://www.youtube.com/watch?v=6F1B_N6LuKw

Day 7 Hands on with Git Repo and RStudio , R 101 BigDataUniversity

Removing a remote http://stackoverflow.com/questions/9224754/how-to-remove-origin-from-git-repository Kickstarting   R  - Writing R scripts https://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_scrpt.html Source on Save https://support.rstudio.com/hc/en-us/articles/200484448-Editing-and-Executing-Code Ctrl+L  — Clear the Console https://support.rstudio.com/hc/en-us/articles/200404846-Working-in-the-Console User Defined Functions in R http://www.statmethods.net/management/userfunctions.html Issue pushing new code in Github http://stackoverflow.com/questions/20939648/issue-pushing-new-code-in-github Git refusing to merge unrelated histories http://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories

Day 5 IBM Watson , DataCamp Purchase, IT Pros Attack n RedMonk rankings

IBM Watson http://www.jenunderwood.com/2017/03/28/ibm-watson-cognitive-computing/?utm_content=bufferb4ded&utm_medium=social&utm_source=facebook.com&utm_campaign=buffer The DataCamp Intro to R is free but later courses are paid. Will try complete Coursera first and get some heads on and then I can buy DataCamp courses as well. https://www.tripwire.com/state-of-security/featured/90-pros-expect-attacks-risk-vulnerability-iiot-2017/ http://redmonk.com/sogrady/2017/03/17/language-rankings-1-17/

Moment to Ignite

I know what you're thinking.It's nothing like that , it's infact the good ol friendship stuff. If i write explicitly in the title no one would bother to read it. I remember my hindi sir telling it takes 2 hours to write something and 2 days to give an apt title. In this modern era there is only one thing that interests everyone controversies, gossip ,all the masala put in together.Anyways I'm deviating a lot. How do you make friends? I might have asked this earlier...take it as a refresher... Yeah yeah i know i know....you cant make friends, you become friends.But again how?? Most of you will be like, whose bothered how now that we are friends.Put aside similar interests,likings , all the rational logical astute observations.Could it be some kind of destiny thing.It hardly sounds like me but then i have changed over time,I have started keeping my views open to every single possibility. Let me put a more real situation, what if you knew each other all the way a...

Helplessness

So we had no project and to add the to misery no jobs.We were told by our placement dept tht our dept so called MEDICAL ELECTRONICS wasn't allowed by most of the companies. We all wer dejected as all of us had worked hard and wanted to get some job.I tht why sit n crib all time when u have so much time to enjoy. So i hit wit my family to Rajasthan.It was a nice but extremely hectic trip for me. We went by flight to jaipur then next day jodhpur by bus the same day udaipur by bus ,whr i came to know tht companies wer allowing us n the placement dept scammed us. So next day we left frm udaipur to mumbai  by train n then the same day to bangalore by bus. In 5 days i had spanned across 5 states. I rechd bangalore and had accenture next day so went thro the placement bible RS Aggarwal. Sadly i didn't clear then i sat for HCL which again i didn't clear so i was amidst doubt within myself. But still i didn't lose hope n worked harder.