In R, you can use the toupper() function to convert all the elements of a vector to uppercase. Here is an example:

# Create a vector with lowercase words
words <- c("apple", "banana", "cherry")

# Convert all the elements to uppercase
upper_words <- toupper(words)

# Print the result
print(upper_words)

Output:

[1] "APPLE"  "BANANA" "CHERRY"

In the above code, the toupper() function is applied to the words vector, and the result is stored in the upper_words vector. The print() function is then used to display the transformed vector.

R语言 一个向量的英文单词全部改为大写

原文地址: http://www.cveoy.top/t/topic/jcVn 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录