公式中出现意外的符号,找不到 [英] Unexpected Symbol in As Formula, Can't Find

查看:93
本文介绍了公式中出现意外的符号,找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用as.formula设置glm,但我不知道意外符号在哪里.问题的部分原因是我要转换的字符向量太长.大约700个单词,中间插入+以便将其转换为公式.该错误显示如下:

I've been using as.formula for setting up a glm, and I can't figure out where the unexpected symbol is. Part of the problem is that the character vector I'm converting is so long. It's about 700 words with + inserted in between in order to turn it into a formula. The error presents as follows:

Error in parse(text = x, keep.source = FALSE) : 
   <text>:2:10080: unexpected symbol

,带有以下文本片段:

2: c_1_E + Campaign_Search_Payroll_Generic_1_P + Campaign_Search_Performing_Core_Keywords + Campaign_Self_Employment_E + Campaign_Self_Employment_P + Campaign_Withholding + Campaign_Youtube + Sou

我肯定知道的事情:

  1. 没有重复的项目.
  2. 除字母数字和下划线(_)外,没有其他符号.
  3. 没有项目以数字开头.
  1. No item is repeated.
  2. No symbols other than alphanumerics and underscore (_).
  3. No item starts with a number.

我对R不太熟悉,无法阅读as.formula文档或函数调用本身.

I'm not well versed enough in R to understand reading the documentation for as.formula or the function call itself.

有什么想法吗?

推荐答案

<text>:2:10080为您提供了错误的位置.第二行,第10080个字符.考虑:

The <text>:2:10080 is giving you the location of the error. 2nd line, 10080th character. Consider:

parse(text="1 + 1 + 2\n a - 3 b")
# Error in parse(text = "1 + 1 + 2\n a - 3 b") : 
#   <text>:2:8: unexpected symbol

在这里,错误出在b上,这是符号的非法使用,您会注意到它是第二行的第8个字符.

Here, the error is with b, which is an illegal use of a symbol, and you'll note it is the 8th character of the second line.

您很可能会丢失+,尽管没有错误背后的数据也无法知道.同样,不进行判断或其他任何操作,但这是要放入模型的大量变量.希望您有很多数据点.

Most likely you're missing a +, though no way of knowing without the data behind your error. Also, not to judge or anything, but that's a helluva lot variables to be sticking into a model. I hope you have lots of data points.

这篇关于公式中出现意外的符号,找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆