Q:

Write a R program to change the first level of a factor with another level of a given factor

0

Write a R program to change the first level of a factor with another level of a given factor.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

v = c("a", "b", "a", "c", "b")
print("Original vector:")
print(v)
f = factor(v)
print("Factor of the said vector:")
print(f)
levels(f)[1] = "e"
print(f)

Sample Output:

[1] "Original vector:"
[1] "a" "b" "a" "c" "b"
[1] "Factor of the said vector:"
[1] a b a c b
Levels: a b c
[1] e b e c b
Levels: e b c

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now