무회blog

R함수 basic001: 사용법: ggplot2, ?qplot ,table,read_excel, read.csv, str , summary , head , dim , list , typeof , attr , unlist ,attr 본문

Python/R

R함수 basic001: 사용법: ggplot2, ?qplot ,table,read_excel, read.csv, str , summary , head , dim , list , typeof , attr , unlist ,attr

최무회 2020. 6. 3. 18:40
# install.packages("installr")
# install.packages('RmecabKo') # C++ 기반으로 함,
# install.packages("ggplot2")
# install.packages("readxl")
# install.packages("dplyr")
# install.packages("rJava")
## tt: ggplot2, ?qplot ,table,read_excel, read.csv, str , summary , head , dim , list , typeof , attr , unlist ,attr 사용법:
## ############################################################
# ## tt: ggplot2, ?qplot ,table,read_excel, read.csv, str , summary , head , dim 

# ## library import 
# library(ggplot2)
# x <- c('a','b','c','d','a')
# x
# qplot(x)
# table(x)
# ------------------------------------------------------------
# ## mpg testData 
# # qplot(data = mpg, x=hwy)
# # qplot(data = mpg, x=cty)
# # qplot(data = mpg, x=drv, y=hwy, geom = 'line')
# # qplot(data = mpg, x=drv, y=hwy, geom = 'boxplot')
# qplot(data = mpg, x=cty, y=hwy, geom = 'line',colour = drv)
# ?qplot
# library(readxl)
# # df_exam <- read_excel("d:/app_src/anaconda/00.Data/2020-05-28_????????_naverNews000.xlsx",col_names =F, sheet = 2) 
# # df_exam <- read_excel("d:/app_src/anaconda/00.Data/2020-05-28_????????_naverNews000.xlsx")
# # df_exam$`_press_title`
# df_csv_exam <- read.csv("d:/app_src/anaconda/00.Data/newsDT/(18-25)????移섍???????.csv", stringsAsFactors = F)
# # df_csv_exam
# # View(df_csv_exam)
# 
# str(df_csv_exam)     
# summary(df_csv_exam) 
# head(df_csv_exam ,2) 
# dim(df_csv_exam)     
# ------------------------------------------------------------
# ## tt: list , typeof , attr , unlist ,attr
# # myvector <- c(1:6,'a')
# # myvector
# #
# # mylist <- list(1:6,'a')
# # mylist
# # obj1 <- 1:4
# # obj2 <- 6:10
# # obj3 <- list(obj1,obj2)
# # mylist <- list(obj1,obj2,obj3)
# # mylist
# # typeof(mylist[3])         # "list"
# # typeof(mylist[[3]])         # "list"
# # print(mylist[[3]])
# # typeof(mylist[[3]])         # "list"
# # typeof(mylist[[3]][1])      # "list"
# # typeof(mylist[[3]][[1]])    #  factor
# # name1 <- "Donald"
# # space1 <- " "
# # name2 <- "Trump"
# # lst <- list(name1,space1,name2)
# # lst[[3]]
# ------------------------------------------------------------
# # # typeof(unlist(lst))
# # gender <- c(2,1,1,2)
# # mydata <- data.frame(name,gender)
# # mydata
# ------------------------------------------------------------
# # attr(mydata$name,"variable means") <-"???????????????? ????????"
# # mydata$name
# #
# # attr(mydata$gender,"variable means") <-"???????????????? ????????"
# #
# # myvalues <- gender
# #
# # for (i in 1:length(gender)){
# #   myvalues[i] <- ifelse(gender[i]==1, "????????","????????")
# #   }
# # attr(mydata$gender,"value means") <- myvalues
# # mydata$gender
# ------------------------------------------------------------
# mydata$gender
# attr(mydata$gender, "variable means")
# # attr(mydata$gender, "value means")[1]
# # mydata$gender.character <- attr(mydata$gender, "value means")
# mydata$gdcharacter <- attr(mydata$gender, "value means")
# mydata

Comments