This is my day 5 homework for BIC by 生信星球.
Today's content is the introduction of data structure.
Before study, gain the demo data from wechat public account.
tips:
(1) the assignment symbol for R is <-, which can also be replaced by =. This answers my question in previous study.
(2) console equals command line in Linux
(3) the code in R includes (), which must be English input
(4) getwd() shows the working directory
(5) vector is made up of element which can be number or string
(6) table is called data frame (df) in R
(7) read help document by ?read.table, try example
(8) data type, focus on vector and data frame
the associations among variable, item, vector.
x<- c(1,2,3)
x<- 1:10 # from 1 to 10 , 10 integers
(1) by location
x[4] # the 4th item in x
x[-4] # reverse choose, exclude the 4th item in x and include others
x[2:4] #from 2nd to 4th
x[-(2:4)] # reverse choose
x[c(1,5)] # the 1st and 5th
(2) by value
x[x==10] # item equals 10 in x
x[x<0] # items less than 0 in x
x[x %in% c(1,2,5)] # items in vector c(1,2,5)
the demo data must be in the working directory
read.table(file = "huahua.txt", sep = "\t", header = T)
a <- read.table(file = "huahua.txt", sep = "\t", header = T)
colnames(a) #check the colunm name
rownames(a) # check the line name
dim(a) #check the structre of data frame
write.table(a, file = "yu.txt", sep = ",", quote = F)
save.image(file="bioinfoplanet.RData") #save current image
save(a,file="test.RData") # save a as test.RData
load("test.RData") # load test.RData
by $ symbol
by location of coordinate
a[x,y]
by name of colunm
a[x,]
a[,y]
a[c(a,b)] #a colunm and b colunm
plot(iris$Sepal.length, iris$Sepal.Width)
save(a,file="test.RData") report: object a not found
check whether the object a is in the right-up section of Rstudio
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。