[R] List of Words in BioWordVec
Is there a way to extract list of words in BioWordVec in R Thank you Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Applying a function to dataframe column where the function value depends on the value of another column
Suppose I have a dataframe in this from a b c g 2 3 h 4 5 i 6 7 I want to apply a function to individual elements of column C where the function value depends on the value of column A [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Subclass Prediction
I am trying to work clustering problem where I actually know the sublcass. For example Suppose I am trying to predict cluster patients a group of people into male and female where I actually know the label male and female but I take it I don't know Suppose my clustering method produces subclasses label 1 and 2. Is there a quick method of how to assign which labels 1 and 2 to male or female to maximize my prediction accuracy? Obvious in this case since there are only two cases it is trivial but when the number of subclasses gets big it, trying all the possible combinations can be very time consuming. Regards Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Installing Caret
I am trying to install the package but am I keep getting this error messages installation of package ��minqa�� had non-zero exit status 2: In install.packages("caret", repos = "http://cran.stat.ucla.edu/;) : installation of package ��RcppEigen�� had non-zero exit status 3: In install.packages("caret", repos = "http://cran.stat.ucla.edu/;) : installation of package ��SparseM�� had non-zero exit status 4: In install.packages("caret", repos = "http://cran.stat.ucla.edu/;) : installation of package ��lme4�� had non-zero exit status 5: In install.packages("caret", repos = "http://cran.stat.ucla.edu/;) : installation of package ��quantreg�� had non-zero exit status 6: In install.packages("caret", repos = "http://cran.stat.ucla.edu/;) : installation of package ��pbkrtest�� had non-zero exit status 7: In install.packages("caret", repos = "http://cran.stat.ucla.edu/;) : installation of package ��car�� had non-zero exit status 8: In install.packages("caret", repos = "http://cran.stat.ucla.edu/;) : installation of package ��caret�� had non-zero exit status Anyone has any idea what wrong? Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Cut Dates into bins
It does not seem to work for me. I will show you exactly my data format SMA$TIME_DATE "28/9/2014" "17/6/2014" "19/9/2014" "17/1/2015" "13/1/2015" "21/10/2014" Shipment$DateRequire "2014-06-09" "2014-06-16" "2014-06-16" "2014-06-16" "2014-06-17" "2014-06-23" What I would like to do is the cut the first set of dates into the second set of dates > From: drjimle...@gmail.com > Date: Fri, 3 Jun 2016 18:59:11 +1000 > Subject: Re: [R] Cut Dates into bins > To: teotj...@hotmail.com > CC: r-help@r-project.org > > Hi Tjun Kiat, > This seems to work: > > daily_date<-as.Date(paste("2000-01",1:28,sep="-"),"%Y-%m-%d") > weekly_date<-as.Date(paste(c(1,8,15,22,28),"01/2000",sep="/"), > "%d/%m/%Y") > cut(daily_date,breaks=weekly_date,include.lowest=TRUE, > labels=paste("Week",1:4)) > > Jim > > > On Fri, Jun 3, 2016 at 6:00 PM, TJUN KIAT TEO <teotj...@hotmail.com> wrote: > > I have two set of dates > > > > 2000-01-01 > > > > 01/01/2000 > > > > The second one occurs weekly and the first one occurs in daily. I would > > like to bin the first set of dates into the second set of dates. What is > > the best way to do it? > > > > I tried converting both formats into numeric formats > > > > DateBase=sort(as.numeric(as.POSIXlt(unique(Shipment$DateRequire),format="%Y-%m-%D",origin="1900-01-01"))) > > > > Compare=as.numeric(as.POSIXlt(SMA$TIME_DATE,format="%d/%m/%y",origin="01/01/1900")) > > > > But the numeric numbers turned out to be very different. > > > > Tjun Kiat > > > > > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Matrix of Lists containing numbers and characters
Here is my sample code TunePar<-matrix(list(Null),2,2) TunePar[[1,1]]=list(subclasses=3,model="gen.ridge") tune=paste(colnames(Temp),Temp,sep="=") tune=paste(tune,collapse=",") However when I type tune This is what I get "subclasses=3,model=1" The text "gen.ridge has been converted to the number 1. Any idea why? Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Writing a matrix of lists as a CSV file
I have a matrix of lists in R that looks like this Crabs Glass nnet List,2 List,2rf List,1 List,1 An example of what a list looks like in the matrix size decay63 0.1 How can I write it into a csv file in R so I can retrieve it in the same format? Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] CSimca
Does anyone knows how to return the prediction probabilities for CSimca function for rrcovHD package? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Convert time format to character
Suppose I have a object in time format 2014-08-13 00:30:00 I want to convert it to a character string 20140813003000 Is is possible ? Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Variable Length Differ
This is my code BSUPred-(forecast(BSU,h=h)[[2]]) PressurePred-(forecast(Pressure,h=h)[[2]]) Placer-(rep(1,h)) test-as.data.frame(cbind(BSUPred,PressurePred)) test$Placer-rep(1:2,h/12) test$Placer-i test-as.data.frame((test[c(Placer,BSUPred,PressurePred)])) resp-predict(fit,newdata=test,type=response) Pred-ifelse((predict(fit,newdata=test,type=response)0.5),1,0) But I get this error message Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) : variable lengths differ (found for 'Placer') Can anyone help? Thanks Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Fine Tuning Parameters for LogReg in Caret
Is there a guide somewhere on how to set the tuning parameters for logistic regression in Caret ? Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Loading a rda file for predicton
I tried this fit-glm(Pred~Pressure+MissingStep, data = Test, family=binomial) save(fit,file=pred.rda) pred-load(pred.rda) predict(pred,Testsamp,type=response) But got this error message no applicable method for 'predict' applied to an object of class character What did I do wrong? Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Assigning a factor to a data frame
I created an an empty data frame this way: forsentest-data.frame(matrix(nrow=nod,ncol=f)). Then I tried to assign one row of another data frame forsen to it forsentest[1,]-forsen[1,] But the factors in forsen gets converted to numbers in forsentest which is not what I want. Is there another way around it ? Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] MDA
I am trying to use the package mda And this is my command mdfit-mda(factor(forsen[,f]) ~ .,data=forsen[,-f],subclasses=sc) But I keep getting this error message on a particular data set Error in maxdist[l] - x[l, i] : NAs are not allowed in subscripted assignments Can anyone help ? Thanks Regards Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] EMMIX
Is the R package EMMIX available ? I tried installing it and it keeps saying the package is not available for R verseion 3.0.1 teotjunk [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Fitting Mixture distributions
I was trying to use the normixEM in mixtools and I got this error message. And I got this error message One of the variances is going to zero; trying new starting values. Error in normalmixEM(as.matrix(temp[[gc]][, -(f + 1)])) : Too many tries! Are there any other packages for fitting mixture distributions ? Tjun Kiat Teo [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Generalized Cholesky Inverse
Yap. I did load the package bdsmatrix On Fri, Jun 21, 2013 at 8:26 AM, Pascal Oettli kri...@ymail.com wrote: Hi, Did you load bdsmatrix? Regards, Pascal 2013/6/21 Tjun Kiat Teo teotj...@gmail.com What are the possible options I have for Generalized choleksy Inverse in R. I tried to use the package bdsmatrix and and was given the error message function solve.gchol does not exist. Thanks Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Installing Jags on 64 Bit Fedora
I know this has been covered before but I have read all the posts on this subject but I still cannot resolve it. I tried to install rjags on a 64bit Fedora 17 and I got this error message Error : .onLoad failed in loadNamespace() for 'rjags', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/usr/lib64/R/library/rjags/libs/rjags.so': libjags.so.3: cannot open shared object file: No such file or directory ERROR: installing package indices failed * removing /usr/lib64/R/library/rjags The downloaded source packages are in /tmp/RtmpOfFX4c/downloaded_packages Updating HTML index of packages in '.Library' Making packages.html ... done Warning message: In install.packages(rjags, configure.args = --with-jags-include=/usr/local/include/JAGS --with-jags-lib=/usr/local/lib64/JAGS --with-jags-modules=/usr/local/lib64/JAGS/modules) : installation of package rjags had non-zero exit status Can anyone help ? Thanks Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Generalized Cholesky Inverse
What are the possible options I have for Generalized choleksy Inverse in R. I tried to use the package bdsmatrix and and was given the error message function solve.gchol does not exist. Thanks Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Bayes Logit and Cholesky Decomposition
I am trying to use the package Bayes Logit and I keep getting this error message. chol2inv(chol(P1.j)) : error in evaluating the argument 'x' in selecting a method for function 'chol2inv': Error in chol.default(P1.j) : the leading minor of order 5 is not positive definite I can't see why this would be so because the prior variance matrix that I feed in is a diagonal matrix so it is definitely positive definite. Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ODE solver
I am trying to use the package ode and periodically it will come up with this error message Warning..Internal T (=R1) and H (=R2) are such that in the machine, T + H = T on the next step (H = step size). Solver will continue anyway. And then the program just take very long to run. Is there anyway to get the program to terminate when this warning is issued instead of continuing to run ? Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Multicore/Parallel
I am using the package Multicore/Parallel to do importance sampling. I have 5 cores on my computer. And I have let's say 10 000 particles to generate. What I did was to send 5 particles in each time, calling the package parallel. Which means in all I am calling the parallel command 2000 times. What happens is in the end somewhere along the way I end up with the error message error in fork unable to create a pipe. Would it be better for me to call the parallel once only but each time send in 2000 particles in each parallel process. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Picking out certain elements in an matrix
Suppose I have a matrix of data A 1 2 3 4 5 6 7 8 9 And I have a vector of indexes 2,1,3 For row 1 of matrix A I want the 2nd element 2 For row 2 of matrix A I want the 1st element 4 For row 3 of matrix A I want the 3rd element 9. Is there a quick way to do it ? Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Bayes Logit
I tried to use mlogit.R in the package Bayes Logit and got this error message Error in .C(rpg_devroye, x, as.integer(n), z, as.integer(num), PACKAGE = BayesLogit) : C symbol name rpg_devroye not in DLL for package BayesLogit) Can anyone help? Thanks Tjun Kiat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Up key is not the previous command
I am using R on Fedora 17 and the up arrow is not the previous command. On my command line on my terminal, the up arrow is the previous command Tjun Kiat __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Simulating from probit
Is there anyway to simulate random deviates from probit ? Tjun Kiat __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] parallel
Does the function parallel work for windows ? Tjun Kiat __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Parallel Programming
I am trying to do parallel programming and I tried this library(doSNOW) library(foreach) testfunc-function(x){ x-x+1 x } noc-2 cl - makeCluster(do.call(rbind,rep(list(localhost),noc)), type = SOCK) registerDoSNOW(cl) clusterExport(cl=cl,c(testfunc.r)) testl-foreach(pp=1:2) %dopar% { testfunc(pp) } And this works but if I try to enclose my commands inside a text file to be sourced it doesn't work noc-2 testfunc-function(x){ x-x+1 x } cl - makeCluster(do.call(rbind,rep(list(localhost),noc)), type = SOCK) registerDoSNOW(cl) clusterExport(cl=cl,c(a,testfunc.r)) testl-foreach(pp=1:2)) %dopar% { source(test.r) } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Defining a variable outside of optim or differential equation solver.
This is applicable to either using optim or the differential equation solver or any similar solver Suppose I want to use the differential equation solver and this is my code d-y[2] vdpol-function(t,y) { list(c(1, d, 3, 4 ) } stiff-ode(y=rep(0,4),times=c(0,1),func=dvdpol,parms=1) The thing is I want d to be composed of one of state variables in the differential function vdopl. Can it be done ? tjun kiat __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Wrapper function for multivariate arrays for ode
I am trying to to write a wrapper function for the ode solver (under the package desolve) to enable it to take multivariate arrays. I know how to do it for 1 dimension arrays but my code breaks down when I try to do it for 2 dimensional arrays. Here is my code diffwrap-function(t,y,mu)vdpol(t=t,A[1:3,1:4]-y[1:12],B[1:12]-y[13:24],mu=mu) vdpol-function(t,A,B,mu) { list(c(mu, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, A[1,1], A[2,1], A[3,1], A[1,2], A[2,2], A[3,2], A[1,3], A[2,3], A[3,3], A[1,4], A[2,4], A[3,4]) ) } stiff-ode(y=rep(0,24),times=c(0,1),func=diffwrap,parms=1) I get keep getting the error message variable A[1,1] not found. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.