Need help using baseballr in Knime. I want to bring in pitcher and batter data in 2023 to calculate their fantasy totals but am getting the generic error message
ERROR R Source (Table) 0:13 Execute failed: R evaluation failed.: “knime.tmp.ret<-NULL;printError<-function(e) message(paste(‘Error:’,conditionMessage(e)));for(exp in tryCatch(parse(text=knime.tmp.script),error=printError)){tryCatch(knime.tmp.ret<-withVisible(eval(exp)),error=printError)
if(!is.null(knime.tmp.ret)) {if(knime.tmp.ret$visible) tryCatch(print(knime.tmp.ret$value),error=printError)}};rm(knime.tmp.script,exp,printError);knime.tmp.ret$value”
@mbarzyk welcome to the KNIME forum. You will have to extract the data a a data frame.
Something like this
library(baseballr)
# Example: Fetching player statistics for a specific player
# Use playerid_lookup to get player's ID based on name
player_stats <- playerid_lookup("Trout", "Mike")
# Ensure the output is explicitly a data frame
player_stats_df <- as.data.frame(player_stats)
# Output the data frame
knime.out <- player_stats_df
Unfortunately every now and then it seems a KNIME version is screwing up the data transfer between KNIME and R. And then it takes time and convincing to sort this out.
Does KNIME Interactive R Statistics Integration v4.2.3 work with KNIME Analytics Platform v4.2.0? Could that be the issue? I’ve installed the R Statistics Integration v4.2.3 following each step in the installation guide and have been getting the aforementioned errors.
Hi all,
The linked post is not related. It was only an issue with KNIME AP 4.5.0 and 4.5.1. Not with previous versions, and it has not resurfaced with 5.2.x. However, updating is a good idea. KNIME AP 4.2.0 is quite outdated and a few bug fixes have been implemented since then.
I tried running the workflow you shared on macOS and yes, the R Snippet node (KNIME Interactive R Statistics) fails with this error message:
Execute failed: R evaluation failed.: "knime.tmp.ret<-NULL;printError<-function(e) message(paste('Error:',conditionMessage(e)));for(exp in tryCatch(parse(text=knime.tmp.script),error=printError)){tryCatch(knime.tmp.ret<-withVisible(eval(exp)),error=printError) if(!is.null(knime.tmp.ret)) {if(knime.tmp.ret$visible) tryCatch(print(knime.tmp.ret$value),error=printError)}};rm(knime.tmp.script,exp,printError);knime.tmp.ret$value"
But, it executes successfully on Windows and Linux. So, I tried an earlier version of KNIME on macOS (4.7.7) and it fails there too. I’m not R expert (I’m sure you are), but is it possible that this is an issue with the used library on macOS in general? Asking since I’ve heard that some R libraries are not working as expected on macOS.
@armingrudd there are pretty standard R libraries that do not seem to work properly. And they have done so in the past (my impression). It seems that the output is not properly captured. The community node does not have the same problems.
In this example a simple plot does work, others do not. GGplot2 is a pretty common library.
Thank you @mlauber71 for the examples. I can reproduce the same issue in the previous example here as well (only macOS).
So, this has been the same before? Becasue I can reproduce on 4.7.7 and 5.2.2.
Do you know any earlier version that this was working fine (on macOS)?
I will discuss this internally as well.
@armingrudd to be honst I cannot exactly recall when the problems started. There was this debate around KNIME 4.5 - where there were some changes and some cases worked.
I have rewritten a workflow to use the R community nodes since I was experiencing problems with the R nodes (on Mac). But it was difficult to pin them down.
I have started an article about visualizations and R with KNIME but stopped because I lacked the energy to go thru convincing someone that there is a problem - so if you might want to take an additional look that would be great. Not doing much with R at the moment.
@armingrudd, @bwilhelm there was a small update for the R Scripting extension and now everything seems to work on KNIME 5.2.2 - not sure if it was you, but thank you anyway.
@mlauber71 this update only updated some metadata of the extension, there haven’t been functional changes in a long time… Great that it is working for you right now, but @armingrudd and I can still reproduce the error with 5.2.2, so there must still be something off.
While this spurious problem is “luckily” reproducible on my machine, I’ll try to understand what’s going wrong.
Phew. That’s a weird one. It seems to be the same issue as here: Table to R not able to load library. Our R Snippet node apparently cannot connect to the internet to download data.
If I run the script from the node in a standalone R it works without problems, and also in the community (MPI) R snippet node.
If I run the command player_stats <- playerid_lookup("Trout", "Mike") in a standalone R session, save the result to a table, and replace the line in the R Snippet node by player_stats <- read.table(...) then everything works as expected.
I assume the reason is that we’re running the R code from KNIME via RServe and communicate via sockets. Maybe, for some reason, this is configured in a way that it cannot talk to the “outside world”. I had a glance at the code but did not find a place where this might be configured that way…