[R] R package for scorecard development

2017-06-28 Thread Nikhil Abhyankar
and tested the smbinning package. However, it only gives the bins for a single variable at a time. How can I get a full scorecard model? Thanks Nikhil [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE

[R] (no subject)

2017-03-05 Thread Nikhil Raj
hello Team R, i have been using R for statistical analysis of phylogeny and i have installed the required packages phangorn and phytools but whenever i give the command "pml.fit" the program stops and it appears thatb r for windows GUI has stopped etc.. previously i thought it was a fault in my com

[R] regarding a problem in R

2017-03-05 Thread Nikhil Raj
hello Team R, i have been using R for statistical analysis of phylogeny and i have installed the required packages phangorn and phytools but whenever i give the command "pml.fit" the program stops and it appears thatb r for windows GUI has stopped etc.. previously i thought it was a fault in my com

[R] help

2017-03-05 Thread Nikhil Raj
hello Team R, i have been using R for statistical analysis of phylogeny and i have installed the required packages phangorn and phytools but whenever i give the command "pml.fit" the program stops and it appears thatb r for windows GUI has stopped etc.. previously i thought it was a fault in my com

[R] Using lapply on term document matrix to calculate word frequency

2015-03-18 Thread Nikhil Goyal
Given three TermDocumentMatrix, text1, text2 and text3, I'd like to calculate word frequency for each of them into a data frame and rbind all the data frames. Three are sample - I have hundreds in reality so I need to functionalize this. It's easy to calculate word freq for one TDM: apply(x,

[R] Problem with levelplot() in a loop

2013-02-20 Thread Nikhil Joshi
Dear R users, I am trying to print heatmaps in a loop (with a pause). Idea is to visualize changing correlations over time and for testing I wrote this simple (reproducible) code below. My problem is that levelplot() does not produce any output when I run the code (though heatmap does). Ideally I

[R] Help with recursive least squares

2012-08-27 Thread Nikhil Joshi
I need some help with using recursive least squares lm.fit.recursive {quantreg}. I found some references online but cannot find a reproducible example as to how to use recursive least squares. I'd really appreciate if anyone can point me to a reproducible example. [[alternative HTML versi

[R] read.csv converts "NA" to missing values

2012-02-27 Thread nikhil abhyankar
the value 'NA' present in a column in a CSV file without R changing it to missing? Thanks Nikhil [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] Differences in SAS and R defaults

2011-08-30 Thread Nikhil Abhyankar
Yes, something similar would be helpful but not among SAS proc but between SAS and R. Thanks Nikhil On Mon, Aug 29, 2011 at 11:08 PM, Jeremy Miles wrote: > > Do you mean things like treatment of categorical variables in regression > procedures (which have different defaults in

[R] Package fgui returns error: Object of type closure is not subsettable

2011-04-11 Thread nikhil abhyankar
d and third functions. What could be the reason? Could it be because of the use of regular expressions? Thanks Nikhil [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEAS

[R] Saving console and graph output to same file

2011-04-05 Thread Nikhil Abhyankar
'textplot' and then saving the graphic output. However, the table does not look nice in the graph output. Is there any way the output from the console can be saved in a file and then the output from the graph window be appended to the same file? Thanks Nikhil [[alternative HTML versi

Re: [R] Problem with xlsx package

2011-02-10 Thread Nikhil Joshi
base package is sourced (or in other words upon starting a new R session). Or am I totally off? Regards Nikhil On Wed, Feb 9, 2011 at 8:28 PM, Gabor Grothendieck wrote: > On Wed, Feb 9, 2011 at 6:12 PM, Nikhil Joshi > wrote: > > I am trying to read an xlsx spreadsheet (1506 rows, 501

[R] Problem with xlsx package

2011-02-09 Thread Nikhil Joshi
I am trying to read an xlsx spreadsheet (1506 rows, 501columns) all populated but getting the following error: Please advise as to how to get around this issue. > res <- read.xlsx("c:\\BSE_v2.xlsx",1) Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.lang.OutOfMemor

[R] Problem in using bdh function for Govt tickers

2011-01-19 Thread nikhil
Hi, all I wanted to fetch data from Bloomberg for govt bonds, and analyse it further. I am having trouble in getting data as when I use field=PX_LAST, it is giving the prices but when I use field=CPN, or ISSUE_DT, it is not giving the results and just bouncing back for that. This is t

[R] Extracting user specified variables from data frame to use as function arguments

2011-01-07 Thread nikhil abhyankar
Hello All; I am writing an R program in the form of a function to find out the summary statistics for response variable(s) in a data frame. I need to accept variable names from the data as arguments and use them inside the function for various tasks. The dataset name is also one of the arguments

Re: [R] help identifying clusters

2010-10-20 Thread Nikhil Kaza
Look at clustering task view http://cran.r-project.org/web/views/Cluster.html A simple way to do it is library(cluster) dat$cluster <- pam(dat, 3, stand=T)$clustering plot(dat$lon, dat$lat, col=dat$cluster) Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carol

Re: [R] Using as.polynomial() over a matrix

2010-10-04 Thread Nikhil Kaza
apply(m, 1, function(x){print(as.polynomial(x))}) # Not sure why you are using 2 i.e. applying the formula column wise instead of 1, row wise. Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Oct 4, 2010, at 9:10 PM, Raznahan, Arm

Re: [R] removed data is still there!

2010-09-21 Thread Nikhil Kaza
example(factor) iris1$Species <- factor(iris1$Species, drop=T) will get you what you need. Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Sep 21, 2010, at 7:41 AM, pdb wrote: I'm confused, hope someone can point out

Re: [R] Finding (Ordered Subvectors)

2010-09-21 Thread Nikhil Kaza
Convert to strings and use grep functions. using c for variable is a bad idea. a <- paste(a, collapse="") b <- paste(b, collapse="") d <- paste(d, collapse="") grepl(b,a) grepl(d,a) Nikhil Kaza Asst. Professor, City and Regional Planning University of No

Re: [R] how to compute when row length is different

2010-09-14 Thread Nikhil Kaza
DF3 <- merge(DF1, DF2, by=c("Sample_id", "RepairHours), all.y=T) DF3$subtract <- DF3$Day_0_Read1-DF3$ ZeroMean Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Sep 14, 2010, at 8:38 AM, rasanpreet wrote: hi

Re: [R] problem with max in a function

2010-09-07 Thread Nikhil Kaza
Comments below On Sep 7, 2010, at 9:37 PM, stephen sefick wrote: Here is a striped down example that is not working because of the 1.00 to 1. Any help would be greatly appreciated. measure_bkf <- (structure(list(measurment_num = c(0, 0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.2, 2.4

Re: [R] How to remove all objects except a few specified objects?

2010-08-24 Thread Nikhil Kaza
or use #not checked rm(setdiff(ls(),c("a", "b")) On Aug 24, 2010, at 4:55 AM, Barry Rowlingson wrote: 2010/8/24 500600 : a <- 1 b <- 2 c <- 3 ls()[-a] # set minus to all the objects you want to retain rm(list = ls()[-a] # will remove all the objects - except a ls() # presto Only beca

Re: [R] Quantile Regression and Goodness of Fit

2010-08-23 Thread nikhil kaza
http://www.econ.uiuc.edu/~roger/research/R1/R1.html On Mon, Aug 23, 2010 at 2:15 PM, Steven Ranney wrote: > All - > > Does anyone know if there is a method to calculate a goodness-of-fit > statistic for quantile regressions with package quantreg? > Specifically, I'm wondering if anyone has imple

Re: [R] Help with Vectors and conditional functions

2010-08-19 Thread Nikhil Kaza
In additiion to Ivan's comment, in this case, you are just plotting Yes or No. I think thats not what you want. Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Aug 19, 2010, at 3:42 AM, Ivan Calandra wrote: Hi, I ha

Re: [R] replace loops with matrix

2010-08-17 Thread Nikhil Kaza
what is nt? is that a typo for ns? I don't see why you need to calculate lia within the loop. Also library(fBasics) ccl <-rowprod(lia) Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Aug 17, 2010, at 6:22 PM, Hey S

Re: [R] Equality of Vectors

2010-08-13 Thread Nikhil Kaza
?all nikhil.l...@gmail.com On Aug 13, 2010, at 2:49 PM, Downey, Patrick wrote: c(1,2,3) == c(1,2,3) __ 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

Re: [R] Fw: Error in rowSums REPOST

2010-08-13 Thread Nikhil Kaza
?as.numeric On Aug 13, 2010, at 7:50 AM, Amit Patel wrote: For the query below I have also included the follwing information. Thanks for your replies str(FeaturePresenceMatrix) chr [1:65530, 1:40] "0" "0" "0" "0" "1" "0" "0" "0" "0" ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:65530]

Re: [R] Help with permutation / loops

2010-08-12 Thread nikhil kaza
with. apply(b,2, paste, collapse="_") On Thu, Aug 12, 2010 at 10:15 AM, Ferreira, Thiago Alves < thiago.alves.ferre...@citi.com> wrote: > Hello Nikhil, hope you are well today. > I am sorry to be a pain but I have one follow up question, I am trying to > express my results in a

Re: [R] Help with permutation / loops

2010-08-11 Thread Nikhil Kaza
default device. One way to overcome it is to plot them to a pdf and name them appropriately for each iteration. Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Aug 11, 2010, at 6:34 AM, Ferreira, Thiago Alves wrote: Hi everyo

Re: [R] efficient matrix element comparison

2010-08-08 Thread Nikhil Kaza
How about a <- which(row(matchM)!=matchM) b <- matchM[a] diag(collusionM[a,b]) <-1 Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Aug 8, 2010, at 8:43 PM, david h shanabrook wrote: It is a simple problem in that I simpl

Re: [R] Best way to Convert String to Time for comparison?

2010-08-04 Thread Nikhil Kaza
Another way is t1<- c("3:00","1:59","3:00","2:00") t2 <- strptime(t1, format="%H:%M") t2[-4]>t2[-1] Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Aug 4, 2010, at 8:47

Re: [R] Plotting multiple layers(maps) on same page

2010-08-03 Thread Nikhil Kaza
you will have a better luck with R-sig-geo. Unfortunately I could not find an easy way for polygon overlays. plot(Tazshape) lines(ugbshape) if ugbshape was a polyline instead of a polygon. Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l

Re: [R] Need help on upper.tri()

2010-08-03 Thread Nikhil Kaza
try using Matrix package instead mat <- Matrix(rnorm(25),5,5) forceSymmetric(mat) The reason your method does not work is because matrix is effectively a vector and the indices increase along rows within a column. Nikhil On Aug 3, 2010, at 7:36 AM, Ron Michael wrote: HI, I am rea

Re: [R] Collinearity in Moderated Multiple Regression

2010-08-03 Thread Nikhil Kaza
My usual strategy of dealing with multicollinearity is to drop the offending variable or transform one them. I would also check vif functions in car and Design. I think you are looking for lm.ridge in MASS package. Nikhil Kaza Asst. Professor, City and Regional Planning University of North

Re: [R] Collinearity in Moderated Multiple Regression

2010-08-03 Thread Nikhil Kaza
Are x1 and x2 are factors (dummy variables)? cor does not make sense in this case. Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Aug 3, 2010, at 9:10 AM, Michael Haenlein wrote: Dear all, I have one dependent variable y and

Re: [R] sorting by date

2010-08-02 Thread Nikhil Kaza
> a <- c( 20071031,20071130, 20071231) b<- sort(as.Date(as.character(a), format="%Y%M%d")) On Aug 2, 2010, at 8:03 PM, Leigh E. Lommen wrote: I am unsure how to sort a column by date if it is currently in the form: MMDD For example the months: 20071031 20071130 20071231 Etc. Re

Re: [R] Dealing with a lot of parameters in a function

2010-08-02 Thread nikhil kaza
use 24 length vectors as parameters instead of numbers e.g. mu=rep(0.5,24) On Mon, Aug 2, 2010 at 11:00 AM, Shentu, Yue wrote: > Hi all, > I'm trying to define and log-likelihood function to work with MLE. > There will be parameters like mu_i, sigma_i, tau_i, ro_i, for i between > 1 to 24. I

Re: [R] removing spatial auto correlation

2010-08-02 Thread nikhil kaza
Try r-sig-geo Look at spdep, geoR, splancs and sp packages for spatial autocorrelation. Also look at http://cran.r-project.org/web/views/Spatial.html On Mon, Aug 2, 2010 at 3:40 AM, nuncio m wrote: > Hi list, > I am trying to fit arima model for a grid of 360x161x338 points, > where

Re: [R] Meaning of following function

2010-08-01 Thread Nikhil Kaza
well "*"(3,2) works but "*"(3,2,3) does not. You should now be able to figure out the logic. It is related to the number of arguments that make sense. Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Aug

Re: [R] question!!

2010-08-01 Thread Nikhil Kaza
?replicate ?apply ?sapply Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Aug 1, 2010, at 2:42 AM, leepama wrote: hi!! imade many codes during these days.. I study Statistics please one more question!! ex1<-function(n,p,

Re: [R] Left Outer Join 2 DF's on Multiple Conditions

2010-07-25 Thread Nikhil Kaza
Look at sqldf package, it is easier to do sql like statements with it. Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Jul 25, 2010, at 6:10 PM, harsh yadav wrote: Hi, I am trying to execute the following SQL statement using two

Re: [R] Updating a Data Frame

2010-07-22 Thread Nikhil Kaza
mp", "isSynchronized","timediff)] <- cbind(dataF[,"tobiitime"], rep(1,nrow(dataF), (dataF[i,"ruiTime"]-dataF[,"tobiitime"])) } Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Jul

Re: [R] replacing elements of distance matrix

2010-07-19 Thread Nikhil Kaza
My mistake, instead of colnames(d1) use substr(colnames(d1),1,1) or similar On Jul 19, 2010, at 2:15 PM, Nikhil Kaza wrote: Michael, You can modify the following code to suit. Also avoid using dist as a variable name since it is a function in base. However, are you sure you want to do

Re: [R] replacing elements of distance matrix

2010-07-19 Thread Nikhil Kaza
;- n.L[[i]]} m2 <- function(i,j){mahalanobis(j, i, var(j))} m3 <- function(k){apply(as.matrix(k),1,m2,as.matrix(k))} d2 <- lapply(x.L, m3) Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Jul 19, 2010, at 11:37 AM, Michael Ralph M. Ab

Re: [R] replacing elements of distance matrix

2010-07-19 Thread Nikhil Kaza
replace dist with mahalanobis distance in the following example. a <- cbind(runif(10), sample(1:3, 10, replace=T)) a.L <- split(a,a[,2]) dist.L <- lapply(a.L, dist) Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Jul

Re: [R] Help with replacing a substring in a string

2010-07-19 Thread Nikhil Kaza
gsub(".", " ", "abc.degg.hijk", fixed=T) On Jul 19, 2010, at 7:37 AM, Tolga I Uzuner wrote: Actually, I think I got it, need to use gsub. From: Tolga I Uzuner Sent: 19 July 2010 12:11 To: 'r-help@r-project.org' Subject: Help with replacing a substring in a string Dear R Users, I am trying to

Re: [R] Two Dimensional Transformation

2010-07-16 Thread Nikhil Kaza
Unless I am missing something this should do it a<- cbind(runif(10),runif(10)) b <- cbind(a[,1]+a[,2], a[,1]/a[,2]) On Jul 16, 2010, at 7:00 AM, Ravi Ramaswamy wrote: Hi - I am trying to map a two dimensional area A to another two dimensional area B using a function. For instance A =

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Nikhil Kaza
Building on Erik's solution and because it would easier to do date arithmetic.. d1 <- as.character(date) d1 <- ifelse(nchar(d1)<4, paste(0,d1,sep=""),d1) d2 <- as.Date(date, "%m%d") On Jul 15, 2010, at 1:21 PM, btc1 wrote: Hello, I have a vector, "dates", as a series of 3 digit elements,

Re: [R] Batch file export

2010-07-13 Thread Nikhil Kaza
write.csv(z, paste("c:/z_",i,".csv"sep='')) You will have to modify this to prepend 0s. Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Jul 13, 2010, at 10:03 AM, Michael Haenlein wrote: Dear all,

Re: [R] Substring function?

2010-07-13 Thread Nikhil Kaza
well %in% is really checking if the element is in the set and is not a substring operator. To get the result you want, try content[grepl(search$signatures, content$urls),] For multiple operations you could try sapply(search$signatures, grepl, x=content$urls) Nikhil Kaza Asst. Professor

Re: [R] Batch files process and String parsing

2010-07-07 Thread Nikhil Kaza
?list.files In particular look at pattern argument. ?file.rename ?lapply ?read.table ?"[" Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Jul 7, 2010, at 1:11 PM, jd6688 wrote: Here are what i am going to accomplis

Re: [R] how to display the clock time in the loop

2010-07-01 Thread Nikhil Kaza
explicit call to print usually works for me. library(audio) for (i in 1:5){ wait(60) print(Sys.time()) } On Jul 1, 2010, at 4:30 PM, Matt Shotwell wrote: > Try to flush output after printing: > > cat(paste(Sys.time()),"\n"); flush(stdout()) > > On Thu, 2010-07-01 at 16:1

Re: [R] How to delete rows based on replicate values in one column with some extra calcuation

2010-06-29 Thread Nikhil Kaza
You can do this in reshape package as mentioned earlier. However, if you need a solution with aggregate here it is a <- with(data, aggregate(cbind(v1,v2), by=list(x,y,z),sum)) names (a) <- c("x","y","z","v1","v2") Nikhil Kaza Asst. P

Re: [R] How to delete the replicate rows by summing up the numeric columns

2010-06-29 Thread Nikhil Kaza
require(reshape) cast(data, first+second~ ., sum) Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Jun 29, 2010, at 3:05 PM, Yi wrote: first=c('u','b','e','k','j','c',&#

Re: [R] How to delete rows based on replicate values in one column with some extra calcuation

2010-06-28 Thread Nikhil Kaza
aggregate(data$third, by=list(data$first), sum) or reqiure(reshape) cast(melt(data), ~first, sum) On Jun 28, 2010, at 9:30 PM, Yi wrote: first=c('u','b','e','k','j','c','u','f','c','e') second = c ('usa ','Brazil ','England','Korea','Japan','China','usa','France','China','England') third=1

Re: [R] optim() not finding optimal values

2010-06-26 Thread Nikhil Kaza
. Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Jun 26, 2010, at 4:27 PM, Derek Ogle wrote: I am trying to use optim() to minimize a sum-of-squared deviations function based upon four parameters. The basic function is defined as

Re: [R] Spatial: number of independent components?

2010-06-21 Thread Nikhil Kaza
-11 coda_0.13-5 [5] deldir_0.0-12 maptools_0.7-34 [7] foreign_0.8-40 nlme_3.1-96 [9] MASS_7.3-6 Matrix_0.999375-39 [11] lattice_0.18-8 boot_1.2-42 [13] sp_0.9-64 loaded via a namespace (and not attached): [1] grid_2.11.1 tools_2.11.1 Nikhil Kaza Asst. Professor, C

Re: [R] Spatial: number of independent components?

2010-06-21 Thread nikhil kaza
I have spdep 4.58. Perhaps it is deprecated in the new version. Try looking for sparse matrix representation in the help files for spdep Nikhil On Mon, Jun 21, 2010 at 6:10 AM, Daniel Malter wrote: > > as.spam.listw is an unknown function. Is it in a different package? > > Dani

Re: [R] Spatial: number of independent components?

2010-06-20 Thread nikhil kaza
Instead of nb2mat try as.spam.listw(nb2listw(cell2nb(...))) this will coerce the adjacency matrix into a sparse matrix representation saving lot of memory. Nikhil On Sun, Jun 20, 2010 at 10:27 PM, Daniel Malter wrote: > > Hi, thanks much. This works in principle. The corrected code is

Re: [R] Spatial: number of independent components?

2010-06-20 Thread Nikhil Kaza
. library(spdep) library(igraph) x=matrix(c(0,1,0,0,0, 0,1,1,0,0, 0,0,0,0,0, 0,0,0,1,0, 0,0,0,1,0),nrow=5) a <- nb2mat(cell2nb(nrow(x),ncol(x)), style="B", torus="TRUE") g <- delete.vertices(graph.adjacency(a), which(x!=1)-1) p

Re: [R] Find the 50 highest values in a matrix

2010-06-17 Thread Nikhil Kaza
Matrix is just a vector. So order should work haven't verified the following code. a <- matrix(rnorm(4000*2000), 4000, 2000) b <- order(a, na.last=TRUE, decreasing=TRUE)[1:50] use %% or %/% to get the row# and column #s Nikhil Kaza Asst. Professor, City and Regional Planning Un

Re: [R] Backslash in paste() function

2010-06-16 Thread Nikhil Kaza
On Jun 16, 2010, at 9:23 AM, Stefan Petersson wrote: Just double all the backslashes and you are fine. In order to see the outcome, use cat() (not print). Uwe Ligges On 16.06.2010 09:49, Stefan Petersson wrote: Hi, I'm trying to build a vector of latex commands. However, I need the comm

Re: [R] [R-sig-Geo] How to extract coordinates values from a shapefile?

2010-06-09 Thread Nikhil Kaza
What does coordinates() give for a polygon? centeroid? I suppose I could look up the code, but it would be immensely helpful if the help page could specify it. regards Nikhil On Jun 9, 2010, at 3:50 PM, Rodrigo Aluizio wrote: > I'm not sure if this is what you want. But the

Re: [R] Odp: strange issue with "which" on "seq"

2010-06-09 Thread Nikhil Kaza
which(abs(v - .1) <= .Machine$double.eps) seems to me too cumbersome to write. Any other easier way? all.equal does not quite work Nikhil On Jun 9, 2010, at 7:54 AM, Petr PIKAL wrote: Hi r-help-boun...@r-project.org napsal dne 09.06.2010 13:16:40: Dear R community, I am puzzled by

Re: [R] reformat time from hhmm

2010-06-03 Thread nikhil kaza
Minor correction below. Use 0 instead of space if you are using %H On Thu, Jun 3, 2010 at 8:55 PM, nikhil kaza wrote: > ?ifelse > > > t2 <- ifelse(nchar(times)<4, paste("0", times, sep=""), times) > > > strptime(t2, "%H%M") > > Ni

Re: [R] reformat time from hhmm

2010-06-03 Thread nikhil kaza
?ifelse > t2 <- ifelse(nchar(times)<4, paste(" ", times, sep=""), times) > strptime(t2, "%H%M") Nikhil On Thu, Jun 3, 2010 at 5:21 PM, Peter Moore wrote: > Hi, > I'm newish to R, a recent convert from Matlab... So far I'm impress

Re: [R] Faster union of polygons?

2010-06-03 Thread nikhil kaza
Reduce might work. Not sure about the speed advantages though. It does simplify code. Unionall <- function(x) Reduce('union', x) leaveout <- Unionall(leaves) On Tue, Jun 1, 2010 at 9:53 PM, Remko Duursma wrote: > Dear R-helpers, > > thanks for yesterday's speeding-up tip. Here is my next query

Re: [R] How to make R automatic?

2010-06-01 Thread Nikhil Kaza
?difftime ?file.info file.info(filename)$mtime Sys.sleep(20) Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Jun 1, 2010, at 10:07 AM, zhangted001 wrote: Hello, I have a question about how R can run automatically. Here is

Re: [R] rounding up to nearest integer

2010-05-24 Thread Nikhil Kaza
?round On May 24, 2010, at 9:26 PM, Mohan L wrote: Dear All, I have a data frame "data" and the below is the str of "data" : $ Feb : int 1 1195 0 11 28 152 24 2 1 1470 ... $ Mar : int 0 1212 0 17 27 184 15 1 1 1311 ... $ Apr : int 2 1244 1 15 23 135 11 0 1 991 ... $ May : int 2

Re: [R] sort a data.frame

2010-05-20 Thread Nikhil Kaza
Try this. dd[order(gsub("chr","",dd$b)),] You need regular expressions if chr is not the only characterstring that is prepended to the numbers. look for ?strsplit Nikhil Kaza University of North Carolina nikhil.l...@gmail.com On May 20, 2010, at 8:28 AM, Yuan Jia

Re: [R] Adding a row at top of dataframe

2010-05-17 Thread Nikhil Kaza
My mistake. cars2 should be initalized to have all the extra rows. cars2 <- data.frame(matrix(rep(NA, prod(dim(cars)) + ncol(cars)), nrow(cars)+1)) cars2[2:nrow(cars2),] <- cars In this way, insertion at any row is possible. Nikhil On May 17, 2010, at 2:46 PM, Peter Ehlers wrote: >

Re: [R] Adding a row at top of dataframe

2010-05-17 Thread Nikhil Kaza
Works with warnings for me. but your method is better. Nikhil On May 17, 2010, at 1:35 PM, Peter Ehlers wrote: data(cars) cars2 <- cars cars2[2:nrow(cars)+1,] <- cars2[1:nrow(cars),] cars2[1,] <- NA __ R-help@r-project.org mailing l

Re: [R] Adding a row at top of dataframe

2010-05-17 Thread Nikhil Kaza
Does this work? data(cars) cars2 <- cars cars2[2:nrow(cars)+1,] <- cars2[1:nrow(cars),] cars2[1,] <- NA Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On May 17, 2010, at 11:28 AM, ecvet...@uwaterloo.ca wrote: I hav

Re: [R] All possible paths between two nodes in a flowgraph using igraphs?

2010-05-04 Thread Nikhil Kaza
paths. I am not sure about cycles. But I suppose you can just use the minimum spanning tree and iteratively add the remaining edges to get the cycles. Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On May 4, 2010, at 7:34 AM, jcano

Re: [R] Text dependent on a variable in a R function

2010-05-02 Thread nikhil kaza
Thats right. serves me for not checking the code before posting. but paste should work in anycase with collapse or when x is a single parameter. Nikhil On Sun, May 2, 2010 at 10:24 AM, David Winsemius wrote: > > On May 2, 2010, at 10:10 AM, Nikhil Kaza wrote: > > say x is

Re: [R] Text dependent on a variable in a R function

2010-05-02 Thread Nikhil Kaza
say x is the variable. plot(..., title=paste(x, "whatever else"), ...) should work as well. same should work with file names as well. Nikhil On May 1, 2010, at 9:56 PM, R K wrote: Hello, I was wondering if someone could tell me how I can make text dependent on a varia

Re: [R] Problem with optimization (constrOptim)

2010-04-29 Thread Nikhil Kaza
Ah..constrOptim is for linear inequality constraints. your ci is a matrix. it should be a vector. Nikhil On Apr 29, 2010, at 3:14 AM, Cz³owiek Kuba wrote: > Hi, > > You are right, my intention was to return a set of values and to > minimize them all in a multicriteria

Re: [R] Problem with optimization (constrOptim)

2010-04-28 Thread Nikhil Kaza
fr does not return a scalar. Nikhil On Apr 28, 2010, at 3:35 AM, Człowiek Kuba wrote: Hello, I have the following problem: I have a set of n matrix equations in the form of : [b1] = [A] * [b0] [b2] = [A] * [b1] etc. vertical vectors [b0], [b1], ... are GIVEN. We try to estimate matrix A

Re: [R] Convert character vector into string

2010-04-28 Thread Nikhil Kaza
?cat On Apr 28, 2010, at 11:21 PM, Ian Seow wrote: Hi, how do I convert a character vector into a string? c("a","b","c") into "a b c" Thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.c

Re: [R] Finding the max correlation coefficient value using CCF function

2010-04-28 Thread Nikhil Kaza
try this ?which.max Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Apr 27, 2010, at 11:42 PM, vikrant wrote: Hi All, Suppose I have 2 time series a = 1:20 b = 5:15 and I am finding the cross correlation between these two

Re: [R] 2 simple question

2010-04-24 Thread Nikhil Kaza
If I understand it correctly par(mfrow=c(2,2)) plot(x,y) plot(y,z) . should work. On Apr 24, 2010, at 8:11 AM, Jim Lemon wrote: On 04/24/2010 02:52 AM, tamas barjak wrote: Hi All! I have 2 plain questions: 1.) I know that very primitive question, but that to grant it, that the drawi

Re: [R] is.na<- doesn't seem to work with labelled variables?

2010-04-06 Thread Nikhil Kaza
a <- c(1, 8, 9, 10, 8) a[which(a==8)] <- NA Nikhil On Apr 6, 2010, at 7:31 AM, David Foreman wrote: Dear All, I seem entirely unable to solve what should be a very simple problem. I have imported a SPSS dataset into R using spss.get from Frank Harrell's Hmisc library. Th

Re: [R] Optim() Help, Unusual Error

2010-03-23 Thread Nikhil Kaza
s in the comp. That is probably the error Nikhil On Mar 23, 2010, at 3:38 PM, ApproxGaussian wrote: I apologize, the "c" is in the original coding; I merely misprinted (copy and paste). I have edited the orginal post to reflect this. -- View this message in context: http://n4.nab

Re: [R] Optim() Help, Unusual Error

2010-03-23 Thread Nikhil Kaza
missed a c(...) here, therefore no par defined. On Mar 23, 2010, at 12:58 PM, ApproxGaussian wrote: par<-(e.1,e.2,e.3,e.4,e.5,e.6,e.7,e.8,e.9,e.10,e.11,e.12,e.13,e.14,e. 15,e.16,e.17,e.18,e.19,e.20,e.21,e.22,e.23,e.24,e.25,e.26,e.27,e.28) __ R-help

Re: [R] Delete all object except some particular ones

2010-03-20 Thread Nikhil Kaza
rm(setdiff(ls(), c("AA", "BB")) should work. On Mar 20, 2010, at 12:27 PM, bogaso.christofer wrote: Dear all, in my working project, I have created huge number of different kind of objects including "AA" and "BB". Now I want to delete all objects except that "AA" and "BB". Is there any proc

Re: [R] Selecting single TAZ based on area proportion

2010-02-08 Thread Nikhil Kaza
ximum. The above just returns the first maximum. Nikhil On Feb 8, 2010, at 1:14 PM, LCOG1 wrote: Good day all, I am having an issue coercing my data. Below i have some data on taxlots and an associated TAZ(transportation analsysi zone) that each property is within. The main issue is th

Re: [R] Odp: Creating Dummy Variables in R

2009-12-16 Thread Nikhil Kaza
I don't think R will complain, if you use the approach below. However, IF, VVS1 and VVS2 are linearly dependent. Better use the factor approach and define which factor should be the contrast Nikhil On 16 Dec 2009, at 10:12AM, Petr PIKAL wrote: what commands did you use for regressi

Re: [R] Changing Column names in (Output) csv file

2009-12-16 Thread Nikhil Kaza
0[i]) write.csv(c(ONS$labels, ONS$Freq), file="prob_table.csv") Alternately just use concatenate command in excel after you exported the joint probs. Nikhil On 15 Dec 2009, at 7:53AM, Amelia Livington wrote: Dear R helpers Following is a part of R code. data_lab <- ex

Re: [R] Help with missing values in the dataset

2009-12-10 Thread Nikhil Kaza
?merge use all=L On 10 Dec 2009, at 6:06AM, Venkatesh.P wrote: Dear all, I am facing problem with inserting the scheduled day of Observation in the dataset. In the dataset I have only relative time (table 1) and not scheduled day of observation (day 1, 4, 8, 15, 22, 29, 36, 43). I would

Re: [R] conditionally merging adjacent rows in a data frame

2009-12-09 Thread Nikhil Kaza
This is great!! Sqldf is exactly the kind of thing I was looking for, other stuff. I suppose you can speed up both functions 1 and 5 using aggregate and tapply only once, as was suggested earlier. But it comes at the expense of readability. Nikhil On 9 Dec 2009, at 7:59AM, Titus von

Re: [R] conditionally merging adjacent rows in a data frame

2009-12-08 Thread Nikhil Kaza
uot;)) I suppose one could save some time by not running aggregate twice on the same dataset, but I am not sure how. Nikhil On 8 Dec 2009, at 7:50AM, Titus von der Malsburg wrote: Hi, I have a data frame and want to merge adjacent rows if some condition is met. There's an obviou

Re: [R] Help with Nested loop - very slow, can I use an apply?

2009-12-07 Thread Nikhil Kaza
From an old post by Gabor http://tolstoy.newcastle.edu.au/R/help/04/01/0147.html apply (outer (landmark_c,t(store_c),"-"),c(1,4),function(x)sqrt(sum(diag(x*x On 7 Dec 2009, at 10:58PM, dolar wrote: Hi there I have two tables, with longitudinal and latitudinal coordinates. what I

Re: [R] How to get the item in list that is a number?

2009-11-24 Thread Nikhil Kaza
?unlist if I understand you correctly. On 24 Nov 2009, at 5:50PM, Peng Yu wrote: I have the following list. The second item in the list is a number. I'm wondering how to write R code to return this information for any list? $`1` integer(0) $`2` [1] 123 $`3` integer(0) $`4` integer(0) $`5

Re: [R] Do you keep an archive of "useful" R code? and if so - how?

2009-11-22 Thread Nikhil Kaza
I 've used tiddlywiki a personal notebook for other things but not for R. It may be useful to write a css that separates out code from description. http://www.tiddlywiki.com/ On 22 Nov 2009, at 11:53AM, Tal Galili wrote: Hello all, When using R for some time, one comes across more and mor

Re: [R] optim(.. ,"SANN",..)

2009-11-21 Thread Nikhil Kaza
product To see this try set.seed(1) v<- runif(12, -10,10) fr(v) Nikhil On 19 Nov 2009, at 6:05PM, lloyd barcza wrote: > fr<-function(x){y<-x*D > C<-apply(t(apply(y,1,function(c){c[c>0]})),1,prod) > R2<-R*C > w<-R2[R2 g<-sum(w) > return(g)}

Re: [R] How to transform the Matrix into the way I want it ???

2009-11-09 Thread Nikhil Kaza
This is not an answer to your question, but I have used SparseM package to represent large travel time matrices efficiently. ?as.matrix.ssr if the traveltime matrix is symmetric. On 9 Nov 2009, at 5:24PM, Hongwei Dong wrote: Hi, R users, I'm trying to transform a matrix A into B (see belo

Re: [R] Find the first values in vector

2009-11-09 Thread Nikhil Kaza
How about vec[1:min(which(vec==FALSE))-1] This will return a character(0) vector if vec[1] is FALSE Nikhil On 9 Nov 2009, at 2:38PM, David Winsemius wrote: vec= TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE TRUE TRUE FALSE __ R-help@r

Re: [R] Frequency

2009-11-02 Thread Nikhil Kaza
try sort (table(MAT), decreasing=T) if MAT is your matrix I think this is what you want. though if you want to sort by the first occurrence then it is a different story. Nikhil On 2 Nov 2009, at 1:35PM, Val wrote: V1 v2 v3 v4 569 10 347 10 46 10 18

Re: [R] Re ading and Creating Shape Files

2009-10-29 Thread Nikhil Kaza
ty of using using a unique ID for the tax records and after the analysis in R just joining the resulting table in a GIS to your original shapefile. Nikhil On 28 Oct 2009, at 1:33PM, PDXRugger wrote: Hello R Community, I have imported a dataset which contain X Y coordinates and would

[R] Recode issue

2009-10-22 Thread Nikhil Kaza
I am having trouble with the recode function that is provided in the CAR package. I trying to create a new factors based on existing factors. E.g. >x <- as.factor(1:20) >y <- recode(x, " 1:5='A'; 6:10='B'; 11:15='C'; 16:20='D' ") >y [1] A A A A A 6 7 8 9 A A A A A A A A A A A Levels: 6 7 8 9

  1   2   >