Rename 3 files with a different name each

Thank you for running the app. The reason why I sent the reprex on how to make a file is so that you could create the files. The input box lists the files stored in (getwd()) and allows the user to make multiple selections. The application is supposed to run glyCount1.R when the user presses that final button (press the button to end, no before the button is pressed. I need for this app to be designed the way it is. But, you confirm the fact that there is a problem with the input box. Thank you for your help. I will see what I can do.

Could you please tell me how to go about creating a RStudio Cloud project?

Thanks

To create a project in RStudio Cloud, you will need to sign up at rstudio.cloud. Then, in your workspace, click "New Project" - a new project will be created for you, and you'll see the familiar RStudio interface in your browser. You can then create a new shiny app in the usual way (File > New File > Shiny Web App) or port your existing app in using the "Upload" button in the Files tab.

If you have your app in a git repo, it's a bit easier - the "New Project" button will allow you to specify the URL of your repo.

Since this is for the purposes of sharing, make sure to click the "Settings" gear at the top of your workspace, choose "Access", and set the "Who can view this project" to "Everyone."

1 Like

Thanks very much for your quick response

Sorry, I should have been more clear! I did use the code provided to create files. That code only creates a single file in the working directory. The file it creates has a name that doesn't match some of the regex patterns used in the code, as far as I can tell — that might be something you want to look more closely at.

In practice, there were no options available so the selectize box behaved like a simple text entry box. Looking more closely, you still had an absolute path to somewhere on your computer in the code that creates the list of choices:

conditionalPanel(
    condition = "output.toCombine > '0'",
    selectInput(
       inputId = "select",
       label = h5(strong("Please select from the list")), 
       choices = c(Chose = "", list.files("~/Development/glycoPipeApp")), 
       multiple = TRUE, 
       selectize = TRUE
    )
  ),

As a general note, there are a few places in this app that seem to me like you're kind of programming against the grain of how shiny works. Reactivity means that you aren't writing code that says "do this first, then that, then that other thing" — you're preparing code recipes that will be run in an order that shiny decides. Adjusting to this model from a more imperative coding style can feel like turning your head inside out! If you haven't seen them already, I really recommend these videos for getting a better handle on reactivity:
https://www.rstudio.com/resources/videos/effective-reactive-programming/

yes, I forgot to tell you that the program part that names the file has to be updated to create the other two files. I have learn to do the conditional panel below at RStudio Community, and I have read about reactivity. Could you please explain why the code below does not relate to reactivity? Could you please explain your view on reactivity and why the code below does not work with reactivity? May be I am wrong.

conditionalPanel(
    condition = "output.toCombine > '0'",
    selectInput(
       inputId = "select",
       label = h5(strong("Please select from the list")), 
       choices = c(Chose = "", list.files("~/Development/glycoPipeApp")), 
       multiple = TRUE, 
       selectize = TRUE
    )
  ),

The code below works well, provided that 1.csv, 2.csv, 3.csv exists (they were created with anther program in this case for the purpose of demonstration only. And this is what I would like to accomplish. The only difference between this script and the one called by the application is that in this script "name1", "name2", and "name3" are created by me as a list in the script. However in the case of the app, those names are input by the user through the text box and are passed as a list from the app to the script. if it is not too much to ask, you could create 3 empty files in your working directory and name them 1.csv, 2.csv. 3.csv. This way you could run the program and see that the same code works in the script, but not when the script is called by the app.

Thank you

new_dataFns <- list("name1", "name2", "name3")
new_path <-  lapply(new_dataFns,
                    function(new_dataFns){
                      paste(getwd(), "/", new_dataFns, sep = "")
                    })

print(new_path)

old_dataFns <- list("1.csv", "2.csv", "3.csv")

for(i in 1:length(old_dataFns)){
 old_dataFns[i] <- gsub(" ", "", paste(getwd(), "/", old_dataFns[i]))

}
print(old_dataFns)

lapply(1:3, function(i){ file.rename(old_dataFns[[i]], new_path[[i]]) })

Hi,

Does this mean I can share my project even if it has a problem that I can not solve so that other people can look at it. or does this refer to sharing your app once is ready?

Thanks,

This will allow you to share your workspace with others, which means that they will be able to see the same four-pane RStudio interface and interact with your code. Sharing the app when it's ready would happen through hosting with a different service - for example, shinyapps.io

1 Like

Thanks very much. So I can write and run my programs in the cloud space while other users can look, run and change my code?

Yes - the other users will need to create rstudio.cloud accounts as well. You can share your workspace with them by giving them the URL related to the project (you can get this from your browser's address bar; it'll look something like https:// rstudio.cloud/project/XXXXX, where the XXXXX is a number). You can find more sophisticated controls for creating a private space for collaboration here.

One word of caution - I believe RStudio Cloud is still in beta, so I caution against using it as your primary development environment. (Somebody please correct me if I'm wrong about this.)

1 Like

Thank you for the info. I will develop in my system and I will share the code when I need somebody else's opinion.

1 Like

It's actually in alpha, so it's definitely not a good idea to rely on it exclusively for primary development right now! The current product focus is on being a platform for teaching and training.

It's a great place to share examples that aren't quite working correctly, especially for things like shiny apps that aren't strictly reprex-able and that have a few different moving parts. When someone goes to your shared project link, they don't actually work directly on your Cloud project — instead they get a temporary copy of your project that they can play with and, if they want, choose to save to their own Cloud workspace. So keep that in mind when deciding what data you are going to make available in a shared Cloud project.

2 Likes

I'm sorry, I think I wrote things in a confusing way — my comment about design patterns for reactivity was not related to this specific chunk of code. I should have made that clearer! My comments were based on impressions I got reading other parts of the code, where it looks like the code is working hard to sort of get around reactivity, instead of embracing the reactive model. This is probably completely vague and unhelpful — I'm afraid I still find it difficult to verbalize these ideas. So again I'm going to point to those videos — Joe does a much better job explaining, with examples :grin:

I have listened to Joe's videos. There where he talks about reactive values and Observe. Observe means do this. Could you please specify any part of the code where I have not used correctly reactiveValue, observe and Isolate?