Displaying 20 results from an estimated 20000 matches similar to: "Display/show the evaluation result of R commands automatically"
2011 Aug 10
1
rbind/cbind
Dear list,
I wonder if there a better way to have rbind/cbind/append to create
the first element (if it is empty) instead of doing the following in a
loop?
for (i in 1:10) {
if (i == 1) {
aRow = SomeExpression(i)
} else {
aRow = rbind(aRow,SomeExpression(i))
}
}
Thanks
Anthony
2011 Aug 10
2
join columns
Dear R-help,
I wonder if you could give me some suggestions in how to do a union
join of two data frames as follow:
-> union join the common column, and insert a 0 if one is missing.
I made a function to perform the following, and I know it may not that
quite welly written, but it works.
Any suggestions are welcome, many thanks.
Anthony
> q1 =
2011 Aug 10
1
column names issue with read.csv
Dear List,
I wonder why when using read.csv(), if the column name contains a
numeric i.e. a stock symbols-"0001.HK", it will automatically insert
an "X" character to the column names - "X0001.HK".
Now I have to manually do a loop and use substring() to remove the "X"
character. Any advice? Thanks
Anthony
2025 Mar 29
4
Creating model formulas programmatically
Note: I am almost certain that this has been asked and answered here
before, so my apologies for the redundant query.
I also know that there are several packages that will do this, but I wish
to do it using base R functions only (see below).
The query: Suppose I have a character vector of names like this:
somenames <- c("Heigh", "Ho", "Silver", "Away")
2011 Jul 17
3
How to convert number (matlab) to date
Hello
I am new to R and I need to convert some dates (numeric format by matlab) to actual dates in R.
For instance,
Matlab -> 730456 -> >> datestr(730456)
ans =
02-Dec-1999
R -
> library(zoo)
> as.Date(730456)
[1] "3969-12-03"
I don't not mind the output format but it needs to be right.
Many thanks
Ed
2025 Mar 30
1
Creating model formulas programmatically
Another solution. reformulate + substitute + as.formula:
substitute(~ (.)^2, list(. = reformulate(somenames)[[2]])) |> as.formula()
On Sat, Mar 29, 2025 at 5:31?PM Bert Gunter <bgunter.4567 at gmail.com> wrote:
>
> Note: I am almost certain that this has been asked and answered here
> before, so my apologies for the redundant query.
>
> I also know that there are several
2025 Mar 30
1
Creating model formulas programmatically
Gabor, Duncan, et. al.
1. Thank you for your great comments and solutions. This is what I was
hoping for!
2. Duncan: I completely agree with your criticisms. In fact, I realized the
for() loop only needed the <- assignment, but your comment is important to
note. However, I didn't like the for() loop either; I *much* preferred your
Reduce() solution which is exactly the sort of elegant
2017 Sep 20
1
Convert data into zoo object using Performance analytics package
Dear Sir,
Thanks for your mail and help. I got this error while trying to run your
code.
sbux1.z <- read.csv.zoo(u, FUN = as.yearmon, format = fmt)
Error in read.table(file = file, header = header, sep = sep, quote = quote,
:
'file' must be a character string or connection
Thanks and Regards,
Upananda Pani
On Tue, Sep 19, 2017 at 4:31 PM, Upananda Pani <upananda.pani at
2017 Sep 19
1
symbolic computing example with Ryacas
Thanks for the response. Yes, I did study the vignette but did not
understand it fully. Anyway, I have tried once again now. I am happy to say
that I have got what I wanted.
library(Ryacas)
x <- Sym("x");U <- Sym("U");x0 <- Sym("x0");C <- Sym("C")
my_func <- function(x,U,x0,C) {
return (U/(1+exp(-(x-x0)/C)))}
FirstDeriv <-
2011 Mar 01
2
How to Save R library data into xls or dta format
Thanks in advance.
I'm having a trouble with data saving.
I want to run the same data which is in Ecdat library at different statistic
programs(excel, stata and matlab)
The data I want to use is
library(Ecdat)
data(Housing)
and I want to extract this data our of R as *.dta *.xls formats.
So, my first try was to open the data in R window and drag and paste to
excel or notepad.
BUT, it
2011 Feb 25
1
Accessing sub diagonals / spdiag in R ?
Hello, I'm attempting to access a specific number of sub diagonals in a
MATRIX and have been accustomed to using spdiags in MATLAB or Octave. I've
got a solution pieced together using for loops and it works though isn't
vectorized and liable to run very slow
for large matrices.
As an example:
A =
1 2 3 4 5
9 8 7 6 5
4 5 6 7 8
5 4 3 2 1
8 7 6 0 1
The subdiagonals are: 9,5,3,0 4,4,6
2017 Sep 20
0
Convert data into zoo object using Performance analytics package
Hi
Gabor's code works as expeceted without error.
What is "u" in your case?
Cheers
Petr
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Upananda
> Pani
> Sent: Wednesday, September 20, 2017 11:06 AM
> To: Gabor Grothendieck <ggrothendieck at gmail.com>
> Cc: r-help <r-help at r-project.org>
>
2003 Jan 14
3
PLS regression?
Hi all,
I would like to do some QSAR analysis (quantitative structure activity
relationship). I need to use some Partial Least Squares (PLS) regression,
but I have not seen this option on the R-project. Is it possible to do this
kind of regression on R?
thank you in advance
best regards,
olivier
[[alternate HTML version deleted]]
2017 Sep 22
1
Convert data into zoo object using Performance analytics package
Dear All,
Thanks a lot for your help. Would you please let me know if i want to read
a csv file as zoo object from my local file rather than directly from the
website, how to do that?
library(zoo)
u <- "https://faculty.washington.edu/ezivot/econ424/sbuxPrices.csv"
fmt <- "%m/%d/%Y"
With sincere regards,
Upananda Pani
On Wed, Sep 20, 2017 at 3:22 PM, PIKAL Petr
2011 Feb 08
4
Interactions in a nls model
I am interested in testing two similar nls models to determine if the
lines are statistically different when fitted with two different data
sets; one corn, another soybean. I know I can do this in linear models
by testing for interactions. See Introductory Statistics with R by
Dallgaard p212-218 for an example. I have two different data sets I am
comparing to lai. ci.re should have very
2012 Aug 06
3
Force evaluation of a symbol when a function is created
I am porting a program in matlab to R,
The problem is that Matlab has a feature where symbols that aren't arguments are evaluated immediately.
That is:
Y=3
F=@(x) x*Y
Will yield a function such that F(2)=6.
If later say. Y=4 then F(2) will still equal 6.
R on the other hand has lazy evaluation.
F<-function(x){x*Y}
Will do the following
Y=3
F(2)=6
Y=4
F(2)=8.
Does anyone know of away to
2006 Jun 12
1
r's optim vs. matlab's fminsearch
Hi,
I'm having a problem converting a Matlab program into R. The R code works
almost all the time, but about 4% of the time R's optim function gets stuck
on a local minimum whereas matlab's fminsearch function does not (or at
least fminsearch finds a better minimum than optim). My understanding is
that both functions default to Nelder-Mead optimization, but what's
different about
2011 Jun 20
2
Model Formulae Evaluation
Hello All,
I have searched but haven't been able to find an answer to this question.
I'm writing a function that needs to be able evaluate the right-hand side of
a general non-linear formula for different parameter values, similar to what
nls() does. I looked through the nls() code but it isn't clear what is going
on. Could someone point me to a reference or a way I might do this?
2023 Mar 11
3
Multiple Assignment built into the R Interpreter?
Dear R Core,
working on my dynamic factor modelling package, which requires several
subroutines to create and update several system matrices, I come back to
the issue of being annoyed by R not supporting multiple assignment out of
the box like Matlab, Python and julia. e.g. something like
A, C, Q, R = init_matrices(X, Y, Z)
would be a great addition to the language. I know there are several
2002 Apr 11
2
time (or output of function) in the R prompt
Dear R-help,
Would it be possible to have the "prompt" option accept a function, such as
date()? This way, I can easily deduce the elapse time of top level R
expressions. This would be similar to how Unix shells handle their prompt
variables.
Cheers,
Andy
------------------------------------------------------------------------------
Notice: This e-mail message, together with any