본문 바로가기

Data Analytics

R practice script 20140128

persp> # (3) Visualizing a simple DEM model

persp>

persp> z <- 2 * volcano        # Exaggerate the relief

persp> x <- 10 * (1:nrow(z))   # 10 meter spacing (S to N)

persp> y <- 10 * (1:ncol(z))   # 10 meter spacing (E to W)

persp> ## Don't draw the grid lines :  border = NA

persp> par(bg = "slategray")

persp> persp(x, y, z, theta = 135, phi = 30, col = "green3", scale = FALSE,

persp+       ltheta = -120, shade = 0.75, border = NA, box = FALSE)

페이지 변경을 확인하기 위해 기다리는 중...

persp> # (4) Surface colours corresponding to z-values

persp>

persp> par(bg = "white")

persp> x <- seq(-1.95, 1.95, length = 30)

persp> y <- seq(-1.95, 1.95, length = 35)

persp> z <- outer(x, y, function(a, b) a*b^2)

persp> nrz <- nrow(z)

persp> ncz <- ncol(z)

persp> # Create a function interpolating colors in the range of specified colors

persp> jet.colors <- colorRampPalette( c("blue", "green") )

persp> # Generate the desired number of colors from this palette

persp> nbcol <- 100

persp> color <- jet.colors(nbcol)

persp> # Compute the z-value at the facet centres

persp> zfacet <- z[-1, -1] + z[-1, -ncz] + z[-nrz, -1] + z[-nrz, -ncz]

persp> # Recode facet z-values into color indices

persp> facetcol <- cut(zfacet, nbcol)

persp> persp(x, y, z, col = color[facetcol], phi = 30, theta = -30)

페이지 변경을 확인하기 위해 기다리는 중...

persp> par(op)

>

clear

clr

example(persp)

apply(m, dimcode, f, fargs)

y <- matrix( c(1,2), c(5,7,9))

y <- matrix( c(1,2), c(7,9))

y <- matrix( c(1,2), c(7,9))

j <- list(name="cho", salary="5800", union=T)

j

j$name

z <- vector(mode="list")

z

z[["abc"]]<3

z

j

x=-10:10

y=1/(1+exp(-x))

plot(x,y, type=T)

x

y

plot(x)

plot(y)

plot(x,y)

y-1/(1+exp(-2.4426*1-0.5445*2 +15.2034))

plot(y)

y=1/(1+exp(-2.4426*1-0.5445*2 +15.2034))

plot(y)

library(tcltk)

demo(tkdensity)

1+`1

;

1+1

exit;

:

;

;

1+1

cat (1-1, 1+1, 3, 5, 9*4)

"Arr, matey"

c <- "Arr, matey"

c

cat(c, x)

cat(c, "x")

tkpack

frame 2

frame2

demo(tkdensity)

T=TRUE

;

T==TRUE

;

T == TRUE ;

T == FALSE ;

F = FALSE;

winners <- read.delim(pipe('pbpaste'))

winners <- read.delim(pipe('pbpaste'))

winners <- read.delim(pipe('pbpaste'))

source('~/.active-rstudio-document')

view(winners)

View(winners)

View('winners')

wins <- read.delim('clipboard')

View(wins)

winx <- read.delim('clipboard')

View(winx)

seq(from-1, to=999, by=7)

seq(from=1, to=999, by=7)

re(1,100)

rep(1,100)

c(1,2,3,3,4,6)

c(seq(from=1, to=99, by=20), rep(1,100))

matrix(1:8, ncol=4)

matrix(1:128, ncol=4)

matrix(1:128, ncol=8)

matrix(1:128, ncol=8, byrow=TRUE)

matrix(1:128, ncol=10, byrow=TRUE)

matrix(1:150, ncol=10, byrow=TRUE)

matrix(1:150, ncol=10, byrow=TRUE)

warnings()

getwd()

install.packages("ade4")

library(ade4)

data(olympic)

print(data(olympic))

attach(olympic)

Turtles=read.table("D:/download/RRR/PaintedTurtles.txt",header=T)

Turtles

turtlem=Turtles[,2:4]

trutlem

turtlem

save(Turtles, file="Turtles.save")

save(turtlem, file="trutlem.save")

apply(turtlem,2,summary)

savehistory("~/r0002.Rhistory")

round(cov(trutlesc),2)

round(cor(turtlem),1)

round(cor(turtlem),2)

trutlesc=scale(turtlem)

round(cov(turtlem),2)

turtlesc=scale(turtlem)

round(cov(turtlesc),2)

require(ade4)

load("turtlem.save")

load("trutlem.save")

pca.turtles = dudi.pca(turtlem, scannf=F, nf=2)

print(pca.turtles)

scatter(pca.turtles)

pca.turtles

data <- read.table("D:/download/RRR/110707-ramen-data.txt", header=T)

data <- read.table("D:/download/RRR/110707-ramen-data.txt", header=T)

data <- read.table("D:/download/RRR/110707-ramen-data.txt", header=T)

data <- read.table("D:/download/RRR/110707-ramen-data.txt", header=T)

data <- read.table("D:/download/RRR/110707-ramen-data.txt", header=T)

data

mean(data)

getwd()

setwd("D:\\jacob\\R_working_dir\\shiny\\06_ShinyDash_sample")

getwd()

dir

dir()

library(shiny

)

runApp("D:\\jacob\\R_working_dir\\shiny\\06_ShinyDash_sample")

install.packages("shinyDash")

library(shinyDash)

version()

version

runApp("06_ShinyDash_sample")

runApp("D:\\jacob\\R_working_dir\\shiny\\06_ShinyDash_sample")

runApp("D:\\jacob\\R_working_dir\\shiny\\04_Dataset_exploration_tool")

diamonds

diamonds[1]

diamonds[,10]

diamonds[1,10]

diamonds

diamonds[3]

diamonds[,3]

diamonds[1,]

diamonds[c(1:3),]

diamonds[1:3,]

diamonds[1:10,]

diamonds[10,]

diamonds[~10,]

diamonds[-10,]

diamonds[10,]

diamonds[1:10,]

runApp("D:\\jacob\\R_working_dir\\shiny\\04_Dataset_exploration_tool")

runApp("D:\\jacob\\R_working_dir\\shiny\\04_Dataset_exploration_tool")

diamonds

dataset <- diamonds

dataset

dataset[1:10,]

dataset[1:100,]

nrow(dataset)

ncol(dataset)

names(dataset)

names(dataset)[[2]]

names(dataset)[1

]

names(dataset)[1:2, ]

names(dataset)[1:2 ]

names(dataset)[1:5]

dataset[1:10,]

names(dataset)

names(dataset)[1]

names(dataset)[[1]

]

names(dataset)[2]

names(dataset)[[2]]

names(dataset)[[2],]

names(dataset)[[2],1]

names(dataset)[[2],[1]

c('NONE', names(dataset))

names(dataset)

c(None='.', names(dataset))

plotOutput('plot')

matrix(1:2, 3,4)

matrix(1:62, 3,4)

matrix(1:6, 3,4)

n = c( 2,3,5)

s = c ( "aa", "bb", "cc")

b = c(TRUE, FALSE, TRUE)

df = data.frame(n,s,b)

n

s

b

df

names(df)

mtcars

mtcars[1:3, ]

mtcars[1,2]

mtcars["Datsun 710", "cyl"]

mtcars["Ferrari Dino"]

mtcars["Ferrari Dino",]

mtcars[("Ferrari Dino", "Datsun 710"),]

mtcars[c("Ferrari Dino", "Datsun 710"),]

c(nrow(mtcars), ncol(mtcars)

;

c(nrow(mtcars), ncol(mtcars))

help(mtcars)

require(graphics)

pairs(mtcars, main = "mtcars data")

coplot(mpg ~ disp | as.factor(cyl), data=mtcars, panel=panel.smooth, rows=1)

coplot(mpg ~ hp | as.factor(cyl), data=mtcars, panel=panel.smooth, rows=1)

coplot(mpg ~ disp | as.factor(cyl), data=mtcars, panel=panel.smooth, rows=1)

coplot(mpg ~ disp | as.factor(gear), data=mtcars, panel=panel.smooth, rows=1)

coplot(mpg ~ disp | as.factor(qsec), data=mtcars, panel=panel.smooth, rows=1)

coplot(mpg ~ cyl | as.factor(qsec), data=mtcars, panel=panel.smooth, rows=1)

coplot(mpg ~ disp | as.factor(am), data=mtcars, panel=panel.smooth, rows=1)

coplot(mpg ~ wt | as.factor(), data=mtcars, panel=panel.smooth, rows=1)

coplot(mpg ~ wt | as.factor(mpg), data=mtcars, panel=panel.smooth, rows=1)

coplot(mpg ~ wt | as.factor(cyl), data=mtcars, panel=panel.smooth, rows=1)

# mpg ~ wt 의 관계를 cyl 값 별로 그려 보여줌

# as.factor의 값은 distinct 값이 현저히 낮은 경우 3 ~ 5 개정도가 적당할 듯

savehistory("D:/jacob/R_working_dir/20140129_script.Rhistory")

head(mtcars)

head(USArrests)

mtcars[[9]]

mtcars

names.mtcars[[9]]

mtcars[[9]].names

mtcars[[9]].names()

mtcars[[am]]

mtcars[["am"]]

mtcars[["wt"]]

mtcasr$wt

mtcars$wt

mtcars$c("wt", "am"

)

mtcars$c("wt", "am")

mtcars$wt

mtcars$wt - mtcars$am

mtcars$wt - mtcars$mpg

mtcars$mpg - mtcars$wt

head(mtcars)

mtcars[[6]]

mtcars[[wt]]

mtcars[["wt"]]

mtcars$wt

mtcars[,"am"]

head(mtcars)

mtcars[1]

mtcars[c("mpg", "hp")]

mtcars[24,]

mtcars[c(1,2,3,14,27),]

mtcars[c("Datsun 710", "Camaro Z28"),]

mtcars$am == 0

L = mtcars$am == 0

L

mtcars[L,]

mtcars[mtcars$am == 0, ]

mtcars[mtcars$wt >= 3, ]

mtcars[mtcars$wt >= 3 and mtcars$wt <5, ]

mtcars[(mtcars$wt >= 3, mtcars$wt <5), ]

mtcars[(mtcars$wt >= 3 and mtcars$wt <5), ]

mtcars[(mtcars$wt >= 3 | mtcars$wt <5), ]

mtcars[(mtcars$wt >= 3 & mtcars$wt <5), ]

mtcars[(mtcars$wt >= 3 && mtcars$wt <5), ]

mtcars[(mtcars$wt >= 3 & mtcars$wt <5), ]

mtcars[(mtcars$wt >= 3 & mtcars$wt <5) & mtcars$mpg > 18, ]

savehistory("D:/jacob/R_working_dir/20140129_script.Rhistory")







'Data Analytics' 카테고리의 다른 글

http://www.r-tutor.com/  (0) 2014.01.29
shinyUI(pageWithSidebar  (0) 2014.01.29
비쥬얼라이제이션 스터디  (0) 2014.01.28
matrix in R  (0) 2014.01.27
http://cafe.naver.com/datageeks  (0) 2014.01.27