Hi Ivo,
I maintain 'package:this.path' that I believe does what you want. I
regularly add this to my own code when I need to:
warning(sprintf("remove this later at %s#%d",
this.path::try.this.path(), this.path::LINENO()), call. = FALSE,
immediate. = TRUE)
Of course, modify as needed.
Regards,
I would use two because it does not force the evaluation of the other
arguments in the ... list.
On Sun, Jan 5, 2025, 13:00 Bert Gunter wrote:
> Consider:
>
> f1 <- function(...){
> one <- list(...)[['a']]
> two <- ...elt(match('a', ...names()))
> c(one, two)
> }
> ## Here "..." is an ar
outer() expects a return value with the same length as that of x.
You could change the code to rep(3, length(x))
Or if you don't want to change the code of the function, you could make a
wrapper and use that instead:
function (x, y)
{
v <- FN1(x, y)
if (length(v) != 1) v else rep(v, lengt
t; Calls: local ... eval.parent -> eval -> eval -> eval -> eval -> readLines
>
> Execution halted
>
> So, the behaviour of unz() seems to be different depending on whether it
> was explicitly opened before passed to readLines(). Should this be fixed or
> documented?
&
Hi Mikko,
I tried running a few different things, and it seems as though
explicitly using `open()` and opening a blocking connection works.
```R
cat("hello", file = "hello.txt")
zip("hello.zip", "hello.txt")
local({
conn <- unz("hello.zip", "hello.txt")
on.exit(close(conn))
## you ca
That looks like a UTF-16LE byte order mark. Simply open the connection
with the proper encoding:
read.delim(
'https://online.stat.psu.edu/onlinecourses/sites/stat501/files/ch15/employee.txt',
fileEncoding = "UTF-16LE"
)
On Sat, Sep 7, 2024 at 3:57 PM Christofer Bogaso
wrote:
>
> Hi,
>
>
You can find more by reading through ?regex as well as Perl documentation
(which you can find online).
On Thu, Aug 1, 2024, 21:11 Steven Yen wrote:
> Good Morning. Below I like statement like
>
> j<-grep(".r\\b",colnames(mydata),value=TRUE); j
>
> with the \\b option which I read long time ago w
It should be written more like this:
```R
z <- data.frame(a = 1:3, b = letters[1:3])
z |> names() |> _[2] <- "foo"
z
```
Regards,
Iris
On Sat, Jul 20, 2024 at 4:47 PM Bert Gunter wrote:
>
> With further fooling around, I realized that explicitly assigning my
> last "solution" 'works'; i.e.
My guess would be that you're using an older version of R. The pipe was
added in R 4.1. It cannot be used in earlier versions as the syntax is
invalid. You could use the dplyr pipe if you want further back
compatibility.
On Tue, Jun 18, 2024, 12:14 Ogbos Okike wrote:
> Greetings to everyone and
This happens because "123e" looks like exponential form. This string has no
exponent, so it gets treated as 0 exponent.
If you're interested in converting hex numbers, append 0x:
as.numeric("0x123a")
or use strtoi:
strtoi("123a", 16)
On Wed, May 1, 2024, 15:24 Carl Witthoft wrote:
> Hello.
>
Hi Duncan,
I only know about sub() and gsub().
There is no way to have pattern be a regular expression and replacement be
a fixed string.
Backslash is the only special character in replacement. If you need a
reference, see this file:
https://github.com/wch/r-source/blob/04650eddd6d844963b6d7aac
Hi Thomas,
If you want to compare the imaginary portions, you could do:
Im(z1) < Im(z2)
If you want to compare the magnitudes, you could do:
Mod(z1) < Mod(z2)
If you want to compare complex numbers, i.e. z1 < z2, well that just
doesn't make sense.
On Mon, Mar 25, 2024, 10:17 Thomas K wrote:
Hi Maria,
I had something similar on my Windows work laptop at some point where the
home directory was something containing non ASCII characters. The easy
solution is to copy said directly from the file explorer into
utils::shortPathName, and then set that as the home directory. In my case,
> wr
Hi Iago,
This is not a bug. It is expected. Patterns may not overlap. However, there
is a way to get the result you want using perl:
```R
gsub("([aeiouAEIOU])(?=[aeiouAEIOU])", "\\1_", "aerioue", perl = TRUE)
```
The specific change I made is called a positive lookahead, you can read
more about
Hi Reed,
I need to stress before giving my answer that no solution can handle
everything. These scenarios will always lead to problems:
* if any of the formal arguments rely on the current state of the call stack
* if any of the formal arguments rely on a variable that is only
defined later in
uncan Murdoch wrote:
> > I'm not an Emacs user, but the ESS-help mailing list (see
> > ess.r-project.org) might be able to help with this.
> >
> > Duncan Murdoch
> >
> > On 10/11/2023 3:43 a.m., Iris Simmons wrote:
> >> Hi,
> >>
> >>
&
Hi,
I'm using R in Emacs and I'm interested in programatically knowing the
details of all opened buffers; details such a buffer name, size, mode,
and possibly associated filename. I've been able to write such a
function in Emacs Lisp, but now I'd like to be able to call that
function from R, or i
If you don't know the name of the attributes in advance, how can you know
the function name to be able to call it? This seems like a very flawed
approach.
Also, I would discourage the use of eval(parse(text = )), it's almost
always not the right way to do what you want to do. In your case,
eval(b
You are not getting the structure you want because the indexes are
wrong. They should be something more like this:
i <- 0
for (row in 1:nrow(alajuela_df)){
for (col in 1:ncol(alajuela_df)){
i <- i + 1
df[i,1]=alajuela_df[row,col]
}
}
but I think what you are doing can be written much
I would say this is not an error, but I think what you wrote isn't
what you intended to do anyway.
y[1] is a data.frame which contains only the first column of y, which
you assign to x$C, so now x$C is a data.frame.
R allows data.frame to be plain vectors as well as matrices and
data.frames, basi
You can try either of these:
expr <- bquote(lm(.(as.formula(mod)), dat))
lm_out5 <- eval(expr)
expr <- call("lm", as.formula(mod), as.symbol("dat"))
lm_out6 <- eval(expr)
but bquote is usually easier and good enough.
On Wed, Oct 25, 2023, 05:10 Shu Fai Cheung wrote:
> Hi All,
>
> I have a pro
You might also be able to rewrite
log(1 - cos(x))
as
log1p(-cos(x))
On Wed, Aug 16, 2023, 02:51 Iris Simmons wrote:
> You could rewrite
>
> 1 - cos(x)
>
> as
>
> 2 * sin(x/2)^2
>
> and that might give you more precision?
>
> On Wed, Aug 16, 2023, 01:50
You could rewrite
1 - cos(x)
as
2 * sin(x/2)^2
and that might give you more precision?
On Wed, Aug 16, 2023, 01:50 Leonard Mada via R-help
wrote:
> Dear R-Users,
>
> I tried to compute the following limit:
> x = 1E-3;
> (-log(1 - cos(x)) - 1/(cos(x)-1)) / 2 - 1/(x^2) + log(x)
> # 0.4299226
>
You could also do
dim(x) <- c(length(x), 1)
On Sat, Aug 5, 2023, 20:12 Steven Yen wrote:
> I wish to stack columns of a matrix into one column. The following
> matrix command does it. Any other ways? Thanks.
>
> > x<-matrix(1:20,5,4)
> > x
> [,1] [,2] [,3] [,4]
> [1,]16 11 1
Hiya!
You can do this by specifying sub="c99" instead of "Unicode":
```R
x <- "fa\xE7ile"
xx <- iconv(x, "latin1", "UTF-8")
iconv(xx, "UTF-8", "ASCII", "c99")
```
produces:
```
> x <- "fa\xE7ile"
> xx <- iconv(x, "latin1", "UTF-8")
> iconv(xx, "UTF-8", "ASCII", "c99")
[1] "fa\\u00e7ile"
>
```
Hello,
I'm trying to demonstrate the behaviour of my R package and how line
directives change that behaviour. So I've got an R chunk like this:
<>=
{
#line 1 "file1.R"
fun <- function() {
pkg::fun()
}
#line 1 "file2.R"
fun()
}
@
but when it is rendered, the line directives
Hi,
I think there are two easy ways to fix this. The first is to use a `switch`
to call the intended function, this should not be a problem since there are
a small number of print functions in **mixR**
```R
print.mixfitEM <- function (x, digits = getOption("digits"), ...)
{
switch(x$family,
You probably want `names(test)`.
On Thu, May 25, 2023 at 7:58 PM Evan Cooch wrote:
> Suppose I have the following list:
>
> test <- list(a=3,b=5,c=11)
>
> I'm trying to figure out how to extract the characters to the left of
> the equal sign (i.e., I want to extract a list of the variable names,
I might try something like this:
FUN1 <- function ()
{
threshold <- 4L
fails <- 0L
internal <- function() {
## do the actual downloading here
tryCatch({
download.file(<...>)
}, error = function() {
fails <<- fails + 1L
if (fai
29 matches
Mail list logo