can't find Objects using pubmed.mineR package - r

I have downloaded abstracts of interest from pubmed.com then read them using pubmed.mineR package with readabs() function. which is supposed to create object of class "Abstracs", but when I type in ls(), it gives me character(0).
I want to search abstracts using searchabsL(Object,include="protein"),though i don't know how?

mystery solved x = readabs("downloaded file")
thanks Dr.Ramachandran for providing the answer.

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.

Plotting GTFS object routes with tidytransit in R

I need to plot General transit Feed Specification (GTFS) object routes and their frequencies. For this purpose I have run the following code from the package manual https://cran.r-project.org/web/packages/tidytransit/tidytransit.pdf
to get some practice. But although the code is taken from the manual, I do get the error below. Is there anyone who can clarify this issue and show me an alternative way to perform spatial analysis?
library(tidytransit)
local_gtfs_path <- system.file("extdata",
"google_transit_nyc_subway.zip",
package = "tidytransit")
nyc <- read_gtfs(local_gtfs_path,
local=TRUE)
plot(nyc)
Error in UseMethod("inner_join") :
no applicable method for 'inner_join' applied to an object of class "NULL"
thanks for posting this!
this happened because we made a change in the API and I think the docs you were looking at were out of sync. they should be up to date now. see http://tidytransit.r-transit.org/articles/introduction.html
also, we made a change so that the plot() function will work as specified in the old docs and in the new docs.

problems with multiDiv in paleotree package

I am trying to use the package paleotree to build LTT plots, but I get the following error when I try to input my trees.
a=read.tree(file.choose()) # to choose newick/nexus file
multiDiv(a)
Error in multiDiv(a) : Data of Unknown Type
Does paleotools only take objects of class 'multiphylo' ? I converted the imput tree to class multiphylo, but it still gives the same error. Can anyone suggest how to go about it?
I'm the author of package paleotree. I think what is going on here is that you are passing a single tree to multiDiv, which is setup for analyzing lists of objects, each of which are converted to a diversity curve. You probably want phyloDiv() instead. I can't be certain without know more about your data.

what is the package of the car() function in R

I'm actually developping in R using RStudio. I just want to know in which package is located the function called car() which is used to extract the first element of a list .
Thanks
I don't know what package it's in. But here's how I'd go about finding out...
RSiteSearch("car", restrict = "functions")
or
library(sos)
findFn("car", sortby = "Function")
apropos() and help.search() are also worth looking into.
By the way, in general the first element in a list can be extracted with [[1]]

Save package settings between sessions

Is there a definitive way to save options or information pertaining to a certain package between sessions?
For example say somebody made a game and released it as an R package. If they wanted to save high scores and not have them reset each time R started a new session what would be the best way to do this? Currently I can only think of storing a file in the users home directory but I'm not sure if I like that approach.
This may be an approach. I created a dummy package with a dummy function (any function I create is bound to be a dummy function) and a data set I called scores that I set as follows:
scores <- NA
Then I created the package with the scores data set.
Then I used the following to change the data set from within R.
loc <- paste0(find.package("new"), "/Data")
unlink(paste0(loc, "/scores.rda"), recursive = TRUE, force = FALSE)
scores <- 10
save(scores, file=paste0(loc, "/scores.rda"))
Then when I unloaded the library and re loaded agin the data set now says:
> scores
[1] 10
Could this be modified to do what you want? You'd have to have it save in between somehow but am not sure on how to do this without messing with .Last function.
EDIT:
It appears this option is not viable in that when you compile as a package and use lazy load it saves the data sets as:
RData.rbd, RData.rbx, not as .rda files. That means the approach I use above is kinda worthless in that we want it to automatically be recognized.
EDIT2
This approach works and I tried it on a package I made. You can't do lazy load of the data and you have to either explicitly use data(scores) or use data(scores) inside of the function you're calling. I also assigned scores to .scores int he global.env the first time it was created and used exists inside the function to see if it exists. If `.scores. existed I assigned that to scores within the function. Once you unload the library and laod again you never have to worry about that again.
Maybe an alternative is to save this as a function somehow that can be altered using Josh's advice here: Permanently replacing a function
I guess there is no way to store settings without saving them to disk or a database, some way or another. It can be done silently though by putting the code below in your ~/.Rprofile. However, if you have packages that save settings in other ways than using options you need to add them manually.
I know this is exactly what you said you did not want, but it might spark some debate at least.
.Last <- function(){
my.options <- options()
save(my.options, file="~/.Roptions.Rdata")
}
.First <- function(){
tryCatch({
load("~/.Roptions.Rdata")
do.call(options, my.options)
rm(my.options)
}, error=function(...){})
}
To my suprise try(..., silent=TRUE) gives a warning on startup if ~/.Roptions.Rdata does not exist, which is why I used tryCatch instead.
The modern answer to this problem is well explained at https://blog.r-hub.io/2020/03/12/user-preferences/
I think I will be trying the hoardr package! Here is an example that worked for me :)
x <- hoardr::hoard()
x$cache_path_set("yourpackage", type = 'user_cache_dir')
x$mkdir()
scores<-data.frame(
user=c("one","two","three"),
score=c("500,200,1100")
)
save(scores,file = file.path(x$cache_path_get(), "scores.rdata"))
x$list()
x$details()
#new session
x <- hoardr::hoard()
x$cache_path_set("yourpackage", type = 'user_cache_dir')
x$list()
x$details()
load(file = file.path(x$cache_path_get(), "scores.rdata"))
PS - you can see a working example in the rnoaa package found on at github "opensci/rnoaa". Check their R/onload.r file! I can expand if needed.

Resources