Hi! I came across this unexpected behaviour in R. First I thought it was a bug
in the assignment operator <- but now I think it's maybe a bug in the way data
frames are being printed. What do you think?
Using R 4.3.1:
> x <- data.frame(A = 1, B = 2, C = 3)
> y <- data.frame(A = 1)
> x
A B C
1
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
On 25/10/2023 2:18 a.m., Christian Asseburg wrote:
Hi! I came across this unexpected behaviour in R. First I thought it was a bug in
the assignment operator <- but now I think it's maybe a bug in the way data
frames are being printed. What do you think?
Using R 4.3.1:
x <- data.frame(A = 1,
Às 07:18 de 25/10/2023, Christian Asseburg escreveu:
Hi! I came across this unexpected behaviour in R. First I thought it was a bug in
the assignment operator <- but now I think it's maybe a bug in the way data
frames are being printed. What do you think?
Using R 4.3.1:
x <- data.frame(A = 1
The "problem" goes away if you use
x$C <- y[1,]
If you have another row in your x, say:
x <- data.frame(A=c(1,4), B=c(2,5), C=c(3,6))
then your code
x$C <- y[1]
returns an error.
If y has the same number of rows as x$C then R has the same outcome as in your
example.
It looks like your code te
Hello,
Inline.
Às 13:32 de 26/10/2023, Ebert,Timothy Aaron escreveu:
The "problem" goes away if you use
x$C <- y[1,]
Actually, if I understand correctly, the OP wants the column:
x$C <- y[,1]
In this case it will produce the same output because y is a df with only
one row. But that is a
Dear All
My program is long and sorry I do not have a replicable set of codes to
present. But I present a chunk of codes at the end below. Essentially,
1. I initialize cat.ref as NUL (see line 1)
2. Then, I repeatedly add elements to cat.ref, where each element
include parentheses in double qu
Hi,
It isn't at all clear to me what you're trying to do. For one thing,
you never actually add more items to cat.ref in the code snippet you
give.
You do use c() on zx.ref - is that what you mean?
But you aren't adding cat.ref to it, you're adding v$cat.ref, and I
have no idea what that might co
I recommend cutting snippets out of your code by stopping the code at the point
of interest and using dput() to pull out "data as it is" before the troublesome
section and then using the reprex package to test that the snippet runs.
Either you will notice the problem on your own while taking thi
Dear Sir, Madam, or to whom this may concern,
my name is Jan Failenschmid and I am a Ph.D. student at Tilburg University.
For my project I have been looking into different types of kernel regression
estimators and corresponding R functions.
While comparing different functions I noticed that stats
Dear R users! Thank you for your excellent replies. I didn't know that the
print.data.frame expands matrix-like values in this way. Why doesn't it call
the column in my example C.A? I understand that something like that happens
when the data.frame in position three has multiple columns. But your
Apologies in advance if my comments don't help, in which case, no need
to respond, but I noted in ?ksmooth:
"bandwidth
the bandwidth. The kernels are scaled so that their quartiles (viewed
as probability densities) are at ± 0.25*bandwidth." So, could this be
a source of the discrepancies you cite
Dear R-Experts,
Here below my R code working but I don't know how to complete/finish my R code
to get the final plot with the extrapolation for the10 more years.
Indeed, I try to extrapolate my data with a linear fit over the next 10 years.
So I create a date sequence for the next 10 years and
Hello Colleagues,
I am trying to get the Git repository using *remotes* package. I am
using *remotes::install_github("dcl-docs/dcldata")
*to get the Git repo.
However, I am getting the following error message. I have absolutely no
idea on what this error message means and how to get away with thi
Hmm, I can't replicate (i.e., it works fine for me). What are the
results of your sessionInfo() (from a *clean* R session)?
==
R Under development (unstable) (2023-10-25 r85410)
Platform: x86_64-pc-linux-gnu
Running under: Pop!_OS 22.04 LTS
Matrix products: default
BLAS: /usr/local/lib/R/l
from ?predict.lm:
"predict.lm produces a vector of predictions or a matrix of
predictions and bounds with column names fit, lwr, and upr if interval
is set. "
ergo:
predict(model, dfuture, interval = "prediction")[,"fit"] ## or [,1]
as it's the first column in the returned matrix
is your vector
Incidentally, if all you wanted to do was plot fitted values, the
predict method is kinda overkill, as it's just the fitted line from
the model. But I assume you wanted to plot CI's/PI's also, as the
example illustrated.
-- Bert
On Thu, Oct 26, 2023 at 1:56 PM Bert Gunter wrote:
>
> from ?predic
17 matches
Mail list logo