Displaying 20 results from an estimated 3000 matches similar to: "lapply across using multiple columns"
2009 Aug 30
2
aggregating irregular time series
Hi,
I have a couple of aggregation operations that I don't know how to
accomplish. Let me give an example. I have the following irregular
time series
time x
10:00:00.021 20
10:00:00.224 20
10:00:01.002 19
10:00:02:948 20
1) For each entry time, I'd like to get sum of x for the next 2
seconds
2009 Aug 12
1
Smart way to sum a column in a matrix across all members in a list
Hi,
I have a list that contains about 100 elements. Each element contains
the following matrix structure
a b
1 1 4
2 2 5
3 3 6
I'd like to sum column b across all elements. I'm thinking of using
lapply or sapply but cannot get it to work. Any help would be really
appreciated. Thank you.
adschai
2009 Aug 30
2
POSIX time conversion doesn't display digit
Hi,
I have the following string that I converted to a POSIXct:
> a <- "2009-08-24 10:00:00.213"
> a.p <- strptime(a,"%Y-%m-%d %H:%M:%OS")
> as.double(as.POSIXct(a.p))
[1] 1251122400
I can't seem to get the decimal fraction of .213 out by casting to
double or numeric. Is there anyway to make sure that POSIXct spits
that out? Thank you.
adschai
2009 Jun 23
1
Smart way to check if a column with certain name exists in a data.frame
Hi,
I have a matrix or data.frame (df). When I would like to check if a column
named "x" exists, it becomes my habit to do the following:
if (length(which(colnames(df)=="x"))>0)
Is there any smarter way to do this? Thank you.
adschai
[[alternative HTML version deleted]]
2009 Jun 28
1
Defining class as a member of another class
Hi,
When I define a new class (through setClass), members defined in
representation argument doesn't seem to like a class. For example, if
I do the following:
setClass("NotWork",representation=(x="zoo"))
It seems to me that representation members will take in only primitive
type to R. Is there any way to stuff a class as a member in another
class? Thank you.
- adschai
2009 Jun 21
1
Need help installing xts package
Hi,
I am trying to install package xts. I am using OPENSUSE 11 64 bit. When I
invoke:
install.pacakges("xts",dependencies=T)
I received a lot of "ERROR: compilation failed for package" errors when R
tries to install xts dependencies. I do not understand this behavior.
I notice one thing. It complains.
ERROR: compilation failed for package 'Hmisc'
** Removing
2009 Oct 30
3
Fast optimizer
Hi,
I'm using optim with box constraints to MLE on about 100 data points.
It goes quite slow even on 4GB machine. I'm wondering if R has any
faster implementation? Also, if I'd like to impose
equality/nonequality constraints on parameters, which package I should
use? Any help would be appreciated. Thank you.
rc
2009 Jun 25
1
Can hist plot % of count instead of raw count?
I do not want to use histogram because I have more control over base graphs
that R provide. I'm wondering if hist function provides a parameter that can
set y axis as % of count instead of raw count?
If not, I'd like to know how I can add text or line on histogram function? I
don't like the idea of having to use raw coordinates to set text position.
Thank you.
adschai
[[alternative
2009 Oct 06
2
how to fit time varying coefficient regression model?
Hi - I read through dse package manual a bit. I'm not quite certain
how I can use it to estimate a time varying coefficient regression
model? I might pick up an inappropriate package. Any suggestion would
be greatly appreciated. Thank you.
rh
2010 Aug 12
1
Need help to understand integrate function
Hi,
I'm running into a wall when trying to use the integrate function. I
have the following setting:
powerLaw2 <- function(x,l1,l2,c0,t0) {
idx <- which(x <= 0);
if (length(idx) > 0) {
x[idx] <- 0;
}
xl <- (-l1+l2)*log(x/t0);
L <- log(c0)-l1*log(x)-log(1+exp(xl));
L <- exp(L);
return(L);
}
plCDF2 <- function(x,l1,l2,c0,t0) {
2010 Mar 30
1
Adding RcppFrame to RcppResultSet causes segmentation fault
Hi,
I'm a bit puzzled. I uses exactly the same code in RcppExamples
package to try adding RcppFrame object to RcppResultSet. When running
it gives me segmentation fault problem. I'm using gcc 4.1.2 on redhat
64bit. I'm not sure if this is the cause of the problem. Any advice
would be greatly appreciated. Thank you.
Rob.
int numCol=4;
std::vector<std::string>
2009 Jun 25
1
apply on xts
Hi,
I do not understand why after I called apply on a function that returns an
xts (getIdvAdjSeries) it returns a matrix whose columns are just numeric
value of time series in xts instead of a list of xts objects.
Basically, I called the following:
apply(matrix(tickers,ncol=1),1,FUN=getDivAdjSeries)
getDivAdjSeries <- function(ticker) {
seriesName <-
2007 Aug 19
1
Question on R server and TinnR
Hi -
Classic question that I tried to look up online and couldn't find a clear answer. It seems that I can have R to act as a server. But I never know how this works. Would anyone please provide an example or introduction material where I can learn about this? I'm trying to build an environment where computation are distributed/delegated among different servers requested whenever I need.
2007 Aug 20
2
how to collapse a list of 1 column matrix to a matrix?
Hi,
I encounter a situation where I have a list whose element is a column matrix. Says,
$'1'
[,1]
1
2
3
$'2'
[,1]
4
5
6
Is there fast way to collapse the list into a matrix like a cbind operation in this case? Meaning, the result should be a matrix that looks like:
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
I can loop through all elements and do
2007 Jul 05
2
Question for svm function in e1071
Hi,
Sorry that I have many questions today. I am using svm function on about 180,000 points of training set. It takes very long time to run. However, I would like it to spit out something to make sure that the run is not dead in between. Would you please suggest anyway to do so?
And is there anyway to speed up the performance of this svm function? Thank you.
- adschai
2007 Aug 13
1
Data structure in R
Hi,
I have a question around how to build data structure in R. I have to implement a tree structure of data. I'm wondering if R already has something like a tree where I can extend from or I need to start from scratch. If so, what would be the most effective way to represent parent and child node relationship? I realize that R is not based on pointer so it's quite a different paradigm for
2007 Jun 02
1
setClass with a slot of RODBC
Hi - I tried to get some answer before but there seems to have no one response. My question is that I have a class like below definition:
setClass("DBManager",
representation(channel="RODBC"))
My purpose of the conn slot is to hold a channel to database connection which is returned by a command like:
channel <- odbcConnect("DB", uid="user",
2007 Jun 09
1
How to plot vertical line
Hi,I have a result from polr which I fit a univariate variable (of ordinal data) with probit function. What I would like to do is to overlay the plot of my fitted values with the different intercept for each level in my ordinal data. I can do something like:lines(rep(intercept1, 1000), seq(from=0,to=max(fit),by=max(fit)/1000))where my intercept1 is, for example, the intercept that breaks between
2007 Jun 04
2
How to obtain coefficient standard error from the result of polr?
Hi - I am using polr. I can get a result from polr fit by calling
result.plr <- polr(formula, data=mydata, method="probit");
However, from the 'result.plr', how can I access standard error of the estimated coefficients as well as the t statistics for each one of them?
What I would like to do ultimately is to see which coefficients are not significant and try to refit the
2007 Apr 09
1
Dealing with large nominal predictor in sem package
Hi,
I am using tsls function from sem package to estimate a model which includes large number of data. Among its predictors, it has a nominal data which has about 10 possible values. So I expand this parameter into 9-binary-value predictors with the coefficient of base value equals 0. I also have another continuous predictor.
The problem is that, whenever I run the tsls, I will get 'System