Re: [R] read.fortran format

2016-05-27 Thread Jeff Newmiller
Your rather sarcastic comment about knowledge given by John's mother seems inappropriate, given that he told you where his information came from and it is the first place you should have looked. The bit about the decimal leading to a shift in the decimal place pointed out by Bill is a bit obsc

Re: [R] read.fortran format

2016-05-27 Thread Steven Yen
That's great, John. Your mother told you when you were born? How am I supposed to know? Thank you both. The following format statement did it!! I just change F5.3 to F5, 5F8.4 to 5F8. I also change 2E15.9 to 2A9, and then use the following as.numeric to convert the alphanumerical to numerical. T

Re: [R] Dynamically populate a vector by iteratively applying a function to its previous element.

2016-05-27 Thread Jeff Newmiller
You have set yourself an impossible goal. Either you can reformulate your problem as non-iterative and can process your data as arrays, or you have to use some kind of for loop. The lapply and Vectorize functions are popular "pretty" ways to do this, but they amount to hidden for loops. Note t

[R] Dynamically populate a vector by iteratively applying a function to its previous element.

2016-05-27 Thread Matteo Richiardi
I want to dynamically populate a vector by iteratively applying a function to its previous element, without using a 'for' cycle. My solution, based on a question I posted some times ago for a more complicated problem (see "updating elements of a list of matrixes without 'for' cycles") was to define

[R] Application of "merge" and "within"

2016-05-27 Thread Santosh
Dear Rxperts! Is there a way to compute relative values.. using within().. function? Any assistance/suggestions are highly welcome!! Thanks again, Santosh... ___ A sample dataset and the computation "outside" within() function is sh

Re: [R] read.fortran format

2016-05-27 Thread William Dunlap via R-help
It has been a while since I used Fortran formatted input, but the following, without dots in the format, works: > txt <- "1950. .614350 .026834 .087227 .006821 .180001 4.56E-2" > print(read.fortran(textConnection(txt), c("f5", "6f8")), digits=10) V1 V2 V3 V4 V5 V6

Re: [R] read.fortran format

2016-05-27 Thread Steven Yen
Thanks John. That helped, but I got a mixed of good thing and bad thing. Good is R does not like the scientific number format "3E15.9" but I was able to read with alphanumerical format "3A15" (and convert to numerical). Bad is R does not like the numbers .1234, .2345 without the zeros before th

Re: [R] [FORGED] couldn't install pcalg package in R 3.1.3

2016-05-27 Thread Rolf Turner
On 28/05/16 06:08, Lida Zeighami wrote: Hi Dears! Would you please let me know how I can install package pcalg for R version 3.1.3 ? I've tried different ways but got error! Thanks inadvance! An answer the helpfulness of which is commensurate with the clarity of your question: Do it correc

Re: [R] mixed models

2016-05-27 Thread James Henson
Greetings David, I am new to R and neglected to check vigorously for missing values. Apologize for posting without checking and finding the one NA. I appreciate your help. Thanks. James F. Henson On Fri, May 27, 2016 at 1:49 PM, David Winsemius wrote: > >> On May 27, 2016, at 10:07 AM, James Hen

Re: [R] couldn't install pcalg package in R 3.1.3

2016-05-27 Thread Jeff Newmiller
Use reply-all to keep the list in the loop. I happen to have this old version of R still around on Windows 7 and it installs just fine for me. You may be able to get it to install by choosing a different CRAN mirror, but I still recommend that you upgrade R and try with that before posting ag

Re: [R] Quantmod - modify decimal places

2016-05-27 Thread David Menezes
Hi Josh Thanks a lot - appreciate the answer. Figured it may have worked that way but investigating the url called by the package was a smart move. Guess I'll need to get the info from Bloomberg! Thanks again David Sent from my iPhone > On 27 May 2016, at 9:52 PM, Joshua Ulrich wrote: > >

Re: [R] mixed models

2016-05-27 Thread David Winsemius
> On May 27, 2016, at 10:07 AM, James Henson wrote: > > Greetings Jeff, > You are correct that the unequal number of levels is not the problem. > I revised the data frame so that the number of levels was equal and > the same error message occurred. The code is below, and the > Eboni2.txt file i

Re: [R] couldn't install pcalg package in R 3.1.3

2016-05-27 Thread Jeff Newmiller
If you read the Posting Guide it warns you against posting in HTML (it doesn't say why but basically what you think you sent is not necessarily what we saw). It also mentions that you should update to the latest version of R (yours is not) if you want help (though we might try anyway). It also m

Re: [R] read.fortran format

2016-05-27 Thread John McKown
On Fri, May 27, 2016 at 12:56 PM, Steven Yen wrote: > Dear fellow R users: > I am reading a data (ascii) file with fortran fixed format, containing > multiple records. R does not recognize fortran's record break (a slash). > I tried to do the following but it does not work. Help appreciated. > >

[R] couldn't install pcalg package in R 3.1.3

2016-05-27 Thread Lida Zeighami
Hi Dears! Would you please let me know how I can install package pcalg for R version 3.1.3 ? I've tried different ways but got error! Thanks inadvance! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE

[R] Trimming time series to only include complete years

2016-05-27 Thread Morway, Eric
In bulk processing streamflow data available from an online database, I'm wanting to trim the beginning and end of the time series so that daily data associated with incomplete "water years" (defined as extending from Oct 1st to the following September 30th) is trimmed off the beginning and end of

[R] read.fortran format

2016-05-27 Thread Steven Yen
Dear fellow R users: I am reading a data (ascii) file with fortran fixed format, containing multiple records. R does not recognize fortran's record break (a slash). I tried to do the following but it does not work. Help appreciated. 60 FORMAT(1X,F6.0,5F8.6/1X,5F8.4,F10.6/1X,2F6.0,3E15.9,F8.0,F

Re: [R] mixed models

2016-05-27 Thread James Henson
Greetings Jeff, You are correct that the unequal number of levels is not the problem. I revised the data frame so that the number of levels was equal and the same error message occurred. The code is below, and the Eboni2.txt file is attached. This problem baffles me. I appreciate any help. Best r

Re: [R] Fitting quantile (or cdf?) function to data with specified percentiles

2016-05-27 Thread Vito Michele Rosario Muggeo
A possible (simple) solution is to use a binomial GLM which guarantees fitted values (percentiles) in (0,1): plot(percentile, score) o<-glm(percentile~sc, family=binomial) points(fitted(o), sc, col=2) You can "predict" percentiles given score via predict.glm() best, vito Franco Danilo Roca L

Re: [R] subset data right

2016-05-27 Thread William Dunlap via R-help
>If you want to drop levels, use droplevels() either on the factor or on the >subset of your data frame. Example: >droplevels(f[1]) #One element, only one level Calling factor() on a factor, as the OP did, also drops any unused levels, as the examples showed. > str(factor(factor(letters)[11:13]))

Re: [R] How to replace all commas with semicolon in a string

2016-05-27 Thread Ulrik Stervbo
If your data.frame is a mix you can loop over each column - along the lines of: library(plyr) adply(test, 2, function(x){ if(!is.numeric(x[[1]]){ gsub(",", ";", x[[1]]) }else{ x[[1]] } }) Ulrik On Fri, 27 May 2016 at 17:21 Jun Shen wrote: > Thanks Ulrik and Bob for your reply. > > gsub worked

Re: [R] How to replace all commas with semicolon in a string

2016-05-27 Thread David L Carlson
> sapply(test, gsub, pattern=",", replacement=";") C1C2 "a;b;c;d" "g;h;f" - David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-projec

Re: [R] How to replace all commas with semicolon in a string

2016-05-27 Thread Jun Shen
Thanks Ulrik and Bob for your reply. gsub worked for one column! If I want to replace the whole data frame, gsub doesn't seem to work. Any idea On Fri, May 27, 2016 at 11:14 AM, Ulrik Stervbo wrote: > use gsub() > > On Fri, 27 May 2016 at 17:12 Jun Shen wrote: > >> Dear list, >> >> Say I have

Re: [R] How to replace all commas with semicolon in a string

2016-05-27 Thread Ulrik Stervbo
use gsub() On Fri, 27 May 2016 at 17:12 Jun Shen wrote: > Dear list, > > Say I have a data frame > > test <- data.frame(C1=c('a,b,c,d'),C2=c('g,h,f')) > > I want to replace the commas with semicolons > > sub(',',';',test$C1) -> test$C1 will only replace the first comma of a > string. > > How do

Re: [R] How to replace all commas with semicolon in a string

2016-05-27 Thread boB Rudis
You can use gsub() instead of sub() On Fri, May 27, 2016 at 11:10 AM, Jun Shen wrote: > Dear list, > > Say I have a data frame > > test <- data.frame(C1=c('a,b,c,d'),C2=c('g,h,f')) > > I want to replace the commas with semicolons > > sub(',',';',test$C1) -> test$C1 will only replace the first com

[R] How to replace all commas with semicolon in a string

2016-05-27 Thread Jun Shen
Dear list, Say I have a data frame test <- data.frame(C1=c('a,b,c,d'),C2=c('g,h,f')) I want to replace the commas with semicolons sub(',',';',test$C1) -> test$C1 will only replace the first comma of a string. How do I replace them all in one run? Thanks. Jun [[alternative HTML versio

Re: [R] add value to Bar chart ggplot2

2016-05-27 Thread Ulrik Stervbo
Hi Elahe, Based on this and your other questions I think you could benefit from spending time with tutorials on ggplot and on R in general. Google should give you plenty and I quickly found this: http://www.ats.ucla.edu/stat/r/ and this: https://www.nceas.ucsb.edu/files/scicomp/Dloads/RProgrammin

Re: [R] add value to Bar chart ggplot2

2016-05-27 Thread Jeff Newmiller
I think you need to read those questions again more carefully... particularly the second one. -- Sent from my phone. Please excuse my brevity. On May 27, 2016 7:41:25 AM PDT, "ch.elahe via R-help" wrote: >Thanks Ulrik, >But in these examples they want to mark the percentage or frequency of >p

Re: [R] add value to Bar chart ggplot2

2016-05-27 Thread ch.elahe via R-help
Thanks Ulrik, But in these examples they want to mark the percentage or frequency of plot variables, in my case I want to mark the bars with a different variable of my df. DO you have any idea? On Friday, May 27, 2016 3:22 PM, Ulrik Stervbo wrote: Hi Elahe, maybe this will help: http://s

Re: [R] Getting Rid of NaN in ts Object

2016-05-27 Thread PIKAL Petr
Hm > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jim Lemon > Sent: Friday, May 27, 2016 12:46 PM > To: Lorenzo Isella > Cc: r-help@r-project.org > Subject: Re: [R] Getting Rid of NaN in ts Object > > Hi Lorenzo, > Maybe: > > tt<-tt[!is.nan(tt)] Th

[R] Fitting quantile (or cdf?) function to data with specified percentiles

2016-05-27 Thread Franco Danilo Roca Landaveri
Hello, I hope you can help me. In class, we were given an Excel worksheet with specified formulas that take the total score from a survey (or from a specific section) and convert it to a percentage, according to a table that assigns scores to a percentile. Since the formulas are too long and co

[R] Sample selection using multiple logit or similar

2016-05-27 Thread Andrew Perrin
Greetings- I am seeking to fit a model using Heckman-style selection; however the wrinkle is that the selection is into multiple categories, not a binary in/out. In this case, selection is into the type of higher-education institution a student attended; the goal is to estimate post-graduation

Re: [R] Quantmod - modify decimal places

2016-05-27 Thread Joshua Ulrich
On Mon, May 23, 2016 at 8:57 PM, David Menezes wrote: > Hi > > Apologies if this has already been asked and answered or if I've labelled > the subject incorrectly but I can't find a solution using the search > function for this group; the vignette documentation for quantmod or general > google sea

Re: [R] add value to Bar chart ggplot2

2016-05-27 Thread Ulrik Stervbo
Hi Elahe, maybe this will help: http://stackoverflow.com/questions/6455088/how-to-put-labels-over-geom-bar-in-r-with-ggplot2 or this: http://stackoverflow.com/questions/12018499/how-to-put-labels-over-geom-bar-for-each-bar-in-r-with-ggplot2 Best, Ulrik On Fri, 27 May 2016 at 15:12 ch.elahe via R

[R] add value to Bar chart ggplot2

2016-05-27 Thread ch.elahe via R-help
Hi all , I have the following bar chart and I want to add SLC variable values to the charts but I don't know how to use geom_text: ggplot(df,(Protocol,fill=quant))+geom_bar()+coord_flip() Thanks for any help! Elahe __ R-help@r-project.org mai

[R] Package index.html pages in repository

2016-05-27 Thread Holger Hoefling
Hi, I am hosting a small repository (of partly non-public repositories) and was wondering if it is possible to create the package-index page on CRAN (e.g. here for drat https://cran.rstudio.com/web/packages/drat/drat.pdf) automatically somehow out of an existing repo (i.e. create the package from

Re: [R] Getting Rid of NaN in ts Object

2016-05-27 Thread Lorenzo Isella
Perfect! Exactly what I was looking for. Thanks Lorenzo On Fri, May 27, 2016 at 01:50:03PM +0200, Christian Brandstätter wrote: Hi Lorenzo, Try: tt[is.nan(tt)] <- NA tt <- na.omit(tt) Best, Christian Am 27.05.2016 um 13:38 schrieb Lorenzo Isella: On Fri, May 27, 2016 at 08:46:20PM +1000,

Re: [R] Getting Rid of NaN in ts Object

2016-05-27 Thread Christian Brandstätter
Hi Lorenzo, Try: tt[is.nan(tt)] <- NA tt <- na.omit(tt) Best, Christian Am 27.05.2016 um 13:38 schrieb Lorenzo Isella: On Fri, May 27, 2016 at 08:46:20PM +1000, Jim Lemon wrote: Hi Lorenzo, Maybe: tt<-tt[!is.nan(tt)] Jim Not really. tt<-structure(c(NaN, NaN, NaN, NaN, NaN, NaN, NaN,

Re: [R] Getting Rid of NaN in ts Object

2016-05-27 Thread Lorenzo Isella
On Fri, May 27, 2016 at 08:46:20PM +1000, Jim Lemon wrote: Hi Lorenzo, Maybe: tt<-tt[!is.nan(tt)] Jim Not really. tt<-structure(c(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, + NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 1133.09, 1155.77, 1179.12, + 1182.85, 1133.43, 1103.36, 1081.19, 10

Re: [R] Getting Rid of NaN in ts Object

2016-05-27 Thread Jim Lemon
Hi Lorenzo, Maybe: tt<-tt[!is.nan(tt)] Jim On Fri, May 27, 2016 at 8:14 PM, Lorenzo Isella wrote: > Dear All, > I am sure the answer is a one liner, but I am banging my head against > the wall and googling here and there has not helped much. > Consider the following time series > > tt<-structu

Re: [R] subset data right

2016-05-27 Thread S Ellison
> You did not change df$quant - you made a new object called 'subdf' > containing a column called 'quant' that had only one level. Changing subdf > has > no effect on df. Also, subsetting a factor _intentionally_ does not change the number of levels. Example: f <- factor(sample(letters[1:3], 30

Re: [R] Match Coordinates to NUTS 2 ID

2016-05-27 Thread Miluji Sb
Thank you for your reply. I am trying to use the over function - but having trouble. Asked at R-sig-geo. Thanks again! Sincerely, Milu On Fri, May 27, 2016 at 12:49 AM, MacQueen, Don wrote: > Perhaps the > over() > function in the sp package. > > (in which case, R-sig-geo might be a better p

[R] Getting Rid of NaN in ts Object

2016-05-27 Thread Lorenzo Isella
Dear All, I am sure the answer is a one liner, but I am banging my head against the wall and googling here and there has not helped much. Consider the following time series tt<-structure(c(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 1133.09, 1155.77,