- Related Questions & Answers
- How to convert lowercase letters in string to uppercase in Python?
- How to convert all uppercase letters in string to lowercase in Python?
- How to extract a data.table row as a vector in R?
- How to create permutations as a list in R?
- How to display tick marks on upper as well as right side of the plot using ggplot2 in R?
- How to check whether a string is in lowercase or uppercase in R?
- Write a C program to convert uppercase to lowercase letters without using string convert function
- How to find minimum value in a numerical vector which is written as a character vector in R?
- How to create a vector with repeated values in R?
- How to create a vector with zero values in R?
- How to create a date vector with randomization in R?
- How to create an ordered list with list items numbered with lowercase letters in HTML?
- How to create an ordered list with list items numbered with uppercase letters in HTML?
- How to create vector in R with a sequence of numbers?
- How to create a vector with zero values in R Program?

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

To create a vector with lowercase we can use the word letters and for uppercase the word LETTERS is used in R. If we want to create a vector with both type of letters then both of these words can be combined using c function and if want to create a vector with randomly sampled values of lowercase and uppercase letters then sample function can be used.

> x1<-c(LETTERS[1:4],letters[1:4]) > x1

[1] "A" "B" "C" "D" "a" "b" "c" "d"

> x2<-c(LETTERS[1:26],letters[1:26]) > x2

[1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" [20] "T" "U" "V" "W" "X" "Y" "Z" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" [39] "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"

> x3<-c(LETTERS[1:13],letters[1:13],LETTERS[14:26],letters[14:26]) > x3

[1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "a" "b" "c" "d" "e" "f" [20] "g" "h" "i" "j" "k" "l" "m" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" [39] "Z" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"

> x4<-sample(c(LETTERS[1:4],letters[1:4]),100,replace=TRUE) > x4

[1] "a" "B" "a" "B" "D" "D" "c" "b" "d" "D" "a" "B" "b" "c" "d" "c" "B" "C" [19] "D" "d" "b" "C" "b" "b" "C" "D" "d" "A" "B" "A" "D" "a" "a" "c" "b" "b" [37] "B" "A" "d" "a" "b" "b" "D" "B" "c" "b" "b" "b" "B" "B" "D" "b" "a" "C" [55] "d" "b" "c" "B" "A" "A" "a" "c" "C" "B" "c" "D" "A" "C" "D" "D" "B" "c" [73] "b" "C" "d" "C" "B" "D" "A" "A" "B" "A" "B" "c" "d" "C" "B" "a" "b" "B" [91] "b" "B" "B" "A" "a" "B" "b" "A" "a" "a"

> x5<-sample(c(LETTERS[1:26],letters[1:26]),120,replace=TRUE) > x5

[1] "n" "t" "S" "B" "l" "n" "W" "Z" "a" "k" "X" "P" "E" "V" "Z" "O" "A" "D" [19] "R" "g" "r" "E" "p" "a" "h" "E" "B" "N" "F" "H" "Y" "h" "f" "r" "r" "E" [37] "G" "x" "H" "V" "W" "z" "p" "r" "E" "u" "u" "X" "w" "E" "Q" "G" "k" "N" [55] "f" "P" "S" "o" "p" "w" "C" "g" "T" "p" "D" "T" "f" "N" "j" "z" "d" "v" [73] "D" "a" "L" "J" "B" "g" "T" "y" "a" "L" "G" "E" "Z" "Y" "l" "G" "M" "L" [91] "f" "b" "h" "P" "B" "T" "i" "e" "H" "b" "K" "p" "W" "I" "z" "t" "I" "B" [109] "Q" "T" "z" "e" "n" "q" "m" "I" "n" "g" "r" "B"

> x6<-sample(c(LETTERS[21:26],letters[21:26]),120,replace=TRUE) > x6

[1] "X" "Z" "Z" "u" "W" "x" "w" "z" "y" "Z" "u" "Z" "x" "z" "V" "X" "y" "x" [19] "V" "U" "x" "Y" "u" "u" "W" "v" "y" "u" "W" "y" "u" "y" "X" "U" "Y" "u" [37] "v" "Z" "u" "X" "Z" "W" "U" "v" "Z" "W" "W" "X" "y" "Z" "z" "X" "U" "U" [55] "w" "y" "W" "U" "W" "X" "y" "V" "v" "V" "V" "Z" "Y" "v" "u" "y" "z" "W" [73] "U" "V" "U" "u" "v" "U" "Z" "Z" "X" "w" "Z" "u" "w" "Y" "X" "y" "Z" "V" [91] "x" "y" "x" "Y" "y" "v" "z" "u" "Y" "z" "W" "v" "u" "u" "V" "v" "Y" "x" [109] "Z" "y" "z" "w" "z" "u" "x" "x" "Z" "V" "x" "U"

> x7<-sample(c(LETTERS[1:13],letters[1:13]),120,replace=TRUE) > x7

[1] "m" "i" "I" "j" "F" "F" "J" "E" "a" "f" "m" "f" "L" "I" "k" "E" "H" "B" [19] "b" "H" "b" "E" "i" "F" "i" "C" "l" "J" "c" "C" "c" "D" "m" "E" "j" "C" [37] "j" "E" "l" "I" "L" "C" "B" "L" "l" "d" "g" "K" "j" "D" "i" "C" "i" "G" [55] "I" "e" "E" "C" "j" "k" "k" "D" "J" "g" "K" "e" "j" "D" "B" "B" "f" "k" [73] "B" "f" "g" "l" "E" "h" "g" "j" "b" "J" "c" "C" "j" "f" "M" "e" "I" "j" [91] "A" "B" "m" "a" "I" "M" "G" "e" "i" "e" "l" "h" "I" "E" "M" "d" "k" "B" [109] "G" "j" "C" "g" "B" "F" "m" "M" "H" "L" "a" "m"

> x8<-sample(c(LETTERS[24:26],letters[24:26]),120,replace=TRUE) > x8

[1] "X" "z" "X" "x" "x" "Y" "y" "Z" "x" "z" "Z" "y" "y" "z" "Y" "X" "Y" "X" [19] "Y" "y" "y" "Y" "x" "Y" "Y" "x" "X" "x" "x" "Z" "Y" "z" "x" "X" "x" "z" [37] "z" "Y" "y" "X" "y" "z" "Z" "z" "Z" "x" "Y" "Z" "x" "z" "x" "x" "X" "z" [55] "y" "x" "y" "x" "Z" "x" "Y" "z" "z" "X" "z" "Y" "X" "X" "x" "z" "z" "y" [73] "Z" "z" "Z" "Y" "x" "Y" "x" "Z" "Y" "y" "X" "x" "z" "x" "Z" "x" "z" "y" [91] "Z" "x" "X" "Y" "X" "X" "y" "x" "Y" "z" "z" "X" "Y" "X" "y" "x" "Y" "y" [109] "Y" "X" "z" "Z" "Z" "X" "Y" "Z" "Y" "Z" "X" "Y"

Advertisements