Re: [R] data

2013-06-08 Thread arun
Hi, Try this: final3New-read.table(file=real_data_cecilia.txt,sep=\t) dim(final3New) #[1] 5369    5 #Inside the split within split, dummy==1 for the first row.  For lists that have many rows, I selected the row with dummy==0 (from the rest) using the #condition that the absolute difference

Re: [R] Clogit R and Stata

2013-06-08 Thread peter dalgaard
The n = 1404 vs. Number of obs =468 looks like the giveaway. You are passing the subset selection logic as the 3rd positional argument, but according to the documentation, that is the weights argument. So, clogit(..., data = dframe, subset = sample==1 glb_ind==Y) On Jun 7, 2013,

[R] modify and append new rows in a dataframe

2013-06-08 Thread Santiago Guallar
My data frame shows changes on the variable act which records the consecutive duration (in seconds) of two states (wet-dry) over a few days for several  individuals (identified by Ring). Since I want to work with daytime (i.e. from dawn till dusk) and night time (i.e. from dusk till next dawn),

Re: [R] data - matched samples, dataframes, panel data

2013-06-08 Thread Cecilia Carmo
It seems to do all I want: 1. matchs the greatest number of firms within an year and industry, by dimension 2. diferences between dimensions should not be more than 10% or/and 200 (if I want just the 10% restrition I think I could substitute 200 for a big number that is impossible to exist)

[R] Add blank rows to a dataframe

2013-06-08 Thread Bert Jacobs
Hi, I have a vector that looks like this: RowSel -c(0,1,0,1,2,3,0,5,5) Now I want to select rows from a specific dataframe DF based on that vector like this: SubDF - DF[RowSel,] So this works fine, but I was wondering how I could add blank rows add the locations in the vector where there is a

Re: [R] Add blank rows to a dataframe

2013-06-08 Thread Duncan Murdoch
On 13-06-08 7:09 AM, Bert Jacobs wrote: Hi, I have a vector that looks like this: RowSel -c(0,1,0,1,2,3,0,5,5) Now I want to select rows from a specific dataframe DF based on that vector like this: SubDF - DF[RowSel,] So this works fine, but I was wondering how I could add blank rows add the

Re: [R] splitting a string column into multiple columns faster

2013-06-08 Thread Dimitri Liakhovitski
Thank you so much, Jorge and Arun - I'll give it a try! Dimitri On Fri, Jun 7, 2013 at 11:27 PM, arun smartpink...@yahoo.com wrote: HI, Tried it on 1e5 row dataset: l1- letters[1:10] s1-sapply(seq_along(l1),function(i) paste(rep(l1[i],3),collapse=)) set.seed(24)

[R] Help with multiple use of quantile

2013-06-08 Thread Parodi, Pietro
Hello I have a matrix aaa like this: aa1 aa2 aa3 [1,] 8371.417 27613.57 1170.466 [2,] 14317.999 42421.82 3423.934 [3,] 22026.466 59874.14 8103.084 [4,] 33884.986 84506.34 19176.764 [5,] 57954.968 129824.30 56097.310 where each column represents an empirical

Re: [R] Trying to install NADA in R 3.0.0

2013-06-08 Thread David Doyle
Thanks Janh!! For others that may be having the same issue, here is what I got from him and it worked. The package and be downloaded from http://cran.r-project.org/src/contrib/Archive/NADA/ -- Hi David, The author (Lopaka Lee) says that

Re: [R] Help with multiple use of quantile

2013-06-08 Thread Adams, Jean
Try this, Pietro ... # example data aaa - matrix(rnorm(60), ncol=3) bbb - matrix(runif(15), ncol=3) # calculate quantiles ccc - sapply(1:dim(aaa)[2], function(i) quantile(aaa[, i], bbb[, i])) # change rownames rownames(ccc) - seq(dim(ccc)[1]) Jean On Sat, Jun 8, 2013 at 8:20 AM, Parodi,

Re: [R] Add blank rows to a dataframe

2013-06-08 Thread David Winsemius
On Jun 8, 2013, at 4:09 AM, Bert Jacobs wrote: Hi, I have a vector that looks like this: RowSel -c(0,1,0,1,2,3,0,5,5) Now I want to select rows from a specific dataframe DF based on that vector like this: SubDF - DF[RowSel,] So this works fine, but I was wondering how I could add

Re: [R] Problem with ODBC connection

2013-06-08 Thread Christofer Bogaso
Hello All, My previous post remains unanswered probably because the attachment was not working properly. So I am re-posting it again. My problem is in reading an Excel-2003 file through ODBC connection using RODBC package. Let say I have this Excel file:

Re: [R] Add blank rows to a dataframe

2013-06-08 Thread arun
RowSel -c(0,1,0,1,2,3,0,5,5) set.seed(24) DF- as.data.frame(matrix(sample(1:40,45,replace=TRUE),ncol=5)) RowSel[!as.logical(RowSel)]-NA DF[RowSel,] # V1 V2 V3 V4 V5 #NA   NA NA NA NA NA #1    12 11 21 24 30 #NA.1 NA NA NA NA NA #1.1  12 11 21 24 30 #2 9 25  6 26 26 #3    29 15  4  2 28

Re: [R] Help with multiple use of quantile

2013-06-08 Thread arun
HI, You could also use: set.seed(24) aaa - matrix(rnorm(60), ncol=3) bbb - matrix(runif(15), ncol=3) ccc1- mapply(quantile,as.data.frame(aaa),as.data.frame(bbb)) ccc - sapply(1:dim(aaa)[2], function(i) quantile(aaa[, i], bbb[, i])) #Jean's solution colnames(ccc1)-NULL   identical(ccc,ccc1)

Re: [R] Help with multiple use of quantile

2013-06-08 Thread Rui Barradas
Hello, And you really don't need colnames(ccc1) - NULL, there's a USE.NAMES argument to mapply. Just set it to FALSE. Rui Barradas Em 08-06-2013 18:28, arun escreveu: HI, You could also use: set.seed(24) aaa - matrix(rnorm(60), ncol=3) bbb - matrix(runif(15), ncol=3) ccc1-

Re: [R] recode: how to avoid nested ifelse

2013-06-08 Thread Neal Fultz
rowSums and Reduce will have the same problems with bad data you alluded to earlier, eg cg = 1, hs = 0 But that's something to check for with crosstabs anyway. Side note: you should check out the microbenchmark pkg, it's quite handy. Rrequire(microbenchmark) Rmicrobenchmark( +

[R] reading a character translation table into R

2013-06-08 Thread Michael Friendly
I have a txt file (attached) that defines equivalents among characters in latin1 (or iso-8859-1), numeric #xxx; codes, HTML entities and latex equivalents. A portion of the file is shown inline below, but may not be rendered well in this email. I'd like to read this into R to use as a

Re: [R] reading a character translation table into R

2013-06-08 Thread Duncan Murdoch
On 13-06-08 4:31 PM, Michael Friendly wrote: I have a txt file (attached) that defines equivalents among characters in latin1 (or iso-8859-1), numeric #xxx; codes, HTML entities and latex equivalents. A portion of the file is shown inline below, but may not be rendered well in this email. I'd

Re: [R] splitting a string column into multiple columns faster

2013-06-08 Thread Dimitri Liakhovitski
Thanks again, guys! Arun's method worked. I have over 270,000 rows and it took me 1 min. Dimitri On Sat, Jun 8, 2013 at 7:47 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Thank you so much, Jorge and Arun - I'll give it a try! Dimitri On Fri, Jun 7, 2013 at 11:27 PM, arun

Re: [R] splitting a string column into multiple columns faster

2013-06-08 Thread arun
Hi Dimitri, No problem. I noticed that it is slower with more number of rows.  You could use data.table(). ##1e6 rows l1- letters[1:10] s1-sapply(seq_along(l1),function(i) paste(rep(l1[i],3),collapse=)) set.seed(24)

[R] get column index with match using apply

2013-06-08 Thread Camilo Mora
Hi everyone, This is probably something very simple but I have just not been able to figure it out and wonder if perhaps you may know. I want to get the column index in which a given value is found. Values to match are found in the last column of the dataframe. for instance dt= v1 v2

[R] plot Predicted survival probabilitie

2013-06-08 Thread matteo pettinari
Dear I would like to find a nice way to plot the predicted survival obtained from a cph fit and few covariates as Age etc... I am working with predict from rms package but i found a problem after the lines predict(cox5, type=lp, se.fit=FALSE, conf.int=TRUE, conf.type=c('mean')) Error in

[R] Need help on window() function of the 'zoo' package

2013-06-08 Thread Ron Michael
Hi,   I observed that if I use window() function available with the 'zoo' package to extract a portion of my times series and if that time series data is stored in some 'zoo' object with only 1 column, then the resulting zoo object is becoming vector.   Here is my observation:   library(zoo)

[R] help needed! RMSE

2013-06-08 Thread mansor nad
i need HELPPP!! how do i calculate the RMSE value for two GEV models?first GEV is where the three parameters are constant.2nd GEV model a 4 parameter model with the location parameter is allowed to vary linearly with respect to time while holding the other parameters at constant. is there any

[R] colour coded dotchart

2013-06-08 Thread Marco Bianchi
Dear R-Users, I have a vector x - 1:10 and I would like to produce a dotchart where the colour of the dot is black if x = 5 and red otherwise. If I use x - 1:10 dotchart(x, col=black) then all dots are obviously of black colour. Has anybody in the mailing list already dealt with a similar task

[R] Error Object Not Found

2013-06-08 Thread Court
Hello, I am having difficulty with a command. An error message pops up saying: Error: object 'RWGJ.wload' not found. I have installed the packages needed to run the analysis, and have saved them to my working directory. -- View this message in context:

[R] R-help: insufficient space problem occurred during inversion of sparse matrix

2013-06-08 Thread luyongfa
Hi everyone, I have one problem with sparse matrix(package SparseM). I tried to inverse a sparse matrix with solve function in SparseM package. But I got warning:Error in .local(x, ...) : insufficient space. p=solve(coeff,tmpmax=120*nrow(coeff)) Error in .local(x, ...) : insufficient

[R] CGIwithR installation failure

2013-06-08 Thread rex
Hello, CGIwithR apparently is not available on CRAN for R 2.15.x, so I downloaded the source (0.73) and tried: ~/Downloads$ R CMD INSTALL CGIwithR * installing to library ‘/home/rex/R/x86_64-pc-linux-gnu-library/2.15’ * installing *source* package ‘CGIwithR’ ... configure: creating

Re: [R] Subset dataframe with loop searching for unique values in two columns

2013-06-08 Thread arun
Hi, You could try this: dat2- read.table(text='  case pin some_data  A  1 data  A  2 data  A  1 data  A  2 data  B  1 data  B  2 data ',sep=,header=TRUE,stringsAsFactors=FALSE)  dat2[!duplicated(dat2[,1:2]),] #  case pin some_data #1    A   1  data #2    A   2  data #5    B   1 

[R] segfault -- address 0x29, cause 'memory not mapped'

2013-06-08 Thread mathias kuhnt
Dear List, after a night of calculating, R says goodbye with a segmentation fault. *** caught segfault *** address 0x29, cause 'memory not mapped' In my functions I subsequently read in network files of about 20KB using the IGraph package. Admittedly, I read in about 1 million files, in total

Re: [R] colour coded dotchart

2013-06-08 Thread Rolf Turner
On 09/06/13 01:21, Marco Bianchi wrote: Dear R-Users, I have a vector x - 1:10 and I would like to produce a dotchart where the colour of the dot is black if x = 5 and red otherwise. If I use x - 1:10 dotchart(x, col=black) then all dots are obviously of black colour. Has anybody in the

Re: [R] get column index with match using apply

2013-06-08 Thread arun
Hi, dat1$colIndex-apply(dat1,1,function(x) match(max(x),x))  dat1 #  v1 v2 v3 v4 max colIndex #1  0  0  1  2   2    4 #2  0  1  2  0   2    3 #3  1  2  3  4   4    4 A.K. - Original Message - From: Camilo Mora cm...@dal.ca To: r-help@r-project.org Cc: Sent: Saturday, June

Re: [R] plot Predicted survival probabilitie

2013-06-08 Thread David Winsemius
On Jun 8, 2013, at 4:58 AM, matteo pettinari wrote: Dear I would like to find a nice way to plot the predicted survival obtained from a cph fit and few covariates as Age etc... I am working with predict from rms package but i found a problem after the lines predict(cox5, type=lp,