R Programming: Create three vectors numeric data, character data and logical data
R Programming: Basic Exercise-15 with Solution
Write a R program to create three vectors numeric data, character data and logical data. Display the content of the vectors and their type.
Sample Solution :
R Programming Code :
a = c(1, 2, 5, 3, 4, 0, -1, -3) b = c("Red", "Green", "White") c = c(TRUE, TRUE, TRUE, FALSE, TRUE, FALSE) print(a) print(typeof(a)) print(b) print(typeof(b)) print(c) print(typeof(c))
 1 2 5 3 4 0 -1 -3  "double"  "Red" "Green" "White"  "character"  TRUE TRUE TRUE FALSE TRUE FALSE  "logical"
R Programming Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a R program to read the .csv file and display the content.
Next: Write a R program to create a 5 × 4 matrix , 3 × 3 matrix with labels and fill the matrix by rows and 2 × 2 matrix with labels and fill the matrix by columns.
Test your Python skills with w3resource's quiz
What is the difficulty level of this exercise?
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework