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 functions 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 character vector

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”中存在的字符的大小写

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

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


tolower(state.division)

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(state.region)

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

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



使用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数据框。

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)

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 data frame.

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编程教程的更多更新。 转换愉快!!!

翻译自: https://www.journaldev.com/40542/convert-case-of-a-string-in-r

mysql中转换成字符串

mysql中转换成字符串_如何在R中转换字符串的大小写?相关推荐

  1. rstudio r语言_如何在R中接受用户输入?

    rstudio r语言 Taking a user input is very simple in R using readline() function. In this tutorial, we ...

  2. rstudio中位数的公式_如何在R中找到中位数

    rstudio中位数的公式 In this tutorial, let's learn how we can find the median in R. Median is defined as th ...

  3. xml文件转换成图片_如何把pdf文件转换成图片?

    pdf文件怎么转成JPG图片呢?相信有不少人在迷惑,可能还在想着截图等操作来完成转换,但如果是截图成JPG图片后的效果可能很差,并没有之前pdf文件那么清楚.那这样往往打印出来的效果也不怎么理想,那怎 ...

  4. csv文件示例_如何在R中使用数据框和CSV文件-带有示例的详细介绍

    csv文件示例 Welcome! If you want to start diving into data science and statistics, then data frames, CSV ...

  5. python中用什么函数读取字符串_如何在Python中获得函数名作为字符串?

    在Python中,如何在不调用函数的情况下以字符串的形式获得函数名? 1 2 3 4def my_function(): pass print get_function_name_as_string( ...

  6. regexp 好汉字符串_如何在JavaScript中使用RegExp确认字符串的结尾

    regexp 好汉字符串 by Catherine Vassant (aka Codingk8) 由凯瑟琳·瓦森(Catherine Vassant)(又名Codingk8) 如何在JavaScrip ...

  7. java中转json字符串_如何在Java中转义JSON字符串-Eclipse IDE技巧

    java中转json字符串 在Java应用程序中工作或进行JSON解析时,通常很常见的做法是从某些资源(例如RESTful Web服务)中复制粘贴JSON字符串,然后使用Jackson库解析JSON. ...

  8. php根据字符串分割字符串_如何在PHP中按字符串分割字符串?

    php根据字符串分割字符串 How to split a string by string in PHP? For example, 如何在PHP中按字符串分割 字符串 ? 例如, "a s ...

  9. ruby字符串截取字符串_如何在Ruby中附加字符串?

    ruby字符串截取字符串 There are multiple ways to do the required but we will study about three of them. 有多种方法 ...

最新文章

  1. Servlet--02--xml文件配置
  2. 提高你开发效率的十五个 Visual Studio 使用技巧
  3. Spring vs Seam
  4. MYSQL驱动包升级到5.1.17版本之后会出现的问题
  5. python实例方法不可以用类调用_为什么python静态/类方法不可调用?
  6. paip.c++ 转换 java 解决方案
  7. 安卓笔记:去除顶部的bar(安卓5.1)
  8. Kali防火墙ufw安装与命令
  9. 华为一员工猝死出租屋 警方初步排除他杀
  10. ajax hapi上传文件,在hapi框架里使用ajax提交表单数据,但是服务端接收到的数据是空对象。怎么办啊?...
  11. C语言文件重定向---“系统找不到指定的文件”
  12. Python实例---爬取下载喜马拉雅音频文件
  13. 数据结构之前序遍历,中序遍历,后序遍历
  14. 博客匿名评论功能正式上线了!
  15. 经济-一文看懂经济学进化史:经济学的四次革命
  16. 标准计算机准备室,各功能室建设要求标准.docx
  17. 用文件记录游戏最高分【C语言】
  18. 关于如何办好培训的感想
  19. 踩坑,union后数据少了
  20. 洛谷随机刷题之传智杯#3

热门文章

  1. java 中的匿名内部类
  2. 课堂练习--最大子数组和
  3. Python生成器 yield
  4. hdu 4279 Number (找规律)
  5. [转载] python 需求清单_Python清单操作摘要
  6. [转载] Python列表拷贝复制函数copy()函数的作用
  7. [洛谷P3979]遥远的国度
  8. Python学习路程day9
  9. http状态码 以及请求响应头相关
  10. db link的查看创建与删除