쉽게 배우는 R 데이터 분석
데이터 불러오기
파일불러오기 실패시, setwd 로 경로 설정
- snippet.shell
# 데이터 불러오기 setwd('C:/Users/Playdata/weekend_R/쉽게 배우는 R 데이터 분석') txt <- readLines('./data/hiphop.txt')
글자 수
- snippet.shell
> # 두 글자 이상 단어 추출 > df_word <- filter(df_word, nchar(word) >= 2) Error in filter_impl(.data, quo) : Evaluation error: 'nchar()' requires a character vector.
에러 발생시 아래와 같이 수정
- snippet.shell
df_word <- filter(df_word, nchar(as.character(df_word$word)) >= 2)
map_data
- snippet.shell
states_map <- map_data('state') str(states_map) Error: Package `maps` required for `map_data`. Please install and try again. Traceback: 1. map_data("state") 2. try_require("maps", "map_data") 3. stop("Package `", package, "` required for `", fun, "`.\n", "Please install and try again.", . call. = FALSE)
- snippet.shell
install.packages('maps') if (require('maps')){ states_map <- map_data('state') str(states_map) }