Saturday, January 7, 2023

List of Important functions in R

  1.  Binding of different columns into one column: mutate(data,data=paste(col1,col2,col3))
  2. Round of your column: round(data$colname,2)
  3. Selection of a range of columns: data[,c(1:7)]
  4. Selection of random column: data [,c(1,2,3,4,5,7,9,10)]
  5. Deletion of column: data[,-c(7,9)]
  6. Rename of columns: names(datasoil)[c(5,6)]<-c("Organic matter","Water contents")
  7. Reorder levels of a factor: factor(data$mulches, levels=levels(data$mulches)[c(1,3,4,2)])
  8. View the level of a factor: levels(data$mulches)
  9. Row binding of two data sets: rbind(data1, data2)
  10. Column binding of two data sets: cbind(data1, data2)
  11. Conversion of variable into factor: irrigation <- factor(irrigation)
  12. Conversion of a variable into numeric: irrigation <- as.numeric(irrigation)
  13. Import CSV file: read.csv("data.csv",na="***")
  14. Frame a data set into columns and rows:data.frame(data)
  15. View structure of data: str(data)
  16. View top 06 rows of imported data set: head(data)
  17. View bottom 06 rows of imported data set: tail(data)
  18. View summary of data set: summary(data)
  19. View summary of single column: summary(dataset$height)
  20. Select one level of a factor: subset(dataset,irrigation=="normal")
  21. Install a package: Install.package(“knitr”)
  22. Install multiple packages: install.packages(c("knitr","emmeans"))
  23. Activate pacakge:library(knitr)
  24. Make histogram: hist(data$height)
  25. Descriptive statistics of a data: stat.desc(data)
  26. make A working directory: setwd("D:/foldername")
  27. Save plot in PNG file: ggsave("SOD.png", width = 20, height = 7)
  28. Group standard deviation table:tapply(POD,list(treatment, variety), sd)
  29. Save plot as PDF file: ggsave("SOD.pdf", width = 20, height = 7)
  30. Load R session: load(file= "D:/R-training/R-basic-Course-6/session")
  31. Save R Session: save(list = ls(all=TRUE), file= "D:/R-training//session")
  32. Export file as excel: writexl::write_xlsx(data,"summary.xlsx")
  33. View column of data :colnames(data)
  34. Subset by value: subset(data,height<34)
  35. Remove extra staff: rm(list = setdiff(ls(), "data"))
  36. De-attach data file: detach(data)
  37. Remove data files from environment: rm(list = ls())
  38. Descriptive statistics: describe(iris)
  39. Import excel file: import(" /Desktop/mbb.xlsx")
  40. Import text file: import(" /Desktop/mbb.txt")
  41. Import CSV file: import(" /Desktop/mbb.csv")
  42. View data file: View(data)
  43. Rainbow color view: barplot(seq(1:12), col=rainbow(12))
  44. Terrain color view: barplot(seq(1:12), col=terrain.colors(12))
  45. cm color view: barplot(seq(1:12), col=cm.colors(12))
  46. Heat color view: barplot(seq(1:12), col=heat.colors(12))
  47.  Topo color view: barplot(seq(1:12), col=topo.colors(12))
  48.  Brewer color: display.brewer.all(colorblindFriendly = TRUE)
  49.  Brewer color: display.brewer.all(colorblindFriendly = TRUE)
  50. Multiple plots view: par(mfrow=c(2,3))
  51.  Function demo in R: demo(graphics)
  52.  Find package for function in R: find("lowess")
  53.  Information about package: library(help=spatial)
  54.  Calculation of arithmetic mean: arithmetic.mean(y)
  55.  Calculation of Geometric mean: geometric(insects)
  56.  Calculation of Harmonic mean: harmonic(c(1,2,4,1))
  57. Calculation Variance: variance(y)
  58.  View history: history(Inf)
  59.  Cartesian: plot(x,y)
  60.  formula: plot(y x)




No comments:

Post a Comment