Re: [R] sapply returning list instead of matrix

2014-02-02 Thread chris warth
Can I follow-up with what I've learned about my own myopia regarding sapply()? First, I appreciate all the feedback. After thinking about it for a while I realized R designers have often chosen to accommodate interactive usage, and in that context, sapply() returning different types makes perfe

Re: [R] Control over character height, width, skew etc.?

2014-02-02 Thread YRichard
Hi Iakub,Do you mind sharing a concrete example of your approach (from R to your script and back to R)? There is a growing demand to produce R plots for government reports that ideally wouldn't require the intervention of a designer to control the typography. While I'm getting a good grip at produc

Re: [R] datetime and date

2014-02-02 Thread Yolande Tra
Thank you Jeff. I had to go back to excel and format the column from there. Thank you everyone, Yolande On Sun, Feb 2, 2014 at 9:51 PM, Yolande Tra wrote: > Hi Jim, > > I got an error > > df$Date2<- > + as.POSIXct(as.character(df$Date1, format = "%m/%d/%Y %H:%M:%S")) > Error in as.POSIXlt.ch

Re: [R] Capturing output of a C executable

2014-02-02 Thread jim holtman
?sink Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sun, Feb 2, 2014 at 8:09 PM, Dennis Fisher wrote: > R 3.0.1 > OS X > > Colleagues, > > I am experimenting with incorporating C code into R. After com

Re: [R] datetime and date

2014-02-02 Thread Yolande Tra
Hi Jim, I got an error > df$Date2<- + as.POSIXct(as.character(df$Date1, format = "%m/%d/%Y %H:%M:%S")) Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format On Sun, Feb 2, 2014 at 9:08 PM, Jim Lemon wrote: > On 02/03/2014 12:53 PM, Yolande T

Re: [R] Capturing output of a C executable

2014-02-02 Thread Jeff Newmiller
You really need to read the "Writing R Extensions" document. It warns you against performing I/O from C code linked to R. You probably ought to read the Posting Guide, also, since this question is off topic here --- Jeff Ne

Re: [R] datetime and date

2014-02-02 Thread Jeff Newmiller
Please read the Posting Guide, which warns you to (among other things) post in plain text and provide a reproducible example. Read ?strptime. Note that you must provide a format that matches the data you parse with it. If you have both formats because you are also using Excel, you can fix the

Re: [R] datetime and date

2014-02-02 Thread Jim Lemon
On 02/03/2014 01:08 PM, Jim Lemon wrote: On 02/03/2014 12:53 PM, Yolande Tra wrote: Hi, I have the following issue. The dataframe df has a column (Date1) supposed to be a date but read as a factor. There are two types of values in the same column Date1 Type 1 are datetime like "5/23/2008 0:00:0

Re: [R] datetime and date

2014-02-02 Thread Jim Lemon
On 02/03/2014 12:53 PM, Yolande Tra wrote: Hi, I have the following issue. The dataframe df has a column (Date1) supposed to be a date but read as a factor. There are two types of values in the same column Date1 Type 1 are datetime like "5/23/2008 0:00:00" Type 2 have no time like "1/10/13". W

[R] datetime and date

2014-02-02 Thread Yolande Tra
Hi, I have the following issue. The dataframe df has a column (Date1) supposed to be a date but read as a factor. There are two types of values in the same column Date1 Type 1 are datetime like "5/23/2008 0:00:00" Type 2 have no time like "1/10/13". When I apply the following to the date column

[R] Capturing output of a C executable

2014-02-02 Thread Dennis Fisher
R 3.0.1 OS X Colleagues, I am experimenting with incorporating C code into R. After compiling the C code with: R CMD SHLIB -o FILE.so FILE.c and executing: dyn.load(“FILE.so”) (without any errors), I execute the following R functions in a terminal window: READSAS

Re: [R] [as.numeric]Convert Category data to Numeric Data

2014-02-02 Thread arun
Hi, as.numeric(iris$Species) iris1 <- within(iris,Species <-as.numeric(Species)) A.K. I have a small question for converting the category data to numeric data. For example, if we use the iris data in r. we have: str(iris) 'data.frame': 150 obs. of  5 variables:  $ Sepal.Length: num  5.1

Re: [R] Plotting multiple time series with variables having different units

2014-02-02 Thread Rolf Turner
Perhaps I misunderstood your question. Jeff Newmiller says that you did not want multiple y-scales on the same plot, which is how I read what you wrote. If you just want plots of X vs. time, Y vs. time, etc. "stacked" one above the other then you perhaps should simple use par(mfrow(.,.)) or

Re: [R] Lapply to create sub categories based on categorical data

2014-02-02 Thread arun
Hi, Try: x <- c(rep("A",0.1*1),rep("B",0.2*1),rep("C",0.65*1),rep("D",0.05*1)) set.seed(24) categorical_data <- sample(x,1) set.seed(49) p_val <- runif(1,0,1) combi <- data.frame(V1=categorical_data,V2=p_val) variables <- unique(combi$V1)  res <- lapply(levels(variables)

Re: [R] package mgcv - predict with bam: Error in X[ind, ] : subscript out of bounds

2014-02-02 Thread David Winsemius
On Feb 2, 2014, at 9:52 AM, Katharina May wrote: > Hi Simon, > > thank you for your reply, I really appreciate any help to understand > the problem here... > Unluckily the package upgrade didn't help with this issue. > An example reproducing the error, and a current sessionInfo() Output > can be

Re: [R] Plotting multiple time series with variables having different units

2014-02-02 Thread Jim Lemon
On 02/03/2014 06:09 AM, David Parkhurst wrote: I've tried to figure out how to do this from what I read, but haven't been successful. Suppose I have a dataframe with variables Date, X, and Y (and maybe U, V, and Z) where X, Y, etc. have different units. I'd like to plot Y vs. Time above X vs. Tim

[R] creating an equivalent of r-help on r.stackexchange.com ? (was: Re: Should there be an R-beginners list?)

2014-02-02 Thread Liviu Andronic
Dear Duncan, I discovered something interesting wrt to the licensing and mirroring of user-contributed material on StackExchange. Please read below. On Sun, Nov 24, 2013 at 9:00 PM, Duncan Murdoch wrote: >> I'm not aware of a discussion on this, but I would say no. >> Fragmentation is bad. Furt

Re: [R] Plotting multiple time series with variables having different units

2014-02-02 Thread Gabor Grothendieck
On Sun, Feb 2, 2014 at 2:09 PM, David Parkhurst wrote: > I've tried to figure out how to do this from what I read, but haven't been > successful. Suppose I have a dataframe with variables Date, X, and Y (and > maybe U, V, and Z) where X, Y, etc. have different units. I'd like to plot > Y vs. Tim

Re: [R] Plotting multiple time series with variables having different units

2014-02-02 Thread Jeff Newmiller
He did not ask for dual axis graphs, Rolf. This can be done with lattice graphics and also with ggplot. See, for example, [1] or [2]. The melt function is a very powerful tool for preparing for this task. [1] http://www.fromthebottomoftheheap.net/2013/10/23/time-series-plots-with-lattice-and-g

Re: [R] Plotting multiple time series with variables having different units

2014-02-02 Thread Rolf Turner
Just ***DON'T***!!! Very bad idea; usually wildly misleading. See, e.g.: http://www.perceptualedge.com/articles/visual_business_intelligence/dual-scaled_axes.pdf OTOH if you're going to be bloody-minded and do it anyway, there are brazillions of hits from a Google search which will tell you h

Re: [R] Plotting multiple time series with variables having different units

2014-02-02 Thread Bert Gunter
If I understand you correctly, there are so many ways to do this (ggplot2, lattice, base graphics with multiple graphs per page via ?layout,...) that I am puzzled as to how you failed to find what you needed. Exactly what was it that you read that left you unable to do this? Perhaps some additional

Re: [R] aggregate()?

2014-02-02 Thread arun
Probably, you are referring to: d <- as.data.frame(cbind(Stock, Soil, Nitrogen, Respiration))### with(d,aggregate(cbind(Nitrogenr=Nitrogen,Respirationr=Respiration),by=list(Soilr=Soil,Stockr=Stock),FUN=mean)) I used: d <- data.frame(Stock, Soil, Nitrogen, Respiration) with(d,aggregate(cbind(Nitro

[R] Plotting multiple time series with variables having different units

2014-02-02 Thread David Parkhurst
I've tried to figure out how to do this from what I read, but haven't been successful. Suppose I have a dataframe with variables Date, X, and Y (and maybe U, V, and Z) where X, Y, etc. have different units. I'd like to plot Y vs. Time above X vs. Time, above one another. For example, X is th

Re: [R] aggregate()?

2014-02-02 Thread David Winsemius
On Feb 2, 2014, at 8:43 AM, arun wrote: > Also, > > > with(d,aggregate(cbind(Nitrogenr=Nitrogen,Respirationr=Respiration),by=list(Soilr=Soil,Stockr=Stock),FUN=mean)) > Did you compare your output to the input? -- David. > A.K. > > On Sunday, February 2, 2014 7:58 AM, Rui Barradas > wrot

Re: [R] meta data on infert data set

2014-02-02 Thread David Winsemius
On Feb 2, 2014, at 12:20 AM, Aziz, Muhammad Fayez wrote: > Thank you folks. Actually I did lookup all these resources you mentioned but > couldn't find a word for word meta data. In fact the data set is a bit > different from what's in the appendix of the paper. Also the meaning of these > te

Re: [R] package mgcv - predict with bam: Error in X[ind, ] : subscript out of bounds

2014-02-02 Thread Katharina May
Hi Simon, thank you for your reply, I really appreciate any help to understand the problem here... Unluckily the package upgrade didn't help with this issue. An example reproducing the error, and a current sessionInfo() Output can be found below. Many thanks once again, Katharina R Code

Re: [R] aggregate()?

2014-02-02 Thread arun
Also,   with(d,aggregate(cbind(Nitrogenr=Nitrogen,Respirationr=Respiration),by=list(Soilr=Soil,Stockr=Stock),FUN=mean)) A.K. On Sunday, February 2, 2014 7:58 AM, Rui Barradas wrote: Hello, First of all avoid as.data.frame(cbind(...)). cbind() returns a matrix and since you are mixing numbers

[R] R question

2014-02-02 Thread dvf208
I have generated a L1 penalized Cox model using the penalized package in R. I used the optL1() function to generate the Breslow object (see below): fit <- optL1(surv.obj, penalized = ..., etc) In the reference manual, it says the fit$predictions are the cross-validated predictions for the left

Re: [R] (no subject)

2014-02-02 Thread John Kane
Not enough information. Have a look at these links for some suggestions on how to ask a question on R-help. John Kane Kingston ON Canada > -Original Message- > From: azadbiost...@gmail.com > Sent: Sat, 1 Feb 2014 18:37:00 -0800 > To: r-help@r-project.org > Subject: [R] (no subject) >

Re: [R] aggregate()?

2014-02-02 Thread John Kane
Not exactly the order you specified but otherwise I think this works. library(plyr) d <- data.frame(Stock, Soil, Nitrogen, Respiration) ddply(d, .(Soil, Stock), summarize, mean(Nitrogen), mean(Respiration)) John Kane Kingston ON Canada > -Original Message- > From: aguitatie...@hotmail.c

Re: [R] aggregate()?

2014-02-02 Thread Rui Barradas
Hello, First of all avoid as.data.frame(cbind(...)). cbind() returns a matrix and since you are mixing numbers with characters, all of the matrix elements become character. Then as.data.frame transforms everything into factors. The correct way is d <- data.frame(Stock, Soil, Nitrogen, Respir

Re: [R] CCA no scores for some constraining variables

2014-02-02 Thread Wolf, Steven
This seems like the ideal case for a MWE. If we can't reproduce your error, we can't help diagnose it! Steve --- Steven Wolf Research Associate CREATE for STEM Institute Michigan State University > On Feb 1, 2014, at 6:44 AM, "Paresys, Lise" wrote: > > Dear all, > > I am performing a CCA us

[R] aggregate()?

2014-02-02 Thread Beatriz R. Gonzalez Dominguez
Hi all, I'm trying to compute a mean on my data but I'm struggling with 2 things: 1. getting the right layout and 2. including the missing values in the outcome. #Input data: Stock <- c("A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B") Soil <- c("Blank", "Blank", "Control", "Control

Re: [R] (no subject)

2014-02-02 Thread Barry Rowlingson
On Sun, Feb 2, 2014 at 6:46 AM, Rolf Turner wrote: > On 02/02/14 15:37, mohammad javad Azadchehr wrote: >> Hi >> I want R code for bayesian CIF competing risks. >> best regards > > I want wealth, wisdom, good looks, and to play full forward for the > Sydney Swans. One out of four isn't bad. To

Re: [R] meta data on infert data set

2014-02-02 Thread Aziz, Muhammad Fayez
Thank you folks. Actually I did lookup all these resources you mentioned but couldn't find a word for word meta data. In fact the data set is a bit different from what's in the appendix of the paper. Also the meaning of these terms seems to be specific to the study than following the dictionary