records

338 views
Skip to the first unread message

Dong Shichao

unread,
27 Jul 2013, 2:28:30 am27/07/13
to shiny-...@googlegroups.com
HI,
Can anybody help me with these two problems?
  1. I want to run the app on a server, when users upload their data(csv file), the server can store them so that I can collect users' data.
  2. When users choose settings to generate plots, I want to record their information(including IP address and time) as well as settings they used.
Many thanks!
Dom
Message has been deleted
Message has been deleted

low yi xiang

unread,
28 Jul 2013, 1:38:21 pm28/07/13
to shiny-...@googlegroups.com
hope i am not out of my place here,

but here is what i did

for (1), you can do something like this

  data_frame<-reactive({
    raw_data<-input$file1
    if(is.null(raw_data))
      return(NULL)
    read.csv(raw_data$datapath,header=TRUE,sep=",")
  })

and followed by another command that does something like

download<-reactive({
setwd("~/ShinyApps")
write.csv(data_frame(),"insert name.csv",row.names=FALSE)
})

however, the problem here you might then face is whenever a user uploads a data, the existing file will be over written, what i did to over come this problem is to create a log file.
you can think of this log file as a counter, so you can do something like

counter<-read.csv("counter.
csv",header=FALSE,sep=",")

and replace write.csv(data_frame(),"insert name.csv",row.names=FALSE) with

write.csv(data_frame(), paste("insert name.csv",counter),row.names=FALSE)

for 2)

R has a build in command for the time, which is

Sys.time(), you can play around with it. what i did was

time<-as.character(Sys.time())

and also append it in my log file.

for  IP address, there are some people asking about it a long time ago, its quite complicated ( i didnt bother to read them as i dont require them as of now)

as for the other settings, when you define them as reactive functions, you can append them in your log file. its up to you as to how you want to design your log file and play with it.

just remember to write.csv for your counter file again after adding +1 to it.

i hope this helps

Joe Cheng

unread,
29 Jul 2013, 8:08:54 pm29/07/13
to shiny-...@googlegroups.com
To record IP address requires the very latest version of Shiny (i.e. install directly from GitHub, instructions are at https://github.com/rstudio/shiny) as well as the very latest version of httpuv. Updating httpuv is actually a little complicated; you need to have Rtools installed if you're on Windows, and you need git. If you have both of those, then you should be able to do:

cd httpuv
git submodule update --init
R CMD INSTALL .

You can then include a "session" argument in your shinyServer function (i.e. function(input, output, session)) and then refer to session$request$REMOTE_ADDR to get the client IP address. If you're running behind Shiny Server you will need to get the value a different way, take a look at session$request$HTTP_X_FORWARDED_FOR (see here for more details).


--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
Message has been deleted
0 new messages