r 博客2015.10.18创建数据并绘制happy.R

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了r 博客2015.10.18创建数据并绘制happy.R相关的知识,希望对你有一定的参考价值。

img <- readJPEG(source =  "happy face.jpg") 
# Transform
g <- rasterGrob(image = img, interpolate=TRUE)


# create data 1 per ROI
noise_mean <- 0
noise_sd <- 10e-2 * .5

RightEye_n <- 200 + 2 + 25
RightEye_x <- 0.25 + rnorm(n = RightEye_n,mean = noise_mean, sd = noise_sd )
RightEye_y <- 0.65 + rnorm(n = RightEye_n,mean = noise_mean, sd = noise_sd )

LeftEye_n <- 200 + 2 + 25
LeftEye_x <- 0.45 + rnorm(n = LeftEye_n,mean = noise_mean, sd = noise_sd )
LeftEye_y <- 0.70 + rnorm(n = LeftEye_n,mean = noise_mean, sd = noise_sd )

Mouth_n <- 150 + 4 - 50
Mouth_x <- 0.4 + rnorm(n = Mouth_n, mean = noise_mean, sd = noise_sd )
Mouth_y <- 0.45 + rnorm(n = Mouth_n,mean = noise_mean, sd = noise_sd )

Nouse_n <- 100 + 10
Nouse_x <- 0.38 + rnorm(n = Mouth_n, mean = noise_mean, sd = noise_sd )
Nouse_y <- 0.55 + rnorm(n = Mouth_n,mean = noise_mean, sd = noise_sd )

Noise_n <- 20
Noise_x <- seq(from = 0.38,  to = 1, length.out = Noise_n) + 
  rnorm(n = Noise_n , mean = noise_mean, sd = noise_sd )
Noise_y <- 
  seq(from = 0.55,to =  1, length.out = Noise_n) + 
  rnorm(n = Noise_n , mean = noise_mean, sd = noise_sd )

x <- c(RightEye_x, Mouth_x, Nouse_x, LeftEye_x , Noise_x)  
y <- c(RightEye_y, Mouth_y, Nouse_y, LeftEye_y , Noise_y)

a <- data.table(x,y)
summary(a)
data2 <- a


jpeg(filename = "disgust with density plot.jpeg", res = 100,
     width = 18, height =10 ,units =  "cm")
print(p)
dev.off()

以上是关于r 博客2015.10.18创建数据并绘制happy.R的主要内容,如果未能解决你的问题,请参考以下文章

r Blog2015.10.18-Plot_by_Range.R

R:将日期从每天转换为每周并绘制它们

r 创建多个K-Means模型并绘制它们

R - 如何“创建”或绘制缺失数据?

Python计算KS值并绘制KS曲线

canvas炫彩小球爱心(博客园鼠标点击)