Is there any way, given a function passed as a parameter, to alter its input parameter string before evaluating it?
Here's pseudo-code for what I'm hoping to achieve:
test.func <- function(a, b) {
# here I want to alter the b expression before evaluating it:
b(..., val1=a)
}
Given the function call passed to b, I want to ad...
I have an example function below that reads in a date as a string and returns it as a date object. If it reads a string that it cannot convert to a date, it returns an error.
testFunction <- function (date_in) {
return(as.Date(date_in))
}
testFunction("2010-04-06") # this works fine
testFunction("foo") # this returns an erro...
I have a simple two vector dataframe (length=30) that looks something like this:
> mDF
Param1 w.IL.L
1 AuZgFw 0.5
2 AuZfFw 2
3 AuZgVw 74.3
4 AuZfVw 20.52
5 AuTgIL 80.9
6 AuTfIL 193.3
7 AuCgFL 0.2
8 ...
I'd like to use each of the rows to form 30 single value numeric vectors with the name of the v...
Hi all,
I am trying:
install.packages("RGoogleDocs", repos = "http://www.omegahat.org/R")
As suggested here, but it doesn't work.
I ended up manually downloading the file from here.
What other ways are there for me to get to the file directly?
Thanks,
Tal
...
I have several .csv files with similar filenames except a numeric month (i.e. 03_data.csv, 04_data.csv, 05_data.csv, etc.) that I'd like to read into R.
I have two questions:
Is there a function in R similar to
MATLAB's varname and assignin that
will let me create/declare a variable name
within a function or loop that will allow me to...
I just came a cross this nice code that makes this scatter matrix plot:
And wanted to implement it to a likret scale variables (integers of 1 to 5) by making the dot's sizes/colors (in the lower triangle) differ according to how many options of that type occurs (like the effect the jitter might have given me).
Any idea on how to do t...
I have three vectors in an xts R object. Call them V1, V2, V3. After merging, the order of them left to right is V2, V3, V1. How do I re-arrange them so they read (from left to right) as V1, V2, V3?
...
ie, if the factor variable is Climate, with 4 possible values: Tropical, Arid, Temperate, Snow, and a node in my rpart tree is labeled as "Climate:ab", what is the split?
...
I'm looking for a book (or other media) which provides an overview of statistics that is both comprehensive (covering all the basic/intermediate concepts) and comprehensible (which, for me, means not being weighed down with unnecessary and especially un-introduced mathematical symbology).
Can anyone offer suggestions?
...
I've a question about using sqlSave. How does R map RODBC data in the data frame to the database table columns?
If I've a table with columns X and Y and a data frame with columns X and Y, RODBC puts X into X and Y into Y (I found out by trail-and-error). But can I explicitly tell R how to map data.frame columns to database table columns...
i tried to find a built-in for geometric mean but couldn't.
(Obviously a built-in isn't going to save me any time while working in the shell, nor do i suspect there's any difference in accuracy; for scripts i try to use built-ins as often as possible, where the (cumulative) performance gain is often noticeable.
In case there isn't one ...
Can you pass by reference with "R" ?
for example, in the following code:
setClass("MyClass",
representation(
name="character"
))
instance1 <-new("MyClass",name="Hello1")
instance2 <-new("MyClass",name="Hello2")
array = c(instance1,instance2)
instance1
array
instance1@name="World!"
instance1
array
the output is
> ins...
I am using ESS in Windows XP. I have noticed that shell.exec is much slower with ESS than with RGui (the problem occurs when I try help(ls) for example, the help is displayed much faster in RGui, I tracked it down and it is due to shell.exec). Is there any reason for this? How can I fix it? My default browser is Firefox.
...
Here is some example data:
data = data.frame(series = c("1a", "1b", "1e"), reading = c(0.1, 0.4, 0.6))
> data
series reading
1 1a 0.1
2 1b 0.4
3 1e 0.6
Which I can pull out selective single rows using subset:
> subset (data, series == "1a")
series reading
1 1a 0.1
And pull out multiple rows usin...
I have a timeseries of samples in R:
> str(d)
'data.frame': 5 obs. of 3 variables:
$ date: POSIXct, format: "2010-03-04 20:47:00" "2010-03-04 21:47:00" ...
$ x : num 0 10 11 15.2 20
$ y : num 0 5 7.5 8.4 12.5
> d
date x y
1 2010-03-04 20:47:00 0.0 0.0
2 2010-03-04 21:47:00 10.0 5.0
3 2010-03-04 22:47...
I have the following data set that I am trying to plot with ggplot2, it is a time series of three experiments A1, B1 and C1 and each experiment had three replicates.
I am trying to add a stat which detects and removes outliers before returning a smoother (mean and variance?). I have written my own outlier function (not shown) but I e...
As you would expect from a DSL aimed at data analysis, R handles missing/incomplete data very well, for instance:
Many R functions have an 'na.rm' flag that you can set to 'T' to remove the NAs:
mean( c(5,6,12,87,9,NA,43,67), na.rm=T)
But if you want to deal with NAs before the function call, you need to do something like this:
to r...
Suppose that I have a data frame with a column whose name is stored in a variable. Accessing this column using the variable is easy using bracket notation:
df <- data.frame(A = rep(1, 10), B = rep(2, 10))
column.name <- 'B'
df[,column.name]
But it is not obvious how to access an arbitrary column using a call to with(). The naive appr...
I am interested in analyzing balance sheets and income statements using R. I have seen that there are R packages that pull information from Yahoo and Google Finance, but all the examples I have seen concern historical stock price information. Is there a way I can pull historical information from balance sheets and income statements using...
Hi all,
This is a "big" question, that I don't know how to start, so I hope some of you can give me a direction. And if this is not a "good" question, I will close the thread with an apology.
I wish to go through the database of Wikipedia (let's say the English one), and do statistics. For example, I am interested in how many active ...