对于学位字符,哪个是正确的编码?

发布于 2025-01-25 13:22:40 字数 303 浏览 1 评论 0原文

我有一系列代码,使文本

temperature<-as.numeric(gsub("°.*","",temp))

r不喜欢“°”字符。保存文件时,它说我需要使用其他编码。

我已经尝试了列表中的各种不同的编码,但是它们都以

temperature<-as.numeric(gsub("??.*","",temp)) 

当前解决方案的某些变化保存代码是在记事本中打开脚本,并将代码粘贴到rstudio中。我需要在rstudio中保存哪个编码?

I have a line of code that alters text

temperature<-as.numeric(gsub("°.*","",temp))

R does not like the "°" character. When I save the file it says I need to use a different encoding.

I have tried all sorts of different encodings from the list, but they all save the code in some variation of

temperature<-as.numeric(gsub("??.*","",temp)) 

My current solution is to open the script in notepad and copy paste the code into rstudio. Which encoding do I need to save a ° in rstudio?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回梦 2025-02-01 13:22:40

在rstudio中对此的完整解决方案是转到文件 - &gt;保存使用编码 - &gt;选择ISO-8859-1-&GT;将框设置为默认编码源文件。现在,该文件每次都以学位字符正确打开。

The full solution to this in rstudio was to go to file -> save with encoding -> select ISO-8859-1 -> check the box Set as default encoding for source files. Now the file opens properly with the degree character every time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文