Does anyone know how to fix this problem? I tried checked the data and tried to modify the formula multiple times. Attached there is the screen. Thank you!
Asked
Active
Viewed 35 times
-1
-
2What problem? We see no code, no data, no errors/warnings/messages, no output ... please see https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info for discussions on producing *reproducible* questions. Thanks. – r2evans Oct 07 '21 at 20:39
-
I've just added the screenshot, sorry+ – lorenzo panetta Oct 07 '21 at 20:41
-
3We don't do screenshots here – stefan_aus_hannover Oct 07 '21 at 20:44
-
1While we *can* do screenshots, they are generally discouraged: it breaks screen-readers and it cannot be copied or searched (ref: https://meta.stackoverflow.com/a/285557 and https://xkcd.com/2116/). Please just include the code, console output, or data (e.g., `data.frame(...)` or the output from `dput(head(x))`) directly. – r2evans Oct 07 '21 at 20:48
-
I don't see `fAlpha` in the picture of your data, should the formula be `Alpha ~ Price + ...`? You may also need to quote the `NA` as `\`NA\``, as that's a special token in R. – r2evans Oct 07 '21 at 20:49
-
Is there a column called fAlpha? – Jon Spring Oct 07 '21 at 20:49
-
1@r2evans from the stackoverflow rules: "DO NOT post images of code, data, error messages, etc." – stefan_aus_hannover Oct 07 '21 at 20:51
-
@stefan_mit_hannover Yes, and my *interpretation* of that is augmented with *"... as your only means of providing code/data/errors, etc"*. Yes, it's my interpretation, and I am one who will quickly discourage the use of pics of such ... but there are times when they are permitted. (I'm also quick to say comments like *"... and I'm not going to spend time transcribing the data or code that you have readily available on your console"*, so I definitely agree with your sentiment!) – r2evans Oct 07 '21 at 20:53
-
lorenzo panetta, it appears that this is two things: a typo (`fAlpha` vs `Alpha`) and the use of `\`NA\`` as a column name. I haven't found an easy way to escape it such that that will work, so I strongly urge you to rename that column from `NA` to something other than a reserved R token. – r2evans Oct 07 '21 at 20:56
-
Guys, sorry but I am a real dumb in R. I don't know what and how to copy and paste here. – lorenzo panetta Oct 07 '21 at 20:57
-
1r2evans, THANK YOU! The problem was NA column. You saved my life – lorenzo panetta Oct 07 '21 at 21:02
-
lorenzo panetta, really, please read through the links I provided in the first comment. If you have questions on how to paste into the Stack editor (code, pictures, etc), then please see https://meta.stackexchange.com/a/22189 and https://stackoverflow.com/editing-help. Please enjoy SO, it's a great resource, but please try to format your questions a little better for us. This one was easy, future questions may very well be "will not try to help" if images are the only information provided. Thanks! – r2evans Oct 07 '21 at 21:13
-
Please provide enough code so others can better understand or reproduce the problem. – Community Oct 09 '21 at 00:09
1 Answers
0
While there is a typo in the image (fAlpha
vs Alpha
), the issue is that you have NA
as a column name. It might be possible in most frame-accessors to get by the fact that this is a reserved word in R, I haven't (with shallow testing) been able to get a formula to work with it.
Change that column name to something that is not a reserved name, perhaps as simple as
names(PTF)[9] <- "NA_"
lm(Alpha ~ Price + ... + NA_ + ..., data = PTF)

r2evans
- 141,215
- 6
- 77
- 149