Skip to content

Instantly share code, notes, and snippets.

@fomightez
Created February 9, 2024 20:10
Show Gist options
  • Save fomightez/1f30f333c20af531934694813a3268bf to your computer and use it in GitHub Desktop.
Save fomightez/1f30f333c20af531934694813a3268bf to your computer and use it in GitHub Desktop.
for SO https://stackoverflow.com/q/77969756/8508004 saying not rendering R kernel well
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "b67b90bb-13ab-441f-9ac7-84f626f2bcee",
"metadata": {
"tags": []
},
"outputs": [
{
"ename": "ERROR",
"evalue": "Error in read.xlsx(\"../data/data.xlsx\", sheet = \"fermentation\"): could not find function \"read.xlsx\"\n",
"output_type": "error",
"traceback": [
"Error in read.xlsx(\"../data/data.xlsx\", sheet = \"fermentation\"): could not find function \"read.xlsx\"\nTraceback:\n"
]
}
],
"source": [
"df.fer <- read.xlsx(\"../data/data.xlsx\",sheet='fermentation')\n",
"\n",
"# adjusting data, creating factors, adjusting data types, etc.\n",
"df.fer$`Volume.[Nml]` <- as.numeric(df.fer$`Volume.[Nml]`) # some text artifacts are present so as.numeric has to be used\n",
"df.fer$`disintegration.temp.[oC]` <- factor(df.fer$`disintegration.temp.[oC]`,\n",
" ordered=TRUE, levels=c('in.','b.d.','45','50','55','60'))\n",
"df.fer$`disintegration.time.[h]` <- factor(df.fer$`disintegration.time.[h]`,\n",
" ordered=TRUE,levels=c('in.','0','24','48'))\n",
"\n",
"# creating new factor to distinguish between case No and experiment included in a case\n",
"df.fer$case.exp <- factor(paste(df.fer$case.No, df.fer$experiment.No,sep='-'))\n",
"\n",
"\n",
"# changing the column names for simpler manipulation\n",
"df.fer.original.col.names <- colnames(df.fer) # just in case\n",
"df.fer.simlified.col.names <- c('day','volume','original.column.header','description','composition','inoculum.weight',\n",
" 'co-substrate.weight','dis.temp','dis.time','case','experiment','disintegration.tab','case.exp')\n",
"\n",
"colnames(df.fer) <- df.fer.simlified.col.names\n",
"\n",
"# removing one series - it turned out to be invalid\n",
"bad.series_case.exp <- '35-1' # it will be removed in some analyses\n",
"df.fer <- df.fer[df.fer$case.exp != bad.series_case.exp,]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ddeabcd3-6f3e-49df-b098-b67d91c08716",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "R",
"language": "R",
"name": "ir"
},
"language_info": {
"codemirror_mode": "r",
"file_extension": ".r",
"mimetype": "text/x-r-source",
"name": "R",
"pygments_lexer": "r",
"version": "4.3.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment