[R] Moving 2nd column into 1st column using R

2019-09-09 Thread smart hendsome via R-help
Hi R-user, I have a problem regarding R.  How can I move my 2nd column into 1st column.  For example I have data as below: mydf <- data.frame(matrix(1:6, ncol = 2))  mydf   X1 X2   1   4   2   5   3   6 I want move my 2nd column become like this:   X1    1      2    3    4   5   6 Hope anyone can

[R] Solving Function using Conjugate Gradient

2019-03-20 Thread smart hendsome via R-help
Hi R-user, I have a problem regarding to estimate lambda[r] by minimizing the convex function using conjugate gradient in R-programming.  The function as below: Hopefully, anybody in this forum can help me. Thanks so much. __ R-help@r-project.org maili

[R] if else with 4 conditions problem

2018-05-27 Thread smart hendsome via R-help
Hi everyone, I have two columns:    A               B    1               1   1               0    0               1    0               0 I have 4 categories which are: 1) if A = 1 and B =1 then A1 = 1, else A2 = 0, A3 = 0, A4 = 0 2) if A = 1 and B =0 then A1 = 0, else A2 =1, A3 = 0, A4 = 0 3) if

[R] Simulation based on runif to get mean

2018-01-29 Thread smart hendsome via R-help
Hello everyone, I have a question regarding simulating based on runif.  Let say I have generated matrix A and B based on runif. Then I find mean for each matrix A and matrix B.  I want this process to be done let say 10 times. Anyone can help me.  Actually I want make the function that I can pla

[R] Result show the values of fitting gamma parameter

2018-01-29 Thread smart hendsome via R-help
Hi, Let say I have data by two columns A and B, and I have fit each column using the gamma distribution by 'fitdist' . I just want the result show only the shape and rate only. Eg: library(fitdistrplus) A <-c(1,2,3,4,5) B<-c(6,7,8,9,10) C <-cbind(A,B) apply(C, 2, fitdist, "gamma") Output sho

[R] Change NA value into 0

2016-02-29 Thread smart hendsome via R-help
Hi R-users, I have problem regarding my function. My function as below: gen.m <- function(n,itr){     set.seed(1234)         m <- matrix(nrow = n, ncol=4)    a <- matrix(nrow = n, ncol = 1)    b <- matrix(nrow = n, ncol = 1)    C <- matrix(nrow = n, ncol = 1)    d <- matrix(nro

[R] Generate arrival of time based on uniform random number

2016-02-03 Thread smart hendsome via R-help
Hi everyone, I have problem regarding to generate arrival of time based on uniform random number. Let day0 = 0.383, lambda = 0.2612 1) Generate uniform random number (already settled) using the code below: set.seed(1234) rand.no <- function(n,itr){   matrix(runif(n*itr, 0, 1), nrow=n, ncol=itr) }

[R] Result error using the function

2015-10-06 Thread smart hendsome
Hi R-users, I am new to R.  I try to code using the function in R as below:  monthly_summary <- function(dt,r) {  tol <- 1E-6    mn  <- vector(length=12, mode="numeric")    lambda  <- vector(length=12, mode="numeric")    ag  <- aggregate(dt[,4] > tol, list (dt[,2], dt[,1]), sum)    names(ag) <- c

[R] Count number of rain more than zero in matrix form

2015-09-30 Thread smart hendsome
Hello R-users, I want to ask how to count the number of daily rain data.  My data using dput() as below: structure(list(Year = c(1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L,

[R] Counting number of rain

2015-09-08 Thread smart hendsome via R-help
Hello R-users, I want to ask how to count the number of daily rain data.  My data as below: Year Month Day Amount 1901 1 1 0 1901 1 2 3 1901 1 3 0 1901 1 4 0.5 1901 1 5 0 1901 1 6 0 1901 1 7 0.3 1901 1 8 0 1901 1 9 0 1901 1 10 0 1901 1 11 0.5 1901 1 12 1.8 1901 1 13 0 1901 1 14 0 1901 1 15 2.5

[R] Replace the value with 1 and 0

2015-02-25 Thread smart hendsome
Hi everyone, I have this kind of rainfall dataset:    Year Month Day Amount 1  1950 1   1    0.0 2  1950 1   2   35.5 3  1950 1   3   17.8 4  1950 1   4   24.5 5  1950 1   5   12.3 6  1950 1   6   11.5 7  1950 1   7    5.7 8  1950 1   8   13.2 9  1950 1   9   11.

[R] Fitting gamma distribution

2015-02-16 Thread smart hendsome
I'm very new to r-programming. I have rainfall data. I have tried to fit gamma into my data but there is error. Anyone can help me please. My rainfall data as I uploaded. When I try run the coding: library(MASS) KLT1<-read.csv('C:/Users/User/Dropbox/PhD Materials/Coding_PhD_Thesis/Kelantan_Avera

[R] The profile log-likelihood problem

2013-11-20 Thread smart hendsome
Hi, Im still new to R and I have a problem regarding the code below. I don't know how to solve that. I want to compute profile log-likelihood using the rainfall data. I use the code below from Dunn: " tweedie.profile(Amount~Year*Month,p.vec=seq(1.35,1.75,length=50),method="series",do.ci=TRUE)