Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

r not reading data

jbh1128d1
10 - Fireball

Hello,

 

I'm using the r developer tool and it runs fine on the following code:

 

# Load the packages


package_name <- c("ggplot2", "tibble", "tidyr",
"purrr", "dplyr", "segmented", "broom",
"stringr")

altx.repo <- getOption("repos")
altx.repo["CRAN"] <- "http://cran.rstudio.com
options(repos = altx.repo)

if(package_name %in% rownames(installed.packages())==FALSE) {
install.packages(package_name)
}

lapply(package_name, library, character.only = TRUE)

# Read in the data from Alteryx into R
the_data <- read.Alteryx("#1", mode="data.frame")

 

But as soon as I add 

 

write.Alteryx(the_data, 1)

 

it errors out and says it can't find the object the_data.  Is there any reason the data object would fall out?

5 REPLIES 5
PaulN
Alteryx Alumni (Retired)

Hey @jbh1128d1,

 

I believe that the issue is caused by altx.repo["CRAN"] <- "http://cran.rstudio.com (string is not closed).

 

Thanks,

 

Paul Noirel

Sr Customer Support Engineer, Alteryx

 

 

jbh1128d1
10 - Fireball

Thanks @PaulN.  

 

That helped get past that line, but now I get an error that the segmented package is not htere.  I can see the segmented package at the https://cran.rstudio.com/ address and I use it in RStudio. 

jbh1128d1
10 - Fireball

Update:  If I take every package out but segmented, it works.  Is there a limit to how many packages I can load using Alteryx?

jbh1128d1
10 - Fireball

Hi @PaulN.  

 

After deleting the package name line and re-adding them one at a time, it seems to be running fine now.  Thank you for the help.

PaulN
Alteryx Alumni (Retired)

Hey @jbh1128d1,

 

I am glad you could find solution.

 

In your original code there was the following line:

 

if (package_name %in% rownames(installed.packages()) == FALSE) {

 

 

This doesn't produce a single value (see https://cran.r-project.org/doc/manuals/r-release/R-intro.html#Conditional-execution, section 9.2.1 for reference) but a vector of size length(package_name)

 

This explains why original code was producing following warning:

 

the condition has length > 1 and only the first element will be used

 

R_tool_warning.png

 

Thanks,

 

Paul Noirel

Sr Customer Support Engineer, Alteryx

 

 

 

 

 

 

Labels