Import the Quandl's harmonized data into r - r

I'm looking for a way to import the Quandl's harmonized data into r.
I tried to use Quandl package with:
Quandl("RAYMOND/MSFT_COSTOFREVENUE_Q", trim_start="2009-06-27", trim_end="2014-03-29")
but with no luck so I tried:
Quandl("RAYMOND/MSFT_COST_OF_REVENUE_Q", trim_start="2009-06-27", trim_end="2014-03-29")
The error that I got is:
Requested entity does not exist. This could mean the code does not
exist or the parameters you have passed have returned an empty
dataset.
Any Idea?

It was a typo on the page you were looking at.
The call is:
Quandl("RAYMOND/MSFT_COST_OF_REVENUE_TOTAL_Q", trim_start="2009-06-27", trim_end="2014-03-29")

Related

Object not found error although column is in the table (data.table format)

I have defined a following function:
counter<-function(data,varname){
data[is.na(varname),.N]
}
When I pass the arguments:
counter(df,ip_address_ts)
I get the error:
Error in .checkTypos(e, names_x) : Object 'ip_address_ts' not found. Perhaps you intended ip_address_ts, email_address_ts
ip_address_ts is in df, so why does this not work?
Your code is looking the object ip_address_ts, not the string "ip_address_ts"
counter(df, "ip_address_ts")
Solution is to use get and then pass the column name as string:
counter<-function(data,varname){
data[is.na(get(varname)),.N]
}
counter(df,"ip_address_ts")
For this and other tips check out this link:
http://brooksandrew.github.io/simpleblog/articles/advanced-data-table/#3-functions
I happened to encounter the same error while working in R Studio, having checked the column exists in the data frame. Two things helped:
Restarting the session
Installing and loading the right package before running the code (In my case it
was the 'dplyr' package in order to use the filter() function).
I hope this helps

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.

Error in eval(expr, envir, enclos) : object 'score' not found

We have always been an SPSS shop but we're trying to learn R. Been doing some basics. I am trying to do a simple t-test, just to learn that code.
Here's my code, and what's happening:
Code screenshot
I don't get why it says "score" isn't found. It's in the table, and the read.csv code defaults to assuming the first row contains headers. I can't see why it's not "finding" the column for score. I'm sure it's something simple, but would appreciate any help.
You didn't store your imported csv file in a variable. It printed to the console because it had nowhere else to go - it just gets printed and then thrown away. You need to assign it for it to be saved in memory:
my_data_frame <- read.csv("ttest.csv")
Now your data exists in the variable my_data_frame and you can use it by supplying it as the data argument:
t.test(score ~ class, mu=0, alt="two.sided", conf=0.95, var.eg=F, paired=F, data=my_data_frame)
Also, in general, I would recommend using read_csv from the package readr over the default read.csv - it's faster.
Finally, when you ask questions, please provide your code as text, not a picture. You should also provide your data or a toy dataset - you can use the function dput to print code that will create your data, or just provide the csv file or some code that creates toy data.

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)

KFAS package; error with documentation code

This is an example from the KFAS manual page 13. I just tried a copy/paste and this was the result. Any idea what the problem is?
There were additional errors with the rest of the example.
> require(KFAS)
Loading required package: KFAS
> data(GlobalTemp)
> model<-SSModel(GlobalTemp~SSMtrend(1,Q=NA,type= common ),H=matrix(NA,2,2))
Error in ts(x) : object is not a matrix
Did you copy the example by hand? The line in the manual (at least this one: http://cran.r-project.org/web/packages/KFAS/KFAS.pdf) uses this command:
require(KFAS)
data(GlobalTemp)
model<-SSModel(GlobalTemp~SSMtrend(1,Q=NA,type='common'),H=matrix(NA,2,2))
With the ' around common (and it works fs)
However you should have got the "common not found" error message, not the one you quote (except you already have an object named common in your environment), so I don't really know if this answer will help you.

Resources