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

  • برمجة R

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

الأجوبة

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
هل كان المحتوى مفيد؟

معلومات ذات صلة

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...