R do.call object not found - r

I'm trying to duplicate a text mining example on text mining Twitter data using R programming language found in
Section 10.2 of Yanchang Zhao's paper R and Data Mining: Examples and Case Studies. Zhoa includes a Twitter data sample rmdTweets.RData so the user doesn't have to get the Twitter data directly from Twitter website.
Zhoa's Twitter sample "rmdTweets.RData" is downloaded to my computer; the required R packages 'tm' and 'twitteR' have been loaded without error; and the working directory has been set to the directory containing "rmdTweets.RData", i.e. setwd("F:/R/Test tm/Twitter_Data/") .
When running this command from Zhoa's paper
df <- do.call("rbind", lapply(rdmTweets, as.data.frame))
I get the error:
Error in lapply(rdmTweets, as.data.frame) : object 'rdmTweets' not found
Can you help me with this error?
Also, I'm new to R and am having trouble finding help on the do.call function written in 'beginner' language, so I can understand "rbind" and lapply

You need to load the data file in first.
load("rmdTweets.RData")

Related

Run a library on R while having the data in a different folder

I have a very simple question I'm sure, but I can't find the solution, please someone help me!
I installed MixSIAR for R, which is a package for statistical analysis and I see that the library is in C:/Users/me/Documents/R/win-library/4.0/MixSIAR and the script works perfectly as long as my data is in the same folder MixSIAR, but if I want to have it in my Dropbox or any other folder in my PC it doesn't work, because I can't figure out how to write the path to "call" the package MixSIAR.
#library(MixSIAR) # Works but needs data to be in the same MixSIAR folder.
library("C:/Users/pingry/Documents/R/win-library/4.0/MixSIAR") # doesn't work
# Load consumer
mix.filename <- system.file("data", "contemp_turtles_Oahu_consumer.csv", package = "MixSIAR")
mix <- load_mix_data(filename=mix.filename,
iso_names=c("d13C","d15N","d34S"),
factors=NULL,
fac_random=NULL,
fac_nested=NULL,
cont_effects=NULL)
The error I get:
Error is in library("C:/Users/pingry/Documents/R/win-library/4.0/MixSIAR") :
there is no package called ‘C:/Users/pingry/Documents/R/win-library/4.0/MixSIAR’
enter image description here
Mr. Flick gave me the answer so here is the code fixed to have my data in my Dropbox and use the MixSIAR package:
library(MixSIAR)
# Load mix data
mix <- load_mix_data(filename=("data/contemp_turtles_2islands_consumer.csv"),
iso_names=c("d13C","d15N","d34S"),
factors="island",
fac_random=TRUE,
fac_nested=FALSE,
cont_effects=NULL)

Using speech to text with googlelanguageR produces NULL transcripts

I'm using the R package 'googleLanguageR' to transcribe various 30 second audio files (over 500 so want to automatize this). I've followed all the steps in the googleLanguageR tutorials, got my key, and authenticated through R.
I'm able to transcribe the test audio (.wav) that comes with the package, but whenever I apply the same function to my files (.mp3), I get NULL for both transcript and timings.
This is the code provided in tutorials:
# get the sample source file
test_audio <- system.file("woman1_wb.wav", package = "googleLanguageR")
gl_speech(test_audio)$transcript
If I use the same for my file, I get an empty element, so I've tried the following with no luck:
test_audio <- "/audio_location/filename.mp3"
gl_speech(test_audio)$transcript
Has anybody encountered a similar problem with this package or have any suspicions of why it produces NULL transcripts?

Error : could not find function "ImportMethodFrom"

I tried to run the code in Chapter 7 Data mining with R learning with case study book but I got an error in following line:
rankWorkflows(svm, maxs = TRUE)
The error was:
Error in as.character.default(X[[i]], ...) : no method for coercing
this S4 class to a vector
Then I searched on the internet and found following solution:
importMethodsFrom(GenomicRanges, as.data.frame)
and again again I got a new error:
Error: could not find function "importMethodFrom"
I searched a lot but I got nothing :(
You can try using library(sos) to find the packages where your function is located.
library(sos)
findFn("replaceherewithyourfunction")
Based on the answer of #Bea, there does not seem to be a importMethodsFrom anywhere in R. My guess is you found the call in a NAMESPACE file. Those files have different syntax than normal R scripts.
If you want to load a specific function from an R package (rather than all functions from a package), you can use libraryname::functionname instad of functionname in your code. In your case, replace as.data.frame with GenomicRanges::as.data.frame
If this does not work (for example because you don't have as.data.frame anywhere in your code), you can also load the whole GenomicRanges library with library(GenomicRanges)

How to find object 'corhelp' in r

I'm having trouble locating the packages for corhelp in R. This is what I get.
AdjMatHARD=abs(corhelp[restConnectivity,restConnectivity])>0.65+0.0
# Error: object 'corhelp' not found
Assuming you're following the code from YEAST
Gene Co-expression Network Analysis R Tutorial, corhelp is a variable defined in the code
corhelp=cor(datExpr,use="pairwise.complete.obs")
just search that page for corhelp to find it.

Error in exprs(eset)

I am trying to read probes from a dat file, put them in a vector then put the vector into a subset to be able to concatenate more data to it and write it in a CSV file. Here my piece of code:
library(Biobase)
library(affy)
affys <- read.csv("address of my dat file")
affys_vec <- as.vector(affys)[,1]
exprs(eset)[affys_vec,] -> sub.set
write.csv(sub.set,file="subset.csv")
However when I reach to the : exprs(eset)[affys_vec,] -> sub.set
I get the following error message:
** Error in exprs(eset) :
error in evaluating the argument object' in selecting a method for function 'exprs':
Error: object 'eset' not found **
Are there any suggestions please?
Thanks,
pqtm
See the vignette An introduction to Biobase and ExpressionSets available on your computer, once Biobase is installed, as
vignette(package="Biobase", "ExpressionSetIntroduction")
But the idea is that you have created eset by pre-processing some CEL or other vendor-specific files. How you pre-process those depends on what your files are, maybe with affy or oligo or lumi, or from a public repository using a package like ArrayExpress or GEOquery Or perhaps you're using limma and have no need for an expression set.
The Bioconductor web site and mailing list provides a lot more information.

Resources