Popular posts
Key roles for a successful analytical project | steps requires to analyze the datasets | Data Analytical project roles
Introduction to R programming | Datacamp - Introduction to R programming | R programming for data scientist | Programming language for Data Scientist
An introduction to R from Datacamp In this chapter, we will learn about the basics and widely used data structures in R like vectors, factors, lists, and data frames. Arithmetic operations: # An addition 5 + 5 [1] 10 # A subtraction 5 - 5 [1] 0 # A multiplication 3 * 5 [1] 15 # A division ( 5 + 5 ) / 2 [1] 5 # Exponentiation 2 ^ 5 [1] 32 # Modulo 28 %% 6 [1] 4 Variable Assignment: # Assign a value to the variable my_apples my_apples <- 5 # Fix the assignment of my_oranges my_oranges <- 6 # Create the variable my_fruit and print it out my_fruit <- my_apples + my_oranges my_fruit [1] 11 Basic data types in R: # Declare variables of different types my_numeric <- 42 my_character <- "universe" my_logical <- FALSE # Check class of my_numeric class ( my_numeric ) [1] "numeric" # Check class of my_character class ( my_character ) [1] "character" # Check class of my_logical class ( my_logical ) [1] "l
Intermediate R programming | Datacamp- Intermediate R programming | R programming for data scientist | programming language for Data Scientist
Intermediate R programming from Datacamp In this chapter, we will learn about conditional statements, loops, and functions to power the R scripts. Conditional and control flow # Equality: # Comparison of logicals TRUE == FALSE # Comparison of numerics -6 * 14 != 17 - 101 # Comparison of character strings "useR" == "user" # Compare a logical with a numeric TRUE == 1 [1] TRUE # Greater and less than: # Comparison of numerics -6 * 5 + 2 >= -10 + 1 # Comparison of character strings "raining" <= "raining dogs" # Comparison of logicals TRUE > FALSE [1] TRUE # Compare vectors: # The linkedin and facebook vectors have already been created for you linkedin <- c ( 16 , 9 , 13 , 5 , 2 , 17 , 14 ) facebook <- c ( 17 , 7 , 5 , 16 , 8 , 13 , 14 ) # Popular days linkedin > 15 # Quiet days linkedin <= 5 # LinkedIn more popular than Facebook linkedin > facebook [1] FALSE TRUE TRUE FALSE FAL
Comments
Post a Comment