Programming/R

[R/Error] Error in parse(text = "5xxx") : <text>:1:2: unexpected symbol

김해김씨99대손 2023. 5. 17. 17:45

여러 함수나 ggplot 사용 시 제목과 같은 메시지를 받게 된다. 

이는 unexpected symbol, 즉 변수로 사용하지 못하는 변수 형식을 받았다는 뜻이다. 

대부분 변수의 이름이 숫자로 시작되어서 인식하지 못하는 경우를 말한다.

 

| 예시

  ggplot(otu, aes_string("3c9c437f27aca05f8db167cd080ff1ec", "1d2e5f3444ca750c85302ceee2473331")) +
    geom_point()
    
# Error in parse(text = paste_line(x)) : <text>:1:2: unexpected symbol
# 1: 3c9c437f27aca05f8db167cd080ff1ec
#      ^

 

 

| 수정 후

숫자로 시각하는 변수명은 ``안에 넣어준다. 

  ggplot(otu, aes_string("`3c9c437f27aca05f8db167cd080ff1ec`", "`1d2e5f3444ca750c85302ceee2473331`")) +
    geom_point()

 

 

| 출처

- https://statisticsglobe.com/error-parse-text-unexpected-symbol-r

 

 

 

 

반응형