diff --git a/exercise-1/exercise.R b/exercise-1/exercise.R index 954d4c4..888ca57 100644 --- a/exercise-1/exercise.R +++ b/exercise-1/exercise.R @@ -1,24 +1,28 @@ # Exercise-1: practice with basic syntax # Create a variable `hometown` that stores the city in which you were born - +hometown <- "bangalore" # Assign your name to the variable `my.name` - +my.name <- "Thejas" # Assign your height (in inches) to a variable `my.height` - - +my.height <- 135 + # Create a variable `puppies` equal to the number of puppies you'd like to have - +puppies <- 3 # Create a variable `puppy.price`, which is how expensive you think a puppy is - +puppy.price <- 400 # Create a variable `total.cost` that has the total cost of all of your puppies - +total.cost <- puppies * puppy.price # Create a boolean variable `too.expensive`, set to TRUE if the cost is greater than $1,000 - +too.expensive <- total.cost > 1000 # Create a variable `max.puppies`, which is the number of puppies you can afford for $1,000. +max.puppies <- 1000 / puppy.price + +print(max.puppies) + diff --git a/exercise-2/README.md b/exercise-2/README.md new file mode 100644 index 0000000..9cded38 --- /dev/null +++ b/exercise-2/README.md @@ -0,0 +1,8 @@ +# Exercise-2 +Nearly all of our R exercises will follow the same format, requiring the following steps: + +1. As you've done before, fork this repository to your own GitHub account +2. Clone the repository to your machine +3. Open the `exercise.R` file in Rstudio, and follow the instructions there. +4. When you're done, `add` and `commit` your changes +5. Push your changes back to GitHub diff --git a/exercise-2/exercise.R b/exercise-2/exercise.R new file mode 100644 index 0000000..e565570 --- /dev/null +++ b/exercise-2/exercise.R @@ -0,0 +1,29 @@ +# Exercise-2: more practice with basic syntax + +# Create a variable `food` that stores your favorite kind of food +food <- "Teiyaki" + +# Create a variable 'restaurant' that stores your favorite place to eat +resturant <- "Itadakimas" + +# Create a variable `friends` equal to the number of friends you would like to eat with +friends <- 4 + +# Create a variable `meal.price`, which is how expensive you think one meal at the restaurant will be +meal.price <- 10 + +# Create a variable `total.cost` that has the total cost of your bill +total.cost <- friends * meal.price + +# Create a variable 'total.cost.tip' to be the total cost including a 15% tip +total.cost.tip <- total.cost * 0.15 + +# Create a variable 'price.limit' set to your spending budget +price.limit <- 100 + +# Create a boolean variable `too.expensive`, set to TRUE if the cost with the tip is greater than the price limit +too.expensive <- (total.cost + total.cost.tip) > price.limit + +# Create a variable `max.friends`, which is the maximum number of friends you can invite that is in range +# of your price limit +max.friends <- round(price.limit / ((total.cost + total.cost.tip)/friends)) \ No newline at end of file