how to use right/left to split a variable in sqldf, as in left(x,n)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 21:22:05

问题


Is there a different function in R to use to get the same result as in SQL for left or right function?

For instance, the following query in SQL would give the first 6 characters of a column:

select left(x, 6)
from table

However, when I try this in sqldf like this:

sqldf("select left(x,6) from table")

I get the following error:

Error in sqliteSendQuery(con, statement, bind.data) :

error in statement: near "(": syntax error

It gives me the x variable but not left(x,6). To clarify, the length of x is more than 6.


回答1:


In sqldf, the function is named leftstr, not left. (answer by G.Grothendieck in the comment)



来源:https://stackoverflow.com/questions/31843373/how-to-use-right-left-to-split-a-variable-in-sqldf-as-in-leftx-n

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!