博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql中转换成字符串_如何在R中转换字符串的大小写?
阅读量:2531 次
发布时间:2019-05-11

本文共 5011 字,大约阅读时间需要 16 分钟。

mysql中转换成字符串

Hello, folks. In this tutorial we are going to convert the case of the string in R. The R language offers functions such as tolower(), toupper(), and casefold() to convert the case of the given string from upper to lower or vice versa as well.

大家好 在本教程中,我们将转换R中字符串的大小写。R语言提供了诸如tolower(),toupper()和casefold()之类的函数,用于将给定字符串的大小写从大写转换为小写,反之亦然也一样

Let’s see how these work.

让我们看看这些是如何工作的。



R中用于大小写转换的函数 (Functions used for case conversion in R)

tolower() = The tolower() function is used to convert the string characters to the lower case.

tolower()= tolower()函数用于将字符串字符转换为小写。

toupper() = The toupper() function is used to convert the string characters to upper case.

toupper()= toupper()函数用于将字符串字符转换为大写。

casefold() = The casefold function is used to convert the string characters from lower to upper case and vice versa as well.

casefold() = casefold函数用于将字符串字符从小写转换为大写,反之亦然。



让我们从语法开始 (Let’s start with the syntax)

  • The syntax of the function tolower() is,

    函数tolower()的语法是,
tolower(x)

x = string or a character vector

x =字符串或字符向量

  • The syntax of the toupper() function is,

    toupper()函数的语法是,
toupper(x)

x = string or a

x =字符串或



使用tolower()函数将字符串转换为小写 (Convert a string to lower case using tolower() function)

In this section, we are going to convert a string or a character vector to a lower case using tolower() function.

在本节中,我们将使用tolower()函数将字符串或字符向量转换为小写。

tolower("WWW.JOURNALDEV.COM")

Output = “www.journaldev.com”

输出=“ www.journaldev.com”

df<-c("HAVE A GOOD DAY")tolower(df)

Output = “have a good day”

输出=“祝你有美好的一天”

The tolower() function will convert the case of the characters to lower as shown above.

tolower()函数将把字符的大小写转换为小写,如上所示。

Now, let’s convert the case of the characters present in a data set ‘state.division’.

现在,让我们转换数据集“ state.division”中存在的字符的大小写

Lower In R

Let’s see how tolower() function converts the case of the string to lower case.

让我们看看tolower()函数如何将字符串的大小写转换为小写。

tolower(state.division)
Lower

In the above output you can see that all the strings present in the column species get converted into small letters or lower cases.

在上面的输出中,您可以看到列种类中存在的所有字符串都转换为小写字母或小写字母。



使用toupper()函数将字符串转换为大写 (Convert a string to upper case using toupper() function)

In the above sections we have converted the strings to lower case. Now let’s convert the strings to upper case using toupper() function in R.

在以上各节中,我们已将字符串转换为小写。 现在,让我们使用R中的toupper()函数将字符串转换为大写。

toupper("www.journaldev.com")

Output = “WWW.JOURNALDEV.COM”

输出=“ WWW.JOURNALDEV.COM”

toupper("have a good day")

Output = “HAVE A GOOD DAY”

输出=“祝你有美好的一天”

These are just a few examples of the toupper() function. It converts the lower case string characters to upper case in R.

这些只是toupper()函数的几个示例。 它将R中的小写字符串转换为大写。

Let’s convert the string characters of a data frame to the upper case using toupper() function in R.

让我们使用R中的toupper()函数将数据帧的字符串字符转换为大写。

Toupper In R 1 1
toupper(state.region)

In the below output you can see how toupper() function converts the string characters of the data frame to upper case.

在下面的输出中,您可以看到toupper()函数如何将数据帧的字符串字符转换为大写。

Upp 1


使用R中的casefold()函数将字符串转换为大写和小写 (Convert a string to upper and lower case using casefold() function in R)

Till now, we have come across tolower() and toupper() functions to convert the case of the strings to lower and upper cases respectively.

到现在为止,我们来了 跨tolower()和toupper()函数将字符串的大小写分别转换为小写和大写。

R offers another function named casefold(), which converts the string characters to lower and upper case.

R提供了另一个名为casefold()的函数,该函数将字符串字符转换为小写和大写形式。

The syntax:

语法:

casefold(x,upper=F)

Where,

哪里,

  • x = string character or a character data frame.

    x =字符串字符或字符数据帧。
  • upper = case of the string will be lower if mentioned False and it will be upper if mentioned True.

    upper =如果为False,则字符串的大小写将为小写;如果为True,则字符串的大小写将为大写。

Let’s see how the casefold() function converts the case of the strings.

让我们看看casefold()函数如何转换字符串的大小写。

casefold("i love r programming",upper = T)

Output = “I LOVE R PROGRAMMING”

输出=“我爱编程”

casefold("I LOVE R PROGRAMMING",upper=F)

Output = “i love r programming”

输出=“我爱编程”

Like this the casefold() function will convert the case of the string characters. Now, let’s see how casefold() function will convert the case of the data frame.

这样,casefold()函数将转换字符串字符的大小写。 现在,让我们看看casefold()函数将如何转换数据帧的大小写。

The below image shows the state.name data frame.

下图显示了state.name数据框。

Casefold

Let’s make use of casefold() function to convert the strings present in the data frame to upper case.

让我们利用casefold()函数将数据框中存在的字符串转换为大写。

casefold(state.name,upper = T)
Casefold 1

In this way, you can convert the case of the strings in R using tolower(), toupper(), and casefold() function.

这样,您可以使用tolower(),toupper()和casefold()函数在R中转换字符串的大小写。



结语 (Wrapping up)

R offers some functions to convert the case of the string characters present in a vector or a .

R提供了一些功能来转换矢量或存在的字符串字符的大小写。

This tutorial focussed on the case conversion using some specific functions in R.

本教程重点介绍使用R中的某些特定功能进行大小写转换。

That’s all for case conversion in R. Stay tuned for more updates on R programming tutorials. Happy conversion!!!

这就是R中的大小写转换。敬请期待有关R编程教程的更多更新。 转换愉快!!!

翻译自:

mysql中转换成字符串

转载地址:http://jmozd.baihongyu.com/

你可能感兴趣的文章
Windows下安装Redis
查看>>
迷宫实现
查看>>
【字符编码】Java字符编码详细解答及问题探讨
查看>>
学习操作系统导图
查看>>
在线的JSON formate工具
查看>>
winform非常实用的程序退出方法!!!!!(转自博客园)
查看>>
xml解析
查看>>
centos安装vim
查看>>
linux工作调度(计划任务)
查看>>
hdu--1698 Just a Hook(线段树+区间更新+懒惰标记)
查看>>
Python学习笔记-EXCEL操作
查看>>
二月二——头牙诗词
查看>>
《吴忠与富平》之四:汉三水属国(北地属国、安定属国)
查看>>
丁酉立秋喜逢风雨
查看>>
vim删除#开头的行和正则表达式笔记
查看>>
python3 提成计算
查看>>
VBA赋值给指定单元格
查看>>
抽象类和接口总结回顾
查看>>
【语言处理与Python】5.3使用Python字典映射词及其属性
查看>>
设备信息
查看>>