# myString <- "Hello world! - R.jsrun.net"
# print ( myString)
# dir.create("ggplot2")
# example(mean)
# getwd()
# a= c(1,2,3,4,5)
# avg<- mean(a)
# print(avg)
# 2+3*5
# x<- 4-pi/2
# x
# print(y<- x+1)
# round(y,2)
# p<- 0.2
# a<-p*0.3/2
# n<-1.96^2*p*(1-p)/a^2
# print(n)
# a=matrix(1:4,nrow=2)
# a
# rowMeans(a)
# rowSums(a)
# a[1:2,1:2]
# a=1:24
# dim(a)=c(3,4,2)
# a
# a1=c("row1","row2","row3")
# a2=c("col1","col2","col3","col4")
# a3=c("list1","list2")
# array(1:24,dim=c(3,4,2),dimnames=list(a1,a2,a3))
# list =list(a=1,b=1:5,c=c("1","2","你好"))
# list
# id=1:5
# sex=c("male","female","female","male","female")
# age=c("20","30","32","25","33")
# pain=c(1,3,2,2,3)
# pain.f=factor(pain,levels=1:3,labels=c("mild","medium","severe"))
# patients=data.frame(id,sex,age,pain.f)
# patients
# x=c(1,2,3,45)
# is.numeric(x)
# is.vector(x)
# y=as.character(x)
# y
# is.numeric(y)
# is.character(y)
# z=c(TRUE,FALSE,TRUE,FALSE)
# is.logical(z)
# as.numeric(z)
# if(FALSE) {
# "
# 这是一个多行注释的实例
# 注释内容放在单引号或双引号之间
# "
# }
# myString <- "Hello, World!"
# print ( myString)
# a=123
# b=456
# print(a+b)
# v <- c(2,4,6,9)
# t <- c(1,4,7,9)
# print(v>t)
# print(v < t)
# print(v == t)
# print(v!=t)
# print(v>=t)
# print(v<=t)
# v <- c(3,1,TRUE,2+3i)
# t <- c(4,1,FALSE,2+3i)
# print(v&t)
# print(v|t)
# print(!v)
#
# v <- c(3,0,TRUE,2+2i)
# t <- c(1,3,TRUE,2+3i)
# print(v&&t)
# v <- c(0,0,TRUE,2+2i)
# t <- c(0,3,TRUE,2+3i)
# print(v||t)
# round(1.5)
# round(2.6)
# round(3.5)
# round(4.5)
# ceiling(6.3)
# ceiling(6.6)
# floor(5.5)
# floor(-5.6)
# ceiling(-6.3)
# a=c(1,2,3,4,5,6)
# a[2]
# b=c(1,6,4,3,6,5)
# order(b)
# rev(a)
# sort(a)
# b=c(1,2,3,4,5,6)
# sd(b)
# var(b)
# range(b)
#
# a=c(1,2,3,4,1,2,1,3)
# b=a>2
# which(b)
# 2+3*5
# if(is.integer(x)){
# print("x是一个整数")}
# print("输出函数")
# x <- c("google","runoob","taobao")
# if("weibo" %in% x) {
# print("第一个 if 包含 weibo")
# } else if ("runoob" %in% x) {
# print("第二个 if 包含 runoob")
# } else {
# print("没有找到")
# }
# v <- c("Google","Runoob")
# cnt <- 2
# repeat {
# print(v)
# cnt <- cnt+1
# if(cnt > 5) {
# break
# }
# }
# v <- c("Google","Runoob")
# cnt <- 2
# while (cnt < 7) {
# print(v)
# cnt = cnt + 1
# }
# v <- LETTERS[1:4]
# for ( i in v) {
# print(i)
# }
# hs=function(a,b,c){
# sum=c(a,b,c)
# sum1=sort(sum)
# return (list(max=sum[3],min=sum[1],mid=sum[2]))
# }
# hs(5,9,6)
#
# result <- format(23.123456789, digits = 9)
# print(result)
#
# result <- format(c(6, 13.14521), scientific = TRUE)
# print(result)
#
# result <- format(23.47, nsmall = 5)
# print(result)
#
# result <- format(6)
# print(result)
#
# result <- format(13.7, width = 6)
# print(result)
#
# result <- format("Runoob", width = 9, justify = "l")
# print(result)
#
# result <- format("Runoob", width = 10, justify = "c")
# print(result)
# nchar("hello world")
# toupper("hello world")
# tolower("Hello World")
# str <- "Hello, World!"
# new_str <- gsub("World", "R", str)
# str <- "Hello, World!"
# split_str <- strsplit(str, ",")
# print(split_str)
# list_data <- list("runoob", "google", c(11,22,33), 123, 51.23, 119.1)
# print(list_data)
# 创建包含数字的向量
# numbers <- c(1, 2, 3, 4, 5)
#
# characters <- c("apple", "banana", "orange")
#
# merged_vector <- c(numbers, c(6, 7, 8))
# print(merged_vector)
#
# merged_characters <- c(characters, c("grape", "melon"))
# print(merged_characters)
# 列表包含向量、矩阵、列表
list_data <- list(c("Google","Runoob","Taobao"), matrix(c(1,2,3,4,5,6), nrow = 2),
list("runoob",12.3))
# 给列表元素设置名字
names(list_data) <- c("Sites", "Numbers", "Lists")
# 显示列表
print(list_data)