R: plota.format() function - r

I was reading this article: Visualizing Tables with plot.table. In it there is a mention of a function plota.format(). I tried running that function with my data to see the visualization. But I am getting the following error:
Error: could not find function "plota.format"*
My question is: Which package does plota.format() belong to?
Thanks!

It doesn't seem like it's an actual package, but you can get it with the following (which I borrowed from the author's github
> library(RCurl)
> sit <- getURLContent(
'https://github.com/systematicinvestor/SIT/raw/master/sit.gz',
binary = TRUE, followlocation = TRUE, ssl.verifypeer = FALSE)
> con <- gzcon(rawConnection(sit, 'rb'))
> source(con)
> close(con)
> plota.format
The source code looks like it's not formatted as source code normally is, so I'm guessing this might be the only way. If you take a look at ls() now, you'll see you've got all the functions in the package so you might want to save them.

It appears to be in the package Systematic Investor Toolbox, described in the link you posted. You can view it on GitHub here.

Related

Create CYT object in CytoTree in R

I want to create a CytoTree CYT object in R to analyse my .FCS files. When I am using the Quick start code in the package description, I will always get an error when running the createCYT() function that says:
Error in createCYT(raw.data = fcs.data, normalization.method = "log") :
2022-09-26 15:46:26 meta.data must be a data.frame
As the function should not rely on any meta data and that object is optional, I do not know how to solve the error.
Here is the description:
https://ytdai.github.io/CytoTree/quick-start.html#quick-start-code
I thank you very much in advance for your help!
BR
I have encountered same problem previously.
In the end it worked only when the data.frame was added (yes, even though it should not depend on it).
Here is how:
meta.data <- data.frame(cell = rownames(fcs.data), stage = gsub(".fcs.+", "", rownames(fcs.data)))
meta.data$stage <- factor(as.character(meta.data$stage))
You may as well have a look at the Cytotree PDF in case of more issues.

Base does not exist R

I have been trying to perform methylation data analysis, however I am stuck on the first few steps. I am trying to follow the workflow mentioned here and I am unable to read in my files as it gives me an error saying base does not exist.
library(methylationArrayAnalysis)
library(knitr)
library(limma)
library(minfi)
library(IlluminaHumanMethylation450kanno.ilmn12.hg19)
library(IlluminaHumanMethylation450kmanifest)
library(RColorBrewer)
library(missMethyl)
library(minfiData)
library(Gviz)
library(DMRcate)
library(stringr)
library(IlluminaHumanMethylationEPICanno.ilm10b4.hg19)
library(conumee)
dataDirectory <- "C:/Users/35389/Desktop/Medullos/All_combined/"
list.files(dataDirectory, recursive = TRUE)
target_EPIC <- read.metharray.sheet("C:/Users/35389/Desktop/Medullos/All_combined/", pattern = "sample_sheet_2.csv") #tried first with dataDirectory then put the link to files again by myself and still the same error of base does not exist
Error in read.metharray.sheet("C:/Users/35389/Desktop/Medullos/All_combined/", : 'base' does not exists
I have been trying to get around this error for a while now.
I tried to read in the methylation files directly using read.methyarray.exp() however, that way, it greatly reduces the dimensions of my data
I wonder if anyone of you has had any experiences with this and any help would be greatly appreciated! :)

Error : could not find function "collocations"

I need to create word cloud which include composed words. In this link Making a wordcloud, but with combined words?
I find the response where I should use quanteda library. I installed it but when I start to adapt the code posed in the above link here:
# detect the collocations
colls <- collocations(docs, n = 200, size = 2)
The program returns this error:
Error in collocations(docs, n = 1500, size = 2) : could not find
function "collocations"
It's really weird because according to https://www.rdocumentation.org/packages/quanteda/versions/0.9.6-9/topics/collocations
the docs should be a Corpus object which is the case :
> class(docs)
[1] "SimpleCorpus" "Corpus"
what do you think?
thank you for your suggestions !
Have u library() your package?
If u do not, try
library("quanteda")
textstat_collocations is the only function of that package similar to that you are looking for:
colls <- textstat_collocations(docs, n = 200, size = 2)
I think they just changed it's name. As you can see in the documentation:
https://cran.r-project.org/web/packages/quanteda/quanteda.pdf
There is only a textstat_collocations function.
When I added the fully qualified name from the documentation
myVar <- quanteda.textstats::textstat_collocations(.....)
RStudio installed the quanteda.textstats library and now is working.

Installing pdftotext on Windows (for use with R, 'tm' package)

I am having trouble using R, 'tm' package, to read in .pdf files.
Specifically, I try to run the following code:
library(tm)
filename = "myfile.pdf"
tmp1 <- readPDF(PdftotextOptions="-layout")
doc <- tmp1(elem=list(uri=filename),language="en",id="id1")
doc[1:15]
...which gives me the error:
Error in readPDF(PdftotextOptions = "-layout") :
unused argument (PdftotextOptions = "-layout")
I assume this is due to the fact that the pdftotext program (part of xpdf, http://www.foolabs.com/xpdf/download.html) has not been installed correctly on my machine, so that R cannot access it.
What are the steps to install xpdf/pdftotext correctly such that the above R code can be executed? (I am aware of similar questions already posted, however they don't address the same issue)
PdftotextOptions is no parameter of readPDF. readPDF has a control parameter, which expects a list. So correct use would be:
if(all(file.exists(Sys.which(c("pdfinfo", "pdftotext"))))) {
tmp1 <- readPDF(control = list(text = "-layout"))
doc <- tmp1(elem=list(uri=filename),language="en",id="id1")
}
Set
setwd('C:/xpdf/bin64')
It works for me.

issue with get_rollit_source

I tried to use get_rollit_source from the RcppRoll package as follows:
library(RcppRoll)
get_rollit_source(roll_max,edit=TRUE,RStudio=TRUE)
I get an error:
Error in get("outFile", envir = environment(fun)) :
object 'outFile' not found
I tried
outFile="C:/myDir/Test.cpp"
get_rollit_source(roll_max,edit=TRUE,RStudio=FALSE,outFile=outFile)
I get an error:
Error in get_rollit_source(roll_max, edit = TRUE, RStudio = FALSE, outFile = outFile) :
File does not exist!
How can fix this issue?
I noticed that the RcppRoll folder in the R library doesn't contain any src directory. Should I download it?
get_rollit_source only works for 'custom' functions. For things baked into the package, you could just download + read the source code (you can download the source tarball here, or go to the GitHub repo).
Anyway, something like the following should work:
rolling_sqsum <- rollit(final_trans = "x * x")
get_rollit_source(rolling_sqsum)
(I wrote this package quite a while back when I was still learning R / Rcpp so there are definitely some rough edges...)

Resources