[R] back tick names with predict function
Robert Baer
rb@er @end|ng |rom @t@u@edu
Sun Dec 3 17:38:55 CET 2023
On 12/1/2023 11:47 AM, peter dalgaard wrote:
> Also, and possibly more constructively, when you get an error like
>
>> CI.c = predict(mod2, data.frame( `plant-density` = x), interval = 'c') # fail
> Error in eval(predvars, data, env) : object 'plant-density' not found
>
> you should check your assumptions. Does "newdata" actually contain a columnn called "plant-density":
Great advice/strategy. Thanks!
>> head(data.frame( `plant-density` = x))
> plant.density
> 1 65.00000
> 2 65.11912
> 3 65.23824
> 4 65.35736
> 5 65.47648
> 6 65.59560
> I.e., it doesn't. So check help for data.frame and looking for something with names.
>
>> On 1 Dec 2023, at 01:47 , Bert Gunter <bgunter.4567 using gmail.com> wrote:
>>
>> "Thank you Rui. I didn't know about the check.names = FALSE argument.
>>> Another good reminder to always read help, but I'm not sure I understood
>>> what help to read in this case"
>> ?data.frame , of course, which says:
>>
>> "check.names
>>
>> logical. If TRUE then the names of the variables in the data frame are
>> checked to ensure that they are syntactically valid variable names and
>> are not duplicated. If necessary they are adjusted (by make.names) so
>> that they are. "
>>
>> -- Bert
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list