R에서 문자열에서 따옴표를 제거하는 방법(3가지 방법)
R의 문자열에서 따옴표를 제거하는 세 가지 일반적인 방법이 있습니다.
방법 1: print() 사용
print(some_strings, quote= FALSE )
방법 2: noquote() 사용
noquote(some_strings)
방법 3: cat() 사용
cat(some_strings)
다음 예에서는 다음 문자열 벡터와 함께 각 메서드를 사용하는 방법을 보여줍니다.
#define vector of strings
some_strings <- c("hey", "these", "are", "some", "strings")
#view vector
some_strings
[1] “hey” “these” “are” “some” “strings”
문자열은 기본적으로 따옴표와 함께 인쇄됩니다.
예 1: print()를 사용하여 문자열에서 따옴표 제거
다음 코드는 print() 함수를 사용하여 따옴표가 제거된 문자열을 인쇄하는 방법을 보여줍니다.
#print vector of strings without quotes print(some_strings, quote= FALSE ) [1] hey these are some strings
예제 2: noquote()를 사용하여 문자열에서 따옴표 제거
다음 코드는 noquote() 함수를 사용하여 따옴표가 제거된 문자열을 인쇄하는 방법을 보여줍니다.
#print vector of strings without quotes noquote(some_strings ) [1] hey these are some strings
예 3: Cat()을 사용하여 문자열에서 따옴표 제거
다음 코드는 cat() 함수를 사용하여 따옴표가 제거된 문자열을 인쇄하는 방법을 보여줍니다.
#print vector of strings without quotes cat(some_strings ) hey these are some strings
\n 인수를 사용하여 새 줄에 따옴표 없이 각 문자열을 인쇄할 수도 있습니다.
#print vector of strings without quotes each on a new line cat(paste(some_strings, " \n ")) hey thesis are some thongs
벡터의 각 문자열은 새 줄에 인쇄됩니다.
추가 리소스
다음 튜토리얼에서는 R에서 다른 일반적인 작업을 수행하는 방법을 설명합니다.
R의 문자열에서 문자를 제거하는 방법
R의 문자열에서 문자 위치를 찾는 방법
R 문자열에서 공백을 제거하는 방법