Dallas R Users: Creating R Packages this Saturday, 6/29

I’ll be presenting at the Dallas R Users Group next Saturday at 10:00AM at the University of Dallas on how to reproduce your R code. We’ll review how to use R scripts, how to embed R code in reproducible documents, and then introduce how to create your own R packages based on your R code. At the end of the afternoon, you’ll be familiar with the entire process of creating an R package to be shared on a repository like CRAN or Bioconductor. No programming background is required – the entire process will be done within RStudio and the R code we’ll be using will be very basic.

Attendance is, as always, free and all in the Dallas/Ft. Worth metroplex are welcome! Details and directions can be found on the Meetup page below.

http://www.meetup.com/Dallas-R-Users-Group/events/124213832/

See you there!

One Comment

  1. Indra B. Kshattry says:

    Hello Every body,
    I am trying to develop a web apps, for teaching math. This has two parts (1) Method and (2) Practice, (later on I will add two more, Self Evaluation and Application).
    Method works fine, but in Practice I want first question to pop up then student does the problem and they will click for the answer. In R console this can be done by the function “locator”, but in the web apps, the function “locator” does not work. Does any body have any idea for my problem?

    ################### R CODE ###################
    library(tcltk)

    library(shiny)

    ################# number.split ################
    number.split = function(x,n){
    number<- (x – x%%10^(n))/10^(n)
    return(number%%10)
    }
    ################## 2digits2.r ########################
    plot.screen("2-digits Addition for 2 numbers")
    x.range <- c(0,15)
    y.range <- c(0,20)

    ## choose numbers to add
    num <- sample(10:99, 2, replace = T)
    ## write problem on the screen
    txt1 <- paste("Find the sum of ", num[1], " and ",num[2])
    text(x.range[1], y.range[2]-2, txt1, adj = c(0,0), cex= 1.2)
    text(x.range[1], y.range[2]-4, expression(bold(Problem)), adj = c(0,0), cex= 1.2, col = "blue")
    n <- nchar(num[1])
    ncol <- n
    nrow <- length(num)
    jug <- matrix(0, nrow,ncol)
    for(k in 1:nrow){
    for(j in 1:ncol){
    jug[k,j] <- number.split(num[k], ncol-j)
    text(x.range[1] + 1 + j, y.range[2] – 4 – k, jug[k,j], cex = 1.2)
    }
    }
    segments(x.range[1] + 1.5, y.range[2] – 4.8 – nrow, x.range[1] + 1.5 + ncol, y.range[2]- 4.8 – nrow)
    ## computation of carry
    carry <- rep(0,ncol + 1)
    s <- numeric()
    for(k in 1:ncol){
    tmp <- jug[,ncol-(k-1)]
    temp <- sum(tmp) + carry[k]
    carry[k+1] <- temp%/%10
    }

    txt1 <- paste("Step 1:")
    text(x.range[1] + 6, y.range[2]-4, txt1, adj = c(0,0), cex = 1.2)
    text(x.range[1] + 6.5, y.range[2]-5, "Addition of numbers in units place", adj = c(0,0))
    for(k in 1:nrow){
    text(x.range[1] + 8 , y.range[2] – 4.5 -k, jug[,2][k])
    }
    segments(x.range[1] + 7.5 , y.range[2] – 7.0, x.range[1] + 8.5 , y.range[2] – 7.0)
    sum1 <- sum(jug[,2])
    jug1 <- rep(0,2)
    for(k in 1:2){
    jug1[k] <- number.split(sum1, 2-k)
    }
    for(k in 1:2){
    text(x.range[1] + 6 + k, y.range[2] – 7.8, jug1[k])
    symbols(x.range[1] + 6 + k, y.range[2] – 7.8, .01, inches = .15, add= T, fg = "blue")
    }
    text(x.range[1] + 7, y.range[2] – 9, "carry", cex = .8, col = "red")
    arrows(x.range[1] + 7, y.range[2] – 9., x.range[1] + 7, y.range[2] – 8.2, code = 2, length= .05, col = "red")
    text(x.range[1] + 9, y.range[2] – 7.8, "Write this number in units digit in the answer", adj = c(0,0), cex = .8, col = "red")
    arrows(x.range[1] + 8.8, y.range[2] – 7.8, x.range[1] + 8.1, y.range[2] – 7.8, code = 2, length= .05, col = "red")

    down <- 7
    txt2 <- paste("Step 2:")
    text(x.range[1] + 6, y.range[2]-4 – down, txt2, adj = c(0,0), cex = 1.2)
    text(x.range[1] + 6.5, y.range[2]-5- down, "Addition of numbers in tens place", adj = c(0,0))
    for(k in 1:nrow){
    text(x.range[1] + 8 , y.range[2] – 4.5 -k- down, jug[,1][k])
    }
    ##segments(x.range[1] + 7.5 , y.range[2] – 7.0 – down, x.range[1] + 8.5 , y.range[2] – 7.0 – down)
    text(x.range[1] +8.0, y.range[2] – 5.5 -nrow -down, carry[2])
    text(x.range[1] + 9.0, y.range[2] – 5.5 -nrow -down, "Carry from units place", cex = .8, col = "red", adj = c(0,0))
    arrows(x.range[1] + 8.8, y.range[2] – 5.5 – nrow – down, x.range[1] + 8.1, y.range[2] – 5.5 – nrow – down, code = 2, length= .05, col = "red")
    segments(x.range[1] + 7.5, y.range[2] – 6 -nrow -down, x.range[1] +8.5, y.range[2] – 6 -nrow -down)
    tmp <- sum(jug[,1])
    sum2 <- tmp + carry[2]
    jug2 <- rep(0,2)
    for(k in 1:2){
    jug2[k] <- number.split(sum2, 2-k)
    }
    for(k in 1:2){
    text(x.range[1] + 6 + k, y.range[2] – 8.8 – down, jug2[k])
    symbols(x.range[1] + 6 + k, y.range[2] – 8.8 – down, .01, inches = .15, add= T, fg = "blue")
    }
    text(x.range[1] + 7, y.range[2] – 11 – down, "carry", cex = .8, col = "red")
    arrows(x.range[1] + 7, y.range[2] – 11.0 – down, x.range[1] + 7, y.range[2] – 9.2 – down, code = 2, length= .05, col = "red")
    text(x.range[1] + 9, y.range[2] – 9.8 – down, "Write this number in tens digit \nin the answer", adj = c(0,0), cex = .8, col = "red")
    arrows(x.range[1] + 8.8, y.range[2] – 8.8 – down, x.range[1] + 8.1, y.range[2] – 8.8 – down, code = 2, length= .05, col = "red")
    text(x.range[1] + 7, y.range[2] – 11.6 – down, "write this number in tbe hundredth place", adj= c(0,0),cex = .8, col = "red")

    ## vertical lines
    segments(x.range[1] + 5.45, y.range[2]-4, x.range[1] + 5.45, y.range[2]- 18, col = "red")
    segments(x.range[1] + 5.5, y.range[2]-4, x.range[1] + 5.5, y.range[2]- 18, col = "blue")
    segments(x.range[1] + 5.55, y.range[2]-4, x.range[1] + 5.55, y.range[2]- 18 , col = "red")
    ##down <- 2
    text(x.range[1], y.range[2]- 1 – down – nrow, expression(bold(Answer)), adj = c(0,0), cex= 1.2, col = "blue")
    for(k in 1:nrow){
    for(j in 1:ncol){
    jug[k,j] <- number.split(num[k], ncol-j)
    text(x.range[1] + 1 + j, y.range[2] – 4 – k – down, jug[k,j], cex = 1.2)
    }
    }
    ## writing carry
    down <- 2.5
    text(x.range[1] + 5.0, y.range[2]- 6.5 – nrow – down , "carry", cex = .8, col = "red")
    for(k in 1:ncol){
    text(x.range[1] + 0 + k, y.range[2]- 6.5 – nrow – down , carry[ncol - (k-2)], cex = .8, col = "red")
    }
    arrows(x.range[1] + 4.5, y.range[2]- 6.5 – nrow – down , x.range[1] + 3.2, y.range[2]- 6.5 – nrow – down, length = .1, code = 2, col = "red")

    ## computation of answer
    ans <- sum(num)
    ## display answer
    N <- nchar(ans)
    jug1 = 100){
    segments(x.range[1] + 1.0, y.range[2] – 11.8 – nrow , x.range[1] + 1.5 + ncol, y.range[2]- 11.8 – nrow )
    for(j in 1:N){
    jug1[j] <- number.split(ans, N-j)
    text(x.range[1]+ j, y.range[2] – 8 – down -2*nrow, jug1[j], cex = 1.2)
    }
    }
    if(ans < 100){
    segments(x.range[1] + 1.5, y.range[2] – 11.8 – nrow, x.range[1] + 1.5 + ncol, y.range[2]- 11.8 – nrow )
    for(j in 1:N){
    jug1[j] <- number.split(ans, N-j)
    text(x.range[1] + 1 + j, y.range[2] – 8 – down – 2*nrow, jug1[j], cex = 1.2)
    }
    }
    ################# Ques.r #########################
    Ques = function(num){
    source("E:/MATH/myfile.r")
    plot.screen("2-digits Addition for 2 numbers")
    x.range <- c(0,15)
    y.range <- c(0,20)

    ## choose numbers to add
    ##num <- sample(10:99, 2, replace = T)
    ## write problem on the screen
    txt1 <- paste("Find the sum of ", num[1], " and ",num[2])
    text(x.range[1], y.range[2]-2, txt1, adj = c(0,0), cex= 1.2)
    text(x.range[1], y.range[2]-4, expression(bold(Problem)), adj = c(0,0), cex= 1.2, col = "blue")
    n <- nchar(num[1])
    ncol <- n
    nrow <- length(num)
    jug <- matrix(0, nrow,ncol)
    for(k in 1:nrow){
    for(j in 1:ncol){
    jug[k,j] <- number.split(num[k], ncol-j)
    text(x.range[1] + 1 + j, y.range[2] – 4 – k, jug[k,j], cex = 1.2)
    }
    }
    segments(x.range[1] + 1.5, y.range[2] – 4.8 – nrow, x.range[1] + 1.5 + ncol, y.range[2]- 4.8 – nrow)

    }
    ################ Ans.r ###################################
    Ans = function(num){
    plot.screen("2-digits Addition for 2 numbers")
    x.range <- c(0,15)
    y.range <- c(0,20)

    ## choose numbers to add
    ##num <- sample(10:99, 2, replace = T)
    text(x.range[1], y.range[2]-4, expression(bold(Answer)), adj = c(0,0), cex= 1.2, col = "blue")
    hshift <- 6
    n <- nchar(num[1])
    ncol <- n
    nrow <- length(num)
    jug <- matrix(0, nrow,ncol)
    for(k in 1:nrow){
    for(j in 1:ncol){
    jug[k,j] <- number.split(num[k], ncol-j)
    text(x.range[1] + 1 + j + hshift, y.range[2] – 4 – k, jug[k,j], cex = 1.2)
    }
    }
    segments(x.range[1] + 1.5 + hshift, y.range[2] – 4.8 – nrow, x.range[1] + 1.5 + hshift + ncol, y.range[2]- 4.8 – nrow)

    ## computation of carry
    carry <- rep(0,ncol + 1)
    s <- numeric()
    for(k in 1:ncol){
    tmp <- jug[,ncol-(k-1)]
    temp <- sum(tmp) + carry[k]
    carry[k+1] <- temp%/%10
    }

    ## Writing carry
    down <- -4.5
    text(x.range[1] + 5.0 + hshift, y.range[2]- 6.5 – nrow – down , "carry", cex = .8, col = "red")
    for(k in 1:ncol){
    text(x.range[1] + 0 + k + hshift, y.range[2]- 6.5 – nrow – down , carry[ncol - (k-2)], cex = .8, col = "red")
    }
    arrows(x.range[1] + 4.5 + hshift, y.range[2]- 6.5 – nrow – down , x.range[1]+hshift + 3.2, y.range[2]- 6.5 – nrow – down, length = .1, code = 2, col = "red")

    ## computation of answer
    ans <- sum(num)
    ## display answer
    N <- nchar(ans)
    jug1 = 100){
    ##segments(x.range[1] + 1.0 + hshift, y.range[2] – 11.8 – nrow , x.range[1]+hshift + 1.5 + ncol, y.range[2]- 11.8 – nrow )
    for(j in 1:N){
    jug1[j] <- number.split(ans, N-j)
    text(x.range[1]+ j + hshift, y.range[2] – 8 – down -2*nrow, jug1[j], cex = 1.2)
    }
    }
    if(ans < 100){
    ##segments(x.range[1] + 1.5 + hshift, y.range[2] – 11.8 – nrow, x.range[1]+ hshift + 1.5 + ncol, y.range[2]- 11.8 – nrow )
    for(j in 1:N){
    jug1[j] <- number.split(ans, N-j)
    text(x.range[1]+ hshift + 1 + j, y.range[2] – 8 – down – 2*nrow, jug1[j], cex = 1.2)
    }
    }

    }

    #################################################

    ##source("C:/Users/Indra/Documents/Addition/Method/2digits2.r")
    ##source("E:/MATH/Chap 2/Practice/Ques.r")
    ##source("E:/MATH/Chap 2/Practice/Ans.r")
    runApp(list(
    ui = pageWithSidebar(
    headerPanel("Learning Addition"
    ),
    sidebarPanel(
    wellPanel(radioButtons("steps", "Learning Steps",
    list("Method" , "Practice" ))),
    wellPanel( uiOutput("learningSteps") ),
    wellPanel(uiOutput("enterNumber")),
    actionButton("get", "Next Problem")
    ##actionButton("ans", "Answer")
    ),
    mainPanel(
    tabsetPanel(
    tabPanel("", plotOutput("additionPlot", width = "110%", height = "600px")
    )
    )
    )
    ),

    server = function(input, output){
    output$enterNumber <- renderUI({
    if(input$steps=="Method"){
    radioButtons("digit","How many digits? :",
    list("1 – digit"="1digit","2 – digit"="2digit"))
    }else if(input$steps=="Practice"){
    radioButtons("digit","How many digits? :",
    list("2 – digit"="2digit"))
    }
    })
    output$learningSteps <- renderUI({
    if(input$steps=="Method"){
    selectInput("number","How many numbers?",
    list("Two"="2", "EXIT" = "exit"))
    }else if(input$steps=="Practice"){
    selectInput("number","How many numbers?",
    list("Two"="2","EXIT" = "exit"))
    }
    })
    dat <- reactive({
    if(input$get == 0) return(NULL)
    ##if(input$ans == 0) return(NULL)
    if(input$steps=="Method"){
    n.digits <- input$digit
    if(n.digits == "2digit"){
    num <- switch(input$number,
    "2" =mdTwoTwo())
    }
    else{stop()
    }
    }
    if(input$steps=="Practice"){
    n.digits <- input$digit

    if(n.digits == "2digit"){
    ##num <- switch(input$number,
    ##"2" = prTwoTwo())
    num <- input$number
    if(num=="2"){ Num <- sample(10:99, 2, replace = T)
    par(mfrow = c(1,2))
    Ques(Num)
    ##if(input$ans==0){
    ##return()
    observe({
    if(is.null(input$get) || input$get == 0) return()
    # run other code when button is pressed

    ##})
    Ans(Num)
    })
    }
    }
    else{stop()
    }
    }

    })

    output$additionPlot <- renderPlot(dat())
    }
    ))

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">