Re: [R] Skip error in downloading file in loop

2017-10-21 Thread Jeff Newmiller
One of the recommendations in the Posting Guide is to read the archives before 
posting... even following along with recent posts would have pointed out the 
existence of the tryCatch function. 

?tryCatch
-- 
Sent from my phone. Please excuse my brevity.

On October 21, 2017 8:01:02 AM PDT, Miluji Sb  wrote:
>I am trying to download data from NASA web-service.
>
>I am using the following code;
>
>for( i in 1:8) {
>  target1 <- paste0("
>https://hydro1.gesdisc.eosdis.nasa.gov/daac-bin/access/timeseries.cgi?variable=NLDAS:NLDAS_FORA0125_H.002:TMP2m&location=GEOM:POINT(
>",
>cities[i, "lon_nldas"],
>",%20", cities[i,"lat_nldas"],
>
>")&startDate=1980-01-01T00&endDate=2016-12-31T23&type=asc2")
>  target2 <- paste0("/Users/dasgupta/Dropbox (FEEM)/Flu Paper/climate
>data/temperature/nldas/",# change for whatever destination
>directory
>you may prefer.
>cities[i,"city"], "_",
>cities[i,"state"], ".csv")
>  download.file(url=target1, destfile=target2,  method = "libcurl")
>}
>
>Any time the coordinates provided is out data coverage, the loop fails
>and
>stops. Is there any way to force R to skip the error and continue with
>the
>rest of the download?
>
>My data looks like this:
>
>dput(droplevels(head(cities, 8)))
>structure(list(city = structure(1:8, .Label = c("Boston", "Bridgeport",
>"Cambridge", "Fall River", "Hartford", "Lowell", "Lynn", "New Bedford"
>), class = "factor"), state = structure(c(2L, 1L, 2L, 2L, 1L,
>2L, 2L, 2L), .Label = c(" CT ", " MA "), class = "factor"), lon_nldas =
>c(-71.05673836,
>-73.19126922, -71.1060061, -71.14364822, -72.67401574, -71.31283992,
>-70.82521832, -70.80586599), lat_nldas = c(42.35866236, 41.18188268,
>42.36679363, 41.69735342, 41.76349276, 42.64588413, 42.46370197,
>41.63767375)), .Names = c("city", "state", "lon_nldas", "lat_nldas"
>), row.names = c(NA, 8L), class = "data.frame")
>
>Any help will be appreciated. Thank you very much!
>
>Sincerely,
>
>Milu
>
>   [[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-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] Problem when trying to run Java in R:

2017-10-22 Thread Jeff Newmiller
I suggest asking a Mac-OS-specific question like this on the r-sig-mac mailing 
list. A common problem is attempting to access a 64-bit implementation of Java 
from a 32-bit version of R, or vice versa, but you may want to include the 
output of sessionInfo() and a reproducible example (both input and output) when 
you ask your question again to help them help you. 
-- 
Sent from my phone. Please excuse my brevity.

On October 21, 2017 4:35:19 AM PDT, Morkus via R-help  
wrote:
>Hello All,
>
>Although running Java from R used to work, for some mysterious reason,
>it's stopped.
>
>Today when I tried to load a basic JDBC driver (or the sample .jinit())
>code, I got:
>
>- JavaVM: requested Java version ((null)) not available. Using Java at
>"" instead.
>
>- JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib
>
>- JavaVM FATAL: Failed to load the jvm library.
>
>I saw postings on StackOverflow about this issue, but none of the
>suggested fixes helped.
>
>I'm on Mac OS 10.13.
>
>My JAVA_HOME is:
>/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
>
>java -version
>java version "1.8.0_144"
>Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
>Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
>
>I'm using R: 3.3.3
>
>Here is sample code that also throws this same error:
>
>library(rJava)
>.jinit() # this starts the JVM
>s <- .jnew("java/lang/String", "Hello World!")
>
>(this is the "hello world" equivalent from the rJava site)
>
>
>
>I also tried to use Java 7 (rev. 51), which used to work, but that
>still fails.
>
>Also tried a fresh install of R/RStudio on another machine with the
>same results (same Java version, etc., however).
>
>I suspect Java itself is working fine since JDBC code from Java
>programs has no issues.
>
>Not sure why loading Java in R stopped working, but would appreciate
>any suggestions.
>
>Thanks very much,
>
>Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted
>email.
>   [[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-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] How to define proper breaks in RFM analysis

2017-10-23 Thread Jeff Newmiller
Using quantiles does not imply assumption of normality, unless you drag that 
assumption in separately. Please go review statistics again, offlist, and come 
back when you need help with R.
-- 
Sent from my phone. Please excuse my brevity.

On October 22, 2017 10:02:57 PM PDT, Hemant Sain  wrote:
>hello,
>I'm confused what you guys are talking about.
>i just want to set ideal threshold values for my RFM scores which can
>be
>done using Quantiles but i don't want to use quantiles because my data
>is
>not normally distributed so it will lead to wrong ranges of breaks. to
>fix
>this problem I'm looking for an approach which can define the ideal
>range
>to breaks to categorize RFM scores into 3 segments.
>that's all i want.
>THanks
>
>
>On 14 October 2017 at 04:24, Jim Lemon  wrote:
>
>> Hemant's problem is that the indicators are not distributed
>uniformly.
>> With a uniform distribution, categorization gives a reasonably
>optimal
>> separation of cases. One approach would be to drop categorization and
>> calculate the overall score as the mean of the standardized indicator
>> scores. Whether this is an option I do not know. I did offer an
>> "eyeball" set of breaks in a previous email, but apparently this was
>> not sufficient.
>>
>> Jim
>>
>> On Sat, Oct 14, 2017 at 4:27 AM, David Winsemius
>
>> wrote:
>> >
>> >> On Oct 13, 2017, at 2:51 AM, PIKAL Petr 
>wrote:
>> >>
>> >> Hi
>> >>
>> >> You expect us to solve your problem but you ignore advice already
>> recieved.
>> >>
>> >> Your data are unreadable, use dput(yourdata) instead. see ?dput
>> >>
>> >>> test<-read.table("clipboard", heade=T)
>> >> Error in scan(file = file, what = what, sep = sep, quote = quote,
>dec =
>> dec,  :
>> >>  line 115 did not have 6 elements
>> >
>> > I didn't have such a problem: (illustrated with a more minimal
>example)
>> >
>> > dat <-  scan( what=list("",1,"",1L,1L,1),
>> >  text="194849 6.99 8/22/2017 9 5 9.996
>> > 194978 14.78 8/28/2017 3 15 16.308
>> > 198614 18.44 7/31/2017 31 1 18.44
>> > 234569 34.99 8/20/2017 11 8 13.5075
>> > 252686 7.99 7/31/2017 31 2 7.99
>> > 291719 21.26 8/25/2017 6 2 15.67
>> > 291787 46.1 8/31/2017 0 2 32.57
>> > 292630 24.34 7/31/2017 31 1 24.34
>> > 295204 21.86 7/18/2017 44 1 21.86
>> > 295989 8.98 8/20/2017 11 2 14.095
>> > 298883 14.38 8/24/2017 7 2 11.185
>> > 308824 10.77 7/31/2017 31 1 10.77")
>> >
>> > names(dat) <- c("user_id", "subtotal_amount", "created_at",
>"Recency",
>> "Frequency", "Monetary")
>> > dat <- data.frame(dat,stringsAsFactors=FALSE)
>> >
>> > I suspect read.table would also have worked for me, but I was
>expecting
>> difficulties based on Petr's posting.
>> >
>> >
>> > #And ended up with this result (on the original copied data):
>> >> str(dat)
>> > 'data.frame':   500 obs. of  6 variables:
>> >  $ user_id: chr  "194849" "194978" "198614" "234569" ...
>> >  $ subtotal_amount: num  6.99 14.78 18.44 34.99 7.99 ...
>> >  $ created_at : chr  "8/22/2017" "8/28/2017" "7/31/2017"
>"8/20/2017"
>> ...
>> >  $ Recency: int  9 3 31 11 31 6 0 31 44 11 ...
>> >  $ Frequency  : int  5 15 1 8 2 2 2 1 1 2 ...
>> >  $ Monetary   : num  10 16.31 18.44 13.51 7.99 ...
>> >
>> > ...  but the following criticism seems, well, _critical_ (as in
>> essential for one to address if a reasonable proposal is to be
>offered.)
>> >
>> >
>> >> What is „ideal interval“ can you define it? Should it be such to
>> provide eqal number of observations?
>> >
>> > That is the crucial question for you to answer, Hemant. Read the
>> ?quartile help page if your answer is "yes" or even "maybe".
>> >>
>> >> Or maybe you could normalise your values and use quartile method.
>> >
>> > Well, maybe not so much on that last one, Petr. Normalization
>should not
>> affect the classification based on quartiles. It doesn't change the
>> ordering of variables.
>> >
>> > --
>> > David.
>> >
>> >>
>> >> Cheers
>> >> Petr
>> >>
>> >> From: Hemant Sain [mailto:hemantsai...@gmail.com]
>> >> Sent: Friday, October 13, 2017 8:51 AM
>> >> To: PIKAL Petr 
>> >> Cc: r-help mailing list 
>> >> Subject: Re: [R] How to define proper breaks in RFM analysis
>> >>
>> >> Hey,
>> >> i want to define 3 ideal breaks (bin) for each variable one of
>those
>> variables is attached in the previous email,
>> >> i don't want to consider quartile method because quartile is not
>> working ideally for that data set because data distribution is non
>normal.
>> >> so i want you to suggest another method so that i can define 3
>breaks
>> with the ideal interval for Recency, frequency and monetary to
>calculate
>> RFM score.
>> >> i'm again attaching you some of the data set.
>> >> please look into it and help me with the R code.
>> >> Thanks
>> >>
>> >>
>> >>
>> >> Data
>> >>
>> >> user_id
>> >>
>> >> subtotal_amount
>> >>
>> >> created_at
>> >>
>> >> Recency
>> >>
>> >> Frequency
>> >>
>> >> Monetary
>> >>
>> >> 194849
>> >>
>> >> 6.99
>> >>
>> >> 8/22/2017
>> >>
>> > snipped
>> >
>> >>
>> >>
>> >> On 13 October 20

Re: [R] How to save and restore a workspace

2017-10-23 Thread Jeff Newmiller
To be specific, the effect of loading packages with the "library" function is 
NOT saved when you save the workspace... and if you come back much later after 
you have updated some packages the old saved objects may not work well with 
those new packages. At the very least you have to re-load all necessary 
packages yourself before you load a saved workspace. Many users avoid ever 
using the "save workspace" option because it can cause old mistakes to come 
back and haunt you later. 

This kind of issue has lead me to become quite systematic about writing R files 
(as Jim suggested below) that re-do all of my work on a given task (omitting 
the false starts needed to learn things) on each of my projects starting from a 
blank workspace. It may seem like a tedious approach to the beginner, but it is 
actually very comforting to know that I can look through every step and verify 
that it did what I wanted it to, without wondering how some particular 
intermediate result was computed six months ago and saved for later use. If one 
step is particularly slow, I may comment out (our put an "if" around) the 
statements that originally created and saved that object with saveRDS, and load 
it instead of recomputing it once I trust it. But the key is to always focus on 
building sequences of R statements, and later on building functions rather than 
poking and prodding a workspace like it was a spreadsheet. 
-- 
Sent from my phone. Please excuse my brevity.

On October 23, 2017 3:45:29 PM PDT, Jim Lemon  wrote:
>Hi Jon,
>Saving your workspace doesn't mean that everything will be rerun when
>you start a new R session. I just means that persistent objects like
>data frames will be there. If you type:
>
>objects()
>
>you will see all of those things that were there when you ended in the
>last session. Things like commands will be in the "history", so you
>can retrieve them just as you did at the end of the last session (up
>arrow). It may be a better solution if you save sequences of commands
>as R script files (e.g. "something.R") as you can run them:
>
>source("something.R")
>
>and edit and save them again.
>
>Jim
>
>On Tue, Oct 24, 2017 at 9:12 AM,   wrote:
>> Hello,
>> I recently downloaded R in hopes of learning to use it for
>statistics.
>> I have promptly run into a problem, as I am unable to save, and later
>recover, a workspace so I can resume work where I left off.
>> I am using Windows.
>> I indicate "yes" to the pop up after q().  Then when I later reopen R
>Console and click on File, I cannot get my prior workspace to appear in
>the R Console frame so I can resume work.
>> In the File drop down menu I have tried Load Workspace, Load History,
>Display file(s)..., opened R Type: R Workspace with no luck.
>> I have read about this in two different books, the R Manual, and R
>FAQs, used the RGui help function, and still cannot do it.
>> I have used Windows for years, but I am ignorant about programming.
>> Would appreciate any help you might offer.
>> I live in the Denver area, so if there are any local resources you
>could direct me to, I would be grateful for that as well.
>>
>> Thank you,
>> Jon VanDeventer
>>
>> Sent from my iPad
>> __
>> 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-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-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] read.table(..., header == FALSE, colClasses = )

2017-10-23 Thread Jeff Newmiller
You are constructing the equivalent of a two-line data file, and complaining 
that it is not treating it like it was one line. If it did used to accept this 
silently [skeptical] then I for one am glad it produces a warning now. 
-- 
Sent from my phone. Please excuse my brevity.

On October 23, 2017 2:53:21 PM PDT, Benjamin Tyner  wrote:
>Hello
>
>I noticed that starting with R version 3.3.0 onward, this generates a 
>warning:
>
>    > txt <- c("a", "3.14")
>   > read.table(file = textConnection(txt), header = FALSE, colClasses 
>= c(x = "character", y = "numeric"))
>
>the warning is "not all columns named in 'colClasses' exist" and I
>guess 
>the change was made in response to this?
>
>    https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=16478
>
>Regardless, I am wondering whether this is desirable, that as a result 
>of the change, the code has become stricter about the presence of a 
>(formerly) harmless names attribute. Or am I missing something?
>
>Regards
>
>Ben
>
>__
>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-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] Creating a data table (frame?) from a SQL Statement?

2017-10-24 Thread Jeff Newmiller
Your question desperately needs a reproducible example (a.k.a. "reprex"), 
because you have to be using contributed packages to do any of this. You also 
need to clarify whether you are intending to access data already in an external 
database, or are planning to load it using R and manipulate it with SQL.

I suggest that you install the "reprex" and "sqldf" packages and read their 
documentation and try out their examples. Then when you ask a question use 
reprex to be sure we see all the steps needed to get to where you are stuck. In 
particular we need the library calls that preceeded your sample code, but the 
reprex package will verify that you have it all there before you send the 
question. 

FWIW, note that the data function has a specific purpose of pulling data sets 
by name out of packages into your workspace, and giving it the output of 
randomly selected functions is not likely to work. Start reading help files 
soon... they may seem dense at first but the only way to get past that is to 
get started soon. Type

?data

at the console to start learning about that function.

Note that csv files are outside the world of standard SQL, so some of what you 
are doing may be very tightly linked with the particular SQL engine you are 
using.
-- 
Sent from my phone. Please excuse my brevity.

On October 24, 2017 7:01:36 AM PDT, Morkus via R-help  
wrote:
>Hello,
>
>I'm new to R so this is probably a simple question for somebody.
>
>I have an RScript that reads a CSV on the disk using read.table(...).
>It then does a boxM test using that data.
>
>However, I'm now trying to load the same data via an SQL command, but I
>can't seem to get the data structure defined so R will like it -- using
>the included "iris" dataset.
>
>I've tried these ways of loading the SQL statement into a compatible R
>Structure:
>
>irisQuery <- data(dbGetQuery(conn, "select * from iris"))
>
>irisQuery <- data.frame(dbGetQuery(conn, "select * from iris"))
>
>irisQuery <- table(dbGetQuery(conn, "select * from iris"))
>
>.
>.
>.
>Followed by:
>
>boxM(irisQuery[,-5], irisQuery[,5])
>
>Nothing works work.
>
>For example, if i use ...
>
>irisQuery <- data.frame(dbGetQuery(conn, "select * from iris"))
>
>I get this error from R on the boxM test:  Error: is.numeric(x) ||
>is.logical(x) is not TRUE
>
>The SQL Statement is returning results, but their not CSV. Not sure if
>that matters.
>---
>
>So, how do I read a SQL statement into an R structure like I read the
>CSV using "read.table" so the boxM test will work?
>
>Thanks very much in advance.
>
>- M
>
>Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted
>email.
>   [[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-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] Creating a data table (frame?) from a SQL Statement?

2017-10-24 Thread Jeff Newmiller
Please always cc the list... the group usually has better answers than any one 
person, and I don't do private consulting on the net. For future reference, 
there is also an r-sig-db mailing list where this question really belongs. 

Since I almost never use jdbc, I would need a reprex (hint you are ignoring my 
advice... a good way to get ignored), which this still isn't. There is probably 
enough here for someone more familiar than I to help you with. I for one find 
it hard to understand why read.table is successfully figuring out how to make 
sense of the presumably-valid data frame that dbGetQuery is returning. That is, 
you really don't need to send everything through read.table in order to make 
use of it. Maybe try

irisDF <- dbGetQuery(conn, "select * from iris")

str( irisDF )

-- 
Sent from my phone. Please excuse my brevity.

On October 24, 2017 10:11:28 AM PDT, Morkus  wrote:
>Jeff,
>
>Excellent points, thank you!
>
>Yes, I have all the required packages installed.
>
>Below's the actual full script.
>
>require(Rserve)
>require(biotools)
>library(rJava)
>library(RJDBC)
>drv <- JDBC("com.mysql.jdbc.Driver","/Users/.../mysql.jar")
>conn <- dbConnect(drv, "jdbc:mysql://localhost:3306/morkus","root",
>"password")
>dbListTables(conn) 
>   // works!
>count <- dbGetQuery(conn,"select count(*) from iris")//
>works!
>irisQuery <- read.table(dbGetQuery(conn, "select * from iris")) works!
>irisQuery  
>  // displays table from iris dataset I imported into MySQL
>boxM(irisQuery[,-5], irisQuery[,5])
> / />>>  FAILS! <<< "Error: is.numeric(x) || is.logical(x) is not TRUE"
>dbDisconnect(conn) 
>// displays TRUE.
>
>
>
>Few rows of displayed data in R Console from line above: "irisQuery"
>
>   Sepal.Length Sepal.Width Petal.Length Petal.WidthSpecies
>15.1 3.5  1.4 0.2 setosa
>24.9   3  1.4 0.2 setosa
>34.7 3.2  1.3 0.2 setosa
>44.6 3.1  1.5 0.2 setosa
>5  5 3.6  1.4 0.2 setosa
>65.4 3.9  1.7 0.4 setosa
>74.6 3.4  1.4 0.3 setosa
>.
>.
>.
>---
>
>Now, if I do the boxM statistic reading a CSV file from disk, like
>this:
>
>irisQuery = read.table('/Users/.../iris.csv', sep=',', header=FALSE,
>stringsAsFactor=FALSE)
>
>Then everything works!  (But I'm not reading files from a CSV on the
>disk; rather, from SQL as above.)
>
>---
>
>So my problem is that I can't seem to package the SQL Result (shown
>above) so that it works like the read.table. I'm missing some R
>function to transform the SQL to a "table" R can work with.
>
>Does that help fill in the missing pieces?
>
>Sorry my first posting wasn't this complete.
>
>Thanks again in advance,
>
>- M
>
>Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted
>email.
>
>>  Original Message 
>> Subject: Re: [R] Creating a data table (frame?) from a SQL Statement?
>> Local Time: October 24, 2017 12:40 PM
>> UTC Time: October 24, 2017 4:40 PM
>> From: jdnew...@dcn.davis.ca.us
>> To: Morkus , r-help@r-project.org
>
>>
>> Your question desperately needs a reproducible example (a.k.a.
>"reprex"), because you have to be using contributed packages to do any
>of this. You also need to clarify whether you are intending to access
>data already in an external database, or are planning to load it using
>R and manipulate it with SQL.
>>
>> I suggest that you install the "reprex" and "sqldf" packages and read
>their documentation and try out their examples. Then when you ask a
>question use reprex to be sure we see all the steps needed to get to
>where you are stuck. In particular we need the library calls that
>preceeded your sample code, but the reprex package will verify that you
>have it all there before you send the question.
>>
>> FWIW, note that the data function has a specific purpose of pulling
>data sets by name out of packages into your workspace, and giving it
>the output of randomly selected functions is not likely to work. Start
>reading help files soon... they may seem dense at first but the only
>way to get past that is to get started soon. Type
>>
>> ?data
>>
>> at the console to start learning about that function.
>>
>> Note that csv files are outside the world of standard SQL, so some of
>what you are doing may be very tightly linked with the particular SQL
>engine you are using.
>>
>> Sent from my phone. Please excuse my brevity.
>>
>> On October 24, 2017 7:01:36 AM PDT, Morkus via R-help
>r-help@r-project.org wrote:
>>
>>> Hello,
>>> I'm new to R so this is probably a simple question for somebody.
>>> I have an 

Re: [R] Help needed with aggregate or other solution

2017-10-25 Thread Jeff Newmiller
-03-22 12:00:00", "2012-03-22 18:00:00",
"2012-03-23 00:00:00", "2012-03-23 06:00:00", "2012-03-23 12:00:00",
"2012-03-23 18:00:00", "2012-03-24 00:00:00", "2012-03-24 06:00:00",
"2012-03-24 12:00:00", "2012-03-24 18:00:00", "2012-03-25 00:00:00",
"2012-03-25 06:00:00", "2012-03-25 12:00:00", "2012-03-25 18:00:00",
"2012-03-26 00:00:00", "2012-03-26 06:00:00", "2012-03-26 12:00:00",
"2012-03-26 18:00:00", "2012-03-27 00:00:00", "2012-03-27 06:00:00",
"2012-03-27 12:00:00", "2012-03-27 18:00:00", "2012-03-28 00:00:00",
"2012-03-28 06:00:00", "2012-03-28 12:00:00", "2012-03-28 18:00:00",
"2012-03-29 00:00:00", "2012-03-29 06:00:00", "2012-03-29 12:00:00",
"2012-03-29 18:00:00", "2012-03-30 00:00:00", "2012-03-30 06:00:00",
"2012-03-30 12:00:00", "2012-03-30 18:00:00", "2012-03-31 00:00:00",
"2012-03-31 06:00:00", "2012-03-31 12:00:00", "2012-03-31 18:00:00",
"2012-04-01 00:00:00", "2012-04-01 06:00:00", "2012-04-01 12:00:00",
"2012-04-01 18:00:00", "2012-04-02 00:00:00", "2012-04-02 06:00:00",
"2012-04-02 12:00:00", "2012-04-02 18:00:00", "2012-04-03 00:00:00",
"2012-04-03 06:00:00", "2012-04-03 12:00:00", "2012-04-03 18:00:00",
"2012-04-04 00:00:00", "2012-04-04 06:00:00", "2012-04-04 12:00:00",
"2012-04-04 18:00:00", "2012-04-05 00:00:00", "2012-04-05 06:00:00",
"2012-04-05 12:00:00", "2012-04-05 18:00:00", "2012-04-06 00:00:00",
"2012-04-06 06:00:00", "2012-04-06 12:00:00", "2012-04-06 18:00:00",
"2012-04-07 00:00:00", "2012-04-07 06:00:00", "2012-04-07 12:00:00",
"2012-04-07 18:00:00", "2012-04-08 00:00:00", "2012-04-08 06:00:00",
"2012-04-08 12:00:00", "2012-04-08 18:00:00", "2012-04-09 00:00:00",
"2012-04-09 06:00:00", "2012-04-09 12:00:00", "2012-04-09 18:00:00",
"2012-04-10 00:00:00", "2012-04-10 06:00:00", "2012-04-10 12:00:00",
"2012-04-10 18:00:00", "2012-04-11 00:00:00", "2012-04-11 06:00:00",
"2012-04-11 12:00:00", "2012-04-11 18:00:00", "2012-04-12 00:00:00",
"2012-04-12 06:00:00", "2012-04-12 12:00:00", "2012-04-12 18:00:00",
"2012-04-13 00:00:00", "2012-04-13 06:00:00", "2012-04-13 12:00:00",
"2012-04-13 18:00:00", "2012-04-14 00:00:00", "2012-04-14 06:00:00",
"2012-04-14 12:00:00", "2012-04-14 18:00:00", "2012-04-15 00:00:00",
"2012-04-15 06:00:00", "2012-04-15 12:00:00", "2012-04-15 18:00:00",
"2012-04-16 00:00:00", "2012-04-16 06:00:00", "2012-04-16 12:00:00",
"2012-04-16 18:00:00", "2012-04-17 00:00:00", "2012-04-17 06:00:00",
"2012-04-17 12:00:00", "2012-04-17 18:00:00", "2012-04-18 00:00:00",
"2012-04-18 06:00:00", "2012-04-18 12:00:00", "2012-04-18 18:00:00",
"2012-04-19 00:00:00", "2012-04-19 06:00:00", "2012-04-19 12:00:00",
"2012-04-19 18:00:00", "2012-04-20 00:00:00", "2012-04-20 06:00:00",
"2012-04-20 12:00:00", "2012-04-20 18:00:00", "2012-04-21 00:00:00",
"2012-04-21 06:00:00", "2012-04-21 12:00:00", "2012-04-21 18:00:00",
"2012-04-22 00:00:00

Re: [R] Help needed with aggregate or other solution

2017-10-26 Thread Jeff Newmiller

On Thu, 26 Oct 2017, Thomas Adams wrote:


Hi Jeff,

Thank you for the suggestions -- I appreciate your help. Unfortunately, the
result2 has two problems...

(1) there are now 3 date columns (it looks like 2 cols are merged into 1
col)


No, there are two date columns. Result2 includes the grouping value as a 
row name (pulled from the names of the dta2list items by rbind).



(2) the output rows should not have any of the basistime dates repeated
(maybe I misstated the problem); I need the max fcst value by basistime, but
also list the date value for that row; for example:


Then try out my code replacing

dta2list <- split( dta2, dta2$date )

with

dta2list <- split( dta2, dta2$basistime )

and

%>% group_by( date )

with

%>% group_by( basistime )

Please study how the code works and ask questions based on gaps in that 
knowledge rather than how the results are not what you expected. This 
mailing list is not a do-your-work-for-you coding service. Some help pages 
you should look at include:


?rownames
?split
?lapply
?do.call
?rbind
?group_by
?do

You might also find [1] helpful in general, and [2] helpful for 
understanding dplyr.


[1] H. Wickham, The Split-Apply-Combine Strategy for Data Analysis, 
Journal of Statistical Software, vol. 40, no. 1, Apr. 2011.


[2] H. Wickham and G. Grolemund, R for Data Science. OReilly UK Ltd, 2017. 
URL: https://r4ds.had.co.nz.




 basistime fcst
1   2012-01-25 15:02:00 47.9
2   2012-01-26 15:11:00 50.4
3   2012-01-27 01:41:00 46.0
4   2012-01-27 10:15:00 47.3
5   2012-01-27 15:15:00 47.3
6   2012-01-28 14:22:00 46.2
7   2012-01-29 13:33:00 45.8
8   2012-01-30 14:11:00 44.8
9   2012-01-31 14:24:00 43.9
10  2012-02-01 14:55:00 41.1
11  2012-02-02 14:56:00 38.1
12  2012-02-03 14:40:00 36.2
13  2012-02-04 15:01:00 34.7
14  2012-02-05 15:04:00 33.1
15  2012-02-06 14:37:00 32.2

This is very close to what I need. The basistime dates are all unique, with
the max fcst value for the available basistime dates; but I additionally
need the corresponding 'date' value.

Best,
Tom



On Thu, Oct 26, 2017 at 1:28 AM, Jeff Newmiller 
wrote:
  Thanks for the dput...

   reproducible example of split-apply-combine ###

  dta <- structure(list(date = structure(c(1L, 2L, 3L, 4L, 5L, 6L,
  7L,
  8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
  5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
  19L, 20L, 21L, 22L, 23L, 24L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
  14L, 15L, 16L), .Label = c("2012-01-25 18:00:00", "2012-01-26
  00:00:00",
  "2012-01-26 06:00:00", "2012-01-26 12:00:00", "2012-01-26
  18:00:00",
  "2012-01-27 00:00:00", "2012-01-27 06:00:00", "2012-01-27
  12:00:00",
  "2012-01-27 18:00:00", "2012-01-28 00:00:00", "2012-01-28
  06:00:00",
  "2012-01-28 12:00:00", "2012-01-28 18:00:00", "2012-01-29
  00:00:00",
  "2012-01-29 06:00:00", "2012-01-29 12:00:00", "2012-01-29
  18:00:00",
  "2012-01-30 00:00:00", "2012-01-30 06:00:00", "2012-01-30
  12:00:00",
  "2012-01-30 18:00:00", "2012-01-31 00:00:00", "2012-01-31
  06:00:00",
  "2012-01-31 12:00:00", "2012-01-31 13:00:00", "2012-01-31
  18:00:00",
  "2012-02-01 00:00:00", "2012-02-01 06:00:00", "2012-02-01
  12:00:00",
  "2012-02-01 18:00:00", "2012-02-02 00:00:00", "2012-02-02
  06:00:00",
  "2012-02-02 12:00:00", "2012-02-02 18:00:00", "2012-02-03
  00:00:00",
  "2012-02-03 06:00:00", "2012-02-03 12:00:00", "2012-02-03
  18:00:00",
  "2012-02-04 00:00:00", "2012-02-04 06:00:00", "2012-02-04
  12:00:00",
  "2012-02-04 18:00:00", "2012-02-05 00:00:00", "2012-02-05
  06:00:00",
  "2012-02-05 12:00:00", "2012-02-05 18:00:00", "2012-02-06
  00:00:00",
  "2012-02-06 06:00:00", "2012-02-06 12:00:00", "2012-02-06
  18:00:00",
  "2012-02-07 00:00:00", "2012-02-07 06:00:00", "2012-02-07
  12:00:00",
  "2012-02-07 18:00:00", "2012-02-08 00:00:00", "2012-02-08
  06:00:00",
  "2012-02-08 12:00:00", "2012-02-08 18:00:00", "2012-02-09
  00:00:00",
  "2012-02-09 06:00:00", "2012-02-09 12:00:00", "2012-02-09
  18:00:00",
  "2012-02-10 00:00:00", "2012-02-10 06:00:00", "2012-02-10
  12:00:00",
  "2012-02-10 18:00:00"

Re: [R] run r script in r-fiddle

2017-10-29 Thread Jeff Newmiller
You can't. Use R on your computer instead. 
-- 
Sent from my phone. Please excuse my brevity.

On October 29, 2017 5:56:55 PM PDT, Frank Mei  wrote:
>Hi All,
>
>I want to know how to run an R file on my computer in R-Fiddle?
>
>I tried source("filename.r"), but not working.
>
>thanks,
>Frank
>
>   [[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-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] Pass Parameters to RScript?

2017-10-30 Thread Jeff Newmiller
I do not do this either, and technically this list is not the right place to 
ask this multi-language question, rather apparently [1] is because the 
alternative to using a system call is to use the Rserve service. You should use 
a search engine to look for info on using rjava and rserve.

[1] https://mailman.rz.uni-augsburg.de/pipermail/stats-rosuda-devel/
-- 
Sent from my phone. Please excuse my brevity.

On October 30, 2017 8:33:48 AM PDT, Eric Berger  wrote:
>I do not program in Java but it seems a Java program can make system
>calls
>which would be equivalent to running from the command line, but done
>from
>within a Java program. Not sure whether that would meet your needs and
>if
>not why not. Just a suggestion.
>
>Check out
>
>http://www.java-samples.com/showtutorial.php?tutorialid=8
>
>
>
>On Mon, Oct 30, 2017 at 5:10 PM, Morkus  wrote:
>
>> Thanks Eric,
>>
>> I saw that page, too, but it states:
>>
>> "This post describes how to pass external arguments to *R* when
>calling a
>> Rscript *with a command line.*"
>>
>> Not what I'm trying to do.
>>
>> Thanks for your reply.
>>
>> Sent from ProtonMail , Swiss-based encrypted
>> email.
>>
>>
>>  Original Message 
>> Subject: Re: [R] Pass Parameters to RScript?
>> Local Time: October 30, 2017 9:39 AM
>> UTC Time: October 30, 2017 1:39 PM
>> From: ericjber...@gmail.com
>> To: Morkus 
>> r-help@r-project.org 
>>
>> I did a simple search and got  hits immediately, e.g.
>> https://www.r-bloggers.com/passing-arguments-to-an-r-
>> script-from-command-lines/
>>
>>
>> On Mon, Oct 30, 2017 at 2:30 PM, Morkus via R-help
>
>> wrote:
>>
>>> Is it possible to pass parameters to an R Script, say, from Java or
>other
>>> language?
>>>
>>> I did some searches, but came up blank.
>>>
>>> Thanks very much in advance,
>>>
>>> Sent from [ProtonMail](https://protonmail.com), Swiss-based
>encrypted
>>> email.
>>> [[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/posti
>>> ng-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-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] error to run this package

2017-10-31 Thread Jeff Newmiller
Please read the Posting Guide mentioned at the bottom of this and every message 
on this list. Things like the following you should consider:

What did you do between the time you started R and this error occurred? There 
is a presumption that we can reproduce your actions and perhaps get the same 
result.

What is the output of sessionInfo() just before this error occurs?

Send your email in plain text, since html gets mangled frequently before we see 
your message. 
-- 
Sent from my phone. Please excuse my brevity.

On October 31, 2017 5:41:36 AM PDT, Anima Pramanik  
wrote:
>Error: package or namespace load failed for ‘car’ in get(Info[i, 1],
>envir
>= env):
> cannot allocate memory block of size 2.5 Gb
>
>
>please help me to get a solution of this problem
>
>   [[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-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] error to run this package

2017-10-31 Thread Jeff Newmiller
Cc'ing back to the list... ALWAYS reply-to-all to keep the list included... I 
don't know all the answers and I don't reply to every request since this is 
volunteer time on my part.

That error does not occur when I load that package. Please re-read my previous 
recommendations and follow all of them... maybe someone else will notice 
something.
-- 
Sent from my phone. Please excuse my brevity.

On October 31, 2017 9:01:51 AM PDT, Anima Pramanik  
wrote:
>library("car", lib.loc="~/R/win-library/3.4")
>Error: package or namespace load failed for ‘car’ in get(Info[i, 1],
>envir
>= env):
> cannot allocate memory block of size 2.5 Gb
>
>On Tue, Oct 31, 2017 at 8:50 PM, Jeff Newmiller
>
>wrote:
>
>> Please read the Posting Guide mentioned at the bottom of this and
>every
>> message on this list. Things like the following you should consider:
>>
>> What did you do between the time you started R and this error
>occurred?
>> There is a presumption that we can reproduce your actions and perhaps
>get
>> the same result.
>>
>> What is the output of sessionInfo() just before this error occurs?
>>
>> Send your email in plain text, since html gets mangled frequently
>before
>> we see your message.
>> --
>> Sent from my phone. Please excuse my brevity.
>>
>> On October 31, 2017 5:41:36 AM PDT, Anima Pramanik
>
>> wrote:
>> >Error: package or namespace load failed for ‘car’ in get(Info[i, 1],
>> >envir
>> >= env):
>> > cannot allocate memory block of size 2.5 Gb
>> >
>> >
>> >please help me to get a solution of this problem
>> >
>> >   [[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-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] Help with Nesting

2017-10-31 Thread Jeff Newmiller
R does not look inside strings for language objects like your symbol variable. 
Nor does it magically figure out that it needs to keep previous values in a 
loop. And you need to be able to use valid syntax to ask clear questions in 
this list, so some more time with a tutorial should occur before you post again.

Perhaps:

result <- lapply( symbol, function(s) {
   Quandl( paste0( "LLL/", s ) )
}
result
-- 
Sent from my phone. Please excuse my brevity.

On October 31, 2017 12:00:41 PM PDT, Edward Guda via R-help 
 wrote:
>How do i resolve this?
>
>symbol <-  c('RRR' ,'GGG')
>
>for(i in seq_along(symbol)) {
>  dat <- Quandl("LLL/symbol[i]")
>  
>}
> 
>required solutionis a loop where Quandl is a function and it loops as
>flows,
>Quandl("LLL/RRR")
>Quandl("LLL/GGG")
>
>__
>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-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] Data invisible to read.csv

2017-11-01 Thread Jeff Newmiller
You are using terms and concepts that apply to spreadsheets, but do not apply 
to R or CSV files. Please conform to the Posting Guide and make a reproducible 
example [1][2][3] using R code to demonstrate your problem. I suspect you will 
find that your problem begins in your spreadsheet and not in R or the CSV file, 
but if not then the example will help us help you. 

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette)

-- 
Sent from my phone. Please excuse my brevity.

On November 1, 2017 7:30:03 AM PDT, WRAY NICHOLAS via R-help 
 wrote:
>Hello   This relates to trying to upload csv files to R.  Essentially I
>have
>some v large csv files, but in the column where the dates are appears
>the column
>entry "00:00.0" for every line.  But in the formula bar appears a date
>as well,
>for example "01/04/09 00:00.0", and this never appears in the main body
>of the
>document
>
>It's the dates I need but they seem to be invisible to the read.csv
>function by
>which I'm uploading - that works, but simply gives "00:00.0" and not
>the date
>bit.  I've never seen this before.  Does anyone know what's going on
>and how I
>can get to the date string?
>
>Thanks, Nick Wray
>   [[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-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] R-3.4.2: make check stops at line 698 of tests/reg-tests-1d.R

2017-11-01 Thread Jeff Newmiller
This idea of hijacking failed connections has been tried before and it breaks 
many things beyond R software and most ISPs have given up on doing this. If 
you, who have this "feature" at hand can figure out a reliable way to detect 
this then it might be "considered". However, it seems unlikely that a general 
solution can be found after all this time, so the better option is probably for 
you to disable this "feature".
-- 
Sent from my phone. Please excuse my brevity.

On November 1, 2017 1:52:16 PM PDT, Albrecht Kauffmann  
wrote:
>Dear Duncan,
>
>thank you very much, that is it! Indeed, there was activated in my
>internet router the "telekom navigation help". When I am (or the system
>is) looking for an not existent url, this "help" opens its own website.
>After deactivation of telekom navigation help, the normal message
>(server not found) comes. I never gave attention to this "help",
>although it is bothering sometimes; now it is switched off in my
>residence. However, in Germany this problem probably frequently arises,
>therefor, it should be considered in the respective code for testing R
>after compilation.  
>
>All the best,
>Albrecht

__
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] R

2017-11-04 Thread Jeff Newmiller
Sorry, but there are restrictions on mailing list attachments (read the Posting 
Guide) and your attachments did not get through. 

However, even if they had come through, we would need you to describe the 
sequence of actions you took, because computers in general respond to your 
actions, and most of the key responses R provides are text messages in response 
to your text commands. Screen shots are a poor way to communicate these 
exchanges.  Try reading [1][2][3] for help on how to do this clearly. 

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette) 
-- 
Sent from my phone. Please excuse my brevity.

On November 4, 2017 4:45:27 AM PDT, sarah roche  wrote:
>To whom it may concern,
>
>
>I cannot seem to load the data no matter what package I download I was
>wondering if you could please look at my screen shots and if you could
>suggest what I could do to fix it please. Thank you very much for your
>time.
>
>
>Kind regards,
>
>Sarah
>__
>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-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] Multiple CSV files in different sheets of an Excel file

2017-11-06 Thread Jeff Newmiller
You need to be more specific about what you mean by "merge" (read e.g. ?merge 
and ?rbind) and show what you did already using a reproducible example 
[1][2][3].

The fact that you mentioned sheets suggests you are writing to Excel files... 
they can be troublesome for storing data (NA values,  size, unstructured 
layout, you can Google for more reasons) so unless you specifically have a 
requirement to interface with Excel you might consider CSV, zip, feather, or 
hdf5.

If you have Java installed, the openxlsx package can be used to write a list of 
data frames in one statement. If you use lapply with read.csv to read the data 
in then this could be fairly compact, depending on what you mean by "merge".

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette)

-- 
Sent from my phone. Please excuse my brevity.

On November 6, 2017 12:23:49 AM PST, Kamlesh Khollam 
 wrote:
>Hi Team,
>I am tried "WriteXLS" package for merging 2 csv files. R script runs
>successfully but does not create CSVmerge file.
>
>Appreciate our help.
>
>​Best Regards,
>Kamlesh Khollam​
>
>   [[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-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] For each entry type in column?

2017-11-06 Thread Jeff Newmiller
All data frames "look like" matrices, but none of them "are" matrices. I think 
we need you to follow the Posting Guide and supply an R reproducible example 
that gives us a concrete idea what the data structure is that you are working 
with, and an example of what you expect to get out of the code you want us to 
show you.  The dput function can be a lifesaver in helping you provide R code 
that can reproduce in our R sessions the data you have in front of you. Read 
more in [1][2] and [3].

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette)
-- 
Sent from my phone. Please excuse my brevity.

On November 6, 2017 9:40:23 AM PST, mviljamaa  wrote:
>How can I do a for loop that does to a data.frame column what:
>
>for x in xs:
>
>does in Python?
>
>Obviously the data.frame column in question holds "levels". What if the
>
>data.frame is in matrix form?
>
>BR, Matti
>
>__
>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-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] For each entry type in column?

2017-11-06 Thread Jeff Newmiller
Maybe you are thinking of the levels function rather than the names function? 
Which still presumes the column is a factor column, when it might actually be a 
character column (in which case you might use the unique function). Again, a 
reproducible example would stop the guessing. 
-- 
Sent from my phone. Please excuse my brevity.

On November 6, 2017 11:26:24 AM PST, Matti Viljamaa  wrote:
>It’s sometimes faster to ask from someone who has already learnt the
>syntax.
>In this case one has to do e.g.
>
>names(data$somecol)
>
>To get the collection and then iteration through it is almost like in
>Python:
>
>for(i in names(data$somecol)) {
>   # do something
>}
>
>> Bert Gunter  kirjoitti 6.11.2017 kello 19.55:
>> 
>> Time to go through a tutorial or two! -- This forum cannot replace
>such self study.
>> 
>> Your query evidences some basic confusion, but ?tapply or the
>equivalent lapply(split(...)) construct are most likely relevant.
>> 
>> Cheers,
>> Bert
>> 
>> 
>> 
>> Bert Gunter
>> 
>> "The trouble with having an open mind is that people keep coming
>along and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>> 
>> On Mon, Nov 6, 2017 at 9:40 AM, mviljamaa > wrote:
>> How can I do a for loop that does to a data.frame column what:
>> 
>> for x in xs:
>> 
>> does in Python?
>> 
>> Obviously the data.frame column in question holds "levels". What if
>the data.frame is in matrix form?
>> 
>> BR, Matti
>> 
>> __
>> 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-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] Pathview xml issue

2017-11-07 Thread Jeff Newmiller
Between the lack of a reproducible example and the question being about a 
Bioconductor package, you probably won't see much response here. Try the 
Bioconductor mailing list? 
-- 
Sent from my phone. Please excuse my brevity.

On November 7, 2017 11:15:51 AM PST, Yin  wrote:
>Hi,
>
>I'm using GAGE/pathview to analyze my RNA-seq and phospho-protein data.
>The
>following error occurs after this command line below:
>
>>pv.out.list <- sapply(path.ids2[1:3], function(pid) pathview(
>gene.data = cnts.d, pathway.id = pid, gene.idtype="SYMBOL",kegg.native
>=
>F,
>same.layer = T, species = "hsa", kegg.dir = "test", out.suffix = "up"))
>
>
>Start tag expected, '<' not found
>Warning: Parsing test/hsa04510.xml file failed, please check the file!
>
>That .xml file is empty, while .png file exists. The issue is there is
>no
>pathway with my data mapped (red and blue nodes). Can you please help
>that?
>
>Thank you!
>Best,
>Shu
>
>   [[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-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] R and LINGO?

2017-11-10 Thread Jeff Newmiller
That is interesting that you are having difficulty. Well, not really... please 
read the Posting Guide:

a) No homework questions. Use the resources offered in your educational 
environment (school, MOOC, etc.).

b) If this is not homework then frame your question with example R code... this 
is a forum about R, not about finance (or other domain-specific concepts). You 
don't have to know the answer to ask it, but you have to show us which R skill 
or function you need help with, using example data and some attempt at a 
solution.

c) LINGO appears to be commercial software that offers an interface for R... 
the use of LINGO is definitely off topic here... we expect to be able to run 
your code examples using R and CRAN resources to be relevant to all R users. 
-- 
Sent from my phone. Please excuse my brevity.

On November 10, 2017 8:04:10 AM PST, "Jan Olsen Røyland" 
 wrote:
>Hei
>Im struggling with this problem:
>b) Another company wants to compose the optimal project portfolio based
>on the following 5-
>year project proposals. In the table, the cash flow for each project in
>each year is shown.
>Project 1 Project 2 Project 3 Project 4 Project 5 Project 6
>1st year of the project -58 -32 -18 -31 -33 -39
>2nd year of the project 17 17 11 4 21 30
>3rd year of the project 26 30 13 19 20 9
>4th year of the project 18 7 4 7 22 13
>5th year of the project 40 6 7 17 6 13
>In this case, the company can also choose which year each project
>should commence. These six
>candidate projects can begin either in 2018, in 2019 or in 2020, or not
>at all.
>The current proposal is to undertake project 1, 2, 3 and 5, with
>project 3 and 5 starting in 2018,
>project 2 in 2019 and project 1 in 2020. Available funds by the end of
>year 2017 will be 70 mill.
>The resulting cash flow is given in the following table:
>Project 1 Project 2 Project 3 Project 5
>Total cash flow
>from projects
>Available
>funds
>2017 70
>2018 -18 -33 -51 19
>2019 -32 11 21 0 19
>2020 -58 17 13 20 -8 11
>2021 17 30 4 22 73 84
>2022 26 7 7 6 46 130
>2023 18 6 24 154
>2024 40 40 194
>Formulate an optimization model in LINGO to determine which projects to
>undertake, and in which
>years. The goal is to maximize available funds by the end of year 2024,
>while making sure that
>available funds are always non-negative throughout the planning
>horizon. How much can the
>improve compared to the current proposal? (For simplicity, assume zero
>discount rate.)
>
>Med Vennelig Hilsen
>Jan Olsen R�yland
>
>
>   [[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] update R version in windows

2017-11-10 Thread Jeff Newmiller
That only works if you use apt-get for all package installs... I don't even 
know if that is possible. Use of install.packages within R works the same on 
all platforms... that is, upgrading R by a minor version (3.3 to 3.4) causes R 
to go looking for user-installed packages in a new library directory, while 
patchlevel upgrades (3.4.1 to 3.4.2) keep using the same library directory 
(read the R Installation and Administration Manual).
-- 
Sent from my phone. Please excuse my brevity.

On November 10, 2017 10:33:49 AM PST, "Bond, Stephen"  
wrote:
>This issue does not exist on Linux. My Ubuntu updates both R and all
>packages.
>
>Stephen B
>
>
>-Original Message-
>From: J C Nash [mailto:profjcn...@gmail.com] 
>Sent: Friday, November 10, 2017 1:19 PM
>To: r-help; RICHARD M. HEIBERGER; Bond, Stephen
>Subject: Re: [R] update R version in windows
>
>However, trying this on Linux Mint gave
>
>  package ‘installr’ is not available (for R version 3.4.2)
>
>Has the package not been updated yet?
>
>
>JN
>
>
>Try the installr package. It was designed for this purpose.
>
>On Fri, Nov 10, 2017 at 11:49 AM, Bond, Stephen cibc.com> wrote:
>> Is there a utility which will allow me to upgrade my R version and
>update all packages from the old version?
>> If I manually upgrade, then I have to manually re-install 50
>packages.
>> Thank you.
>>
>> Stephen B
>>
>>
>__
>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-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] Primer for working with survey data in R

2017-11-11 Thread Jeff Newmiller
You really should have pointed out that you cross-posted this question [1] so 
we wouldn't repeat things. You were already pointed at the task view on this 
subject there. Be sure to look for vignettes in the relevant packages.

I cannot point you to domain-specific examples, though I came across some in 
the brief search I did that lead me to your redundant question, so you probably 
ought to clarify what you have looked at and why it wasn't helpful. 

You mention specifying possible values... I will point out that many people 
turn off the automatic conversion to factor when reading categorical data, 
instead converting those columns to factors explicitly using the factor 
function:

dta$cat1 <- factor( dta$cat1, levels=c( "democrat", "republican", 
"libertarian", "independent", "other" ) )

There is also a package that focuses on factors ("forcats") that may have 
functions in it useful to your work.

I would put actual questions in a separate data frame with the question numbers 
and use the merge function if/when needed... but this is not my usual working 
area... some dedicated packages might put that info into attributes. 

[1] https://stats.stackexchange.com/questions/313220/doing-survey-analysis-in-r
-- 
Sent from my phone. Please excuse my brevity.

On November 11, 2017 11:56:50 AM PST, Kevin Taylor  wrote:
>I am taking a behavioral stats graduate class and the instructor is
>using
>SPSS. I'm trying to follow along in R.
>
>Recently in class we started working with scales and survey data,
>computing
>Cronbach's Alpha, reversing values for reverse coded items, etc.
>
>Also, SPSS has some built in functionality for entering the meta-data
>for
>your survey, e.g. the possible values for items, the text of the
>question,
>etc.
>
>I haven't been able to find any survey guidance for R other than how to
>run
>the actual calculations (Cronbach's, reversing values).
>
>Are there tutorials, books, or other primers, that would guide a newbie
>step by step through using R for working with survey data? It would be
>helpful to see how others are doing these things. (Not just how to run
>the
>mathematical operations but how to work with and manage the data.)
>Possibly
>this would be in conjunction with some packages such as Likert or
>Scales.
>
>TIA.
>
>--Kevin
>
>   [[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-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] create waveform sawtooth

2017-11-12 Thread Jeff Newmiller
Ccing the maintainer if the tuneR package. 

Looks to me like sawtooth (and square) don't behave as expected when using 
xunit="samples". Workaround is to use xunit="time" instead:

sawtooth(110,duration=1/100,samp.rate=sample_rate,xunit="time")

I looked at the code but found it to be opaque.
-- 
Sent from my phone. Please excuse my brevity.

On November 12, 2017 6:15:45 AM PST, Michael Tiemann  
wrote:
>My tuneR sawtooth wave function generator is broken.
>
>When I use the sine function, I get exactly what I expect: a sine wave
>whose frequency is defined by the freq parameter.  In particular,
>higher frequencies have shorter wavelengths (more cycles per second
>means shorter waves).  When I create a sawtooth wave, the opposite
>seems to occur: higher frequencies result in longer waves.  But that’s
>not all: as frequencies increase, it appears that wavelengths increase
>to infinite length, then get shorter again as the wave reverses, then
>it gets longer and flips again.
>
>Here’s a small file that demonstrates the bad sawtooth waves:
>
>library(tuneR)
>
>sample_rate <- 12000
>reverse <- FALSE
>mycolors=c("red","orange","yellow","green","cyan","blue","violet","magenta")
>plot(sawtooth(110,duration=round(sample_rate/100),samp.rate=sample_rate,xunit="samples")@left,type="l")
>freqs <- c(111,112,113,114,115,116,117,118)
>for (i in 1:length(freqs)) {
>temp <-
>sine(freqs[i],duration=round(sample_rate/100),samp.rate=sample_rate,xunit="samples")
>lines(temp@left,type="l",lty=2,col=mycolors[i])
>}
>
>
>
>
>   [[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-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] Convert poly line to polygon in R

2017-11-13 Thread Jeff Newmiller
Might want to post this on R-sig-geo.

Might also want to post in plain text format... see below how your message got 
messed up coming through the mailing list.
-- 
Sent from my phone. Please excuse my brevity.

On November 12, 2017 9:58:56 PM PST, Javad Bayat via R-help 
 wrote:
>I have a shape file as poly line and I want to convert it to polygon.Is
>it possible to do that in R?lake
><-readShapeLines("./lake_main_utm.shp")proj4string(lake) <-
>CRS("+proj=utm +zone=39 +datum=WGS84")
>
>Sincerely.
>
>   [[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-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] Dates to numeric in for loop

2017-11-14 Thread Jeff Newmiller
"Date" means "numeric with an attribute of class='Date' ", so what actually 
happened was that the for loop dropped the class attribute. In most cases using 
the seq_along() function lets you step through index values to extract values 
from your original vectors. In general, any S3 object will behave this way in a 
for loop. 

for ( i in seq_along( dts ) ) {
  print( class( dts[ i ] ) )
}
-- 
Sent from my phone. Please excuse my brevity.

On November 14, 2017 6:15:03 AM PST, Mikkel Grum  wrote:
>Hi
>
>Can anyone explain why a date becomes numeric when you loop over a
>series
>of dates?
>
>> dt <- Sys.Date()
>> dt
>[1] "2017-11-14"
>> class(dt)
>[1] "Date"
>> dts <- dt - 1:0
>> class(dts)
>[1] "Date"
>>
>> for (i in dts) {
>+ print(i)
>+ print(class(i))
>+ print(as.Date(i, "1970-01-01"))
>+ print(class(as.Date(i, "1970-01-01")))
>+ }
>[1] 17483
>[1] "numeric"
>[1] "2017-11-13"
>[1] "Date"
>[1] 17484
>[1] "numeric"
>[1] "2017-11-14"
>[1] "Date"
>
>Why is this apparently not a bug? Are there other types that change
>type
>when looped over?
>
>Kind regards
>Mikkel
>
>
>
>_
>*Mikkel Grum*
>+44 7377337321 (mobile)
>mikkelgrum (Skype)
>
>   [[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-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] R6 object that is a list of referenced object

2017-11-15 Thread Jeff Newmiller

See below.

On Wed, 15 Nov 2017, Cristina Pascual wrote:


Dear community,

I am having a class, let's say Person,

Person <-  R6Class("Person",
public = list(
  idPerson = NULL,
  name = NULL,
  age = NULL,
  initialize = function(idPerson = NA, name = NA, age = NA) 
{


It is a bad idea to setup default values for all your parameters in any 
function, but particularly so for an initialization function. A Person 
with NA in the idPerson field is essentially unusable, so encouraging the 
creation of such an object is very bad practice.



   self$idPerson <- idPerson
   self$name <- name
   self$age <- age
  }
) # public

) # Person

I have created:
Person1 <- Person$new(1,'a',4)
Person2 <- Person$new(2,'b',5)

and I also have a class Community:

Community <- R6Class("Community",
public = list(
  e = NULL,
  initialize = function() self$e <- Person$new()


Initializing a Community with a bogus person is as bad as the idPerson 
being NA. It makes a lot more sense to have the set of persons in a 
community be the null set than to have a minimum of one person in the 
community who happens to have invalid identification.



)
)

I want to create

Community1 = List

and add Person1 and Person2 to Community1 (Community1 <- Community1$add(Person1)
   
Community1 <- Community1$add(Person2)

)

How can I write this with R6? I cannot find the proper example in the website.

Can anybody help me?

Thanks in advance,


You don't seem to be very familiar with either R or conventional 
object-oriented design. Although I am giving you a reprex below, I 
recommend that you avoid R6 until you are more familiar with how normal 
functional programming and S3 object oriented coding styles work in R. 
Using R6 as a crutch to avoid that learning process will only lead you to 
frustration and inefficient data handling. That is, this whole thing 
should just be a data frame.



library(R6)
Person <-  R6Class( "Person"
  , public = list( 
idPerson = NA
 , 
name = NA
 , 
age = NA
 , 
initialize = function( idPerson


 , name

 , age

 ) {

   self$idPerson <- 
idPerson


   self$name <- name

   self$age <- age

 }
 ) # public
  ) # Person

Person1 <- Person$new( 1, 'a', 4 )
Person2 <- Person$new( 2, 'b', 5 )

Community <- R6Class( "Community"
, public = 
list( e = NULL


, addPerson = function( p ) {

   self$e <- append( self$e, p )

  }

)
)

Community1 <- Community$new()
Community1$addPerson( Person1 )
Community1$addPerson( Person2 )
Community1$e
#> [[1]]
#> 
#>   Public:
#> age: 4
#> clone: function (deep = 
FALSE)

#> idPerson: 1
#> initialize: function 
(idPerson, name, age)

#> name: a
#>
#> [[2]]
#> 
#>   Public:
#> age: 5
#> clone: function (deep = 
FALSE)

#> idPerson: 2
#> initialize: function 
(idPerson, name, age)

#> name: b

# Standard R approach:
Person1a <- data.frame( idPerson = 1
  , name = "a"
  , age = 4
  , stringsAsFactors = FALSE
  )
Person2a <- data.frame( idPerson = 2
  , name = "b"
  , age = 5
  , stringsAsFactors = FALSE
  )
Community1a <- rbind( Person1a, Person2a )
Community1a
#>   idPerson name age
#> 11a   4
#> 22b   5






[[alternative HTML version deleted]]


Please POST IN PLAIN TEXT FORMAT. This is a setting you must make in 
your email program, and failure to do so will lead to us seeing different 
things than you send (that is, we see varying degrees of scrambling of 
your message if you send HTML-formatted emails). Read the Posting Guide 
mentioned below for more success tips.




__
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] Risks of using "function <- package::function" ?

2017-11-16 Thread Jeff Newmiller
Obvious?  How about "obscurity"? Just directly use pkg::fun if you have name 
collision. 
-- 
Sent from my phone. Please excuse my brevity.

On November 16, 2017 4:46:15 PM PST, Duncan Murdoch  
wrote:
>On 16/11/2017 4:53 PM, Boris Steipe wrote:
>> Large packages sometimes mask each other's functions and that creates
>a headache, especially for teaching code, since function signatures may
>depend on which order packages were loaded in. One of my students
>proposed using the idiom
>> 
>> <- ::
>> 
>> ... in a preamble, when we use just a small subset of functions from
>a larger package. I like that idea and can't see obvious
>disadvantages(1).
>> 
>> Are there subtle risks to that approach?
>
>You might do it twice.  R isn't going to complain if you have
>
>filter <- stats::filter
>
># some other code here...
>
>filter <- dplyr::filter
>
>in your code, but the second one will overwrite the first one.
>
>The normal way to handle this is in the NAMESPACE file, where you
>should 
>have
>
>importFrom(stats, filter)
>
>If you then have
>
>importFrom(dplyr, filter)
>
>you should get an warning:
>
>Warning: replacing previous import ‘stats::filter’ by ‘dplyr::filter’ 
>when loading ‘testpkg’.
>
>Duncan Murdoch
>
>__
>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-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] RStudio blank upon opening

2017-11-17 Thread Jeff Newmiller
You should ask this in the RStudio support forums.. it is not about R.

I will say anecdotally regarding such behavior that RStudio expects  certain 
directories that it creates to be hidden (e.g. the .Rproj.user directory for 
projects) so if you copied or otherwise messed with those files then this might 
happen.  However,  your description does not mention projects and I don't know 
what other directories or files might lead to such behavior, so do go and ask 
people more likely to know the answer.
-- 
Sent from my phone. Please excuse my brevity.

On November 17, 2017 6:15:56 AM PST, Beginner via R-help  
wrote:
>
>I'm having a problem: RStudio (on   desktop comp) blank upon opening
>(after I update Win7). I tried different things (reinstalled R and
>RStudio, backuping  RStudio settings folder... etc)! C an I launch
>Rstudio direct from
>RGui(32bit)? or some else way to solve this problem? Thanks! P.S. I 
>launch RStudio with Ctrl-RStudio (that is set the path to R)
>
>   [[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-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] family

2017-11-17 Thread Jeff Newmiller
This question is about algorithm help... or rather, "do my work for me", not 
about R.

Study up on "directed acyclic graphs" [1]... there actually are some packages 
related to such data structures on CRAN (e.g. pooh::tsort, Task View gR 
"gRaphical Models in R"), but you should at least be aware of the possible 
approaches before we talk about implementing (that is the "R" part that is on 
topic here) one of them on this list. 

[1] https://en.wikipedia.org/wiki/Topological_sorting
-- 
Sent from my phone. Please excuse my brevity.

On November 17, 2017 4:28:09 PM PST, Val  wrote:
>Hi all,
>I am reading a huge data set(12M rows) that contains family
>information,
>Offspring, Parent1 and Parent2
>
>Parent1 and parent2 should be in the first column as an offspring
>before their offspring information. Their parent information (parent1
>and parent2) should be  set to zero, if unknown.  Also the first
>column should be unique.
>
>
>Here is my sample data  set  and desired output.
>
>
>fam <- read.table(textConnection(" offspring  Parent1 Parent2
>Smith Alex1  Alexa
>Carla Alex1 0
>Jacky Smith   Abbot
>Jack  0   Jacky
>Almo  JackCarla
> "),header = TRUE)
>
>
>
>desired output.
>Offspring Parent1 Parent2
>Alex1  00
>Alexa  00
>Abbot  00
>SmithAlex1  Alexa
>CarlaAlex1  0
>JackySmith   Abbot
>Jack   0 Jacky
>Almo JackCarla
>
>Thank you.
>
>__
>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-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] Σχετ: change colour in barplot

2017-11-20 Thread Jeff Newmiller
Just so you know, your attachments were stripped on the mailing list both 
times. It was your direct cc to Duncan that allowed him to see your 
attachments. Please avoid using attachments in the future, and if you must 
anyway then read the Posting Guide about which MIME type attachments are 
allowed so others can contribute to the discussion and benefit from the 
exchange you do have. (You can verify how your email/attachments came through 
by reading it on the mailing list archives.)
-- 
Sent from my phone. Please excuse my brevity.

On November 20, 2017 4:09:34 AM PST, Maria Lathouri via R-help 
 wrote:
>Dear all, 
>I am really sorry for this. I have attached the script and a .csv file
>with an example. 
>Hope this will help.
>Many thanks,Maria 
>
>Στις 11:53 π.μ. Δευτέρα, 20 Νοεμβρίου 2017, ο/η Duncan Murdoch
> έγραψε:
> 
>
> On 20/11/2017 6:38 AM, Maria Lathouri via R-help wrote:
>>  Dear all
>> I know that it is a very simple question but it seems that I cannot
>change the colour in the bars.
>> I have the following dataframe:
>> A                  B                 C           D          E        
>           F                    G                0.0.24          152460
>        474       5.5        612000           59061000       1540313
>> and here is the script:
>> setwd("~/Desktop")
>> emission<-read.csv("emission from land.csv")
>> attach(emission)
>> #define the formulas
>>
>Emission_from_Land<-A*B*C*DEmission_from_Access_Road<-E*(F/100)*CEmissions_from_well<-(G/100)*E*C
>> #combine my outputs into a new dataframe
>> dat<-cbind(Emission_from_Land, Emission_from_Access_Road,
>Emissions_from_well_pad)
>> #plot a barplot
>> barplot(dat, ylab="Kg-CO2 Eq", ylim=c(0.0e+00, 2e+10),
>axisnames=FALSE, col=c("blue", "red", "orange"),
>>      main ="Well Site Construction Emissions",
>legend.text=c("Land", "Access", "Well"),
>>      args.legend = list(x="bottom", horiz="TRUE", bty="n",
>inset=c(-0.5, -0.25)))
>> When I add the col= argument, the colour changes in the legend but
>not the actual bars in the plot. I don't know what I am doing wrong. I
>know that I am missing something but I cannot figure it out.
>> I would very much appreciate for your help.
>
>We don't have your data, so we can't reproduce that plot.  But when I
>do 
>the following, I see three colours:
>
>dat <- matrix(1:9, ncol=3)*0.5e9
>par(mfrow=c(2,2))
>barplot(dat, ylab="Kg-CO2 Eq", ylim=c(0.0e+00, 2e+10), axisnames=FALSE,
>
>col=c("blue", "red", "orange"),
>          main ="Well Site Construction Emissions", 
>legend.text=c("Land", "Access", "Well"),
>          args.legend = list(x="bottom", horiz="TRUE", bty="n", 
>inset=c(-0.5, -0.25)))
>
>So you'll need to give us a reproducible example if you want help.
>
>Duncan Murdoch
>
>
>   
>__
>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-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] Cursor lag: Mac High Sierra, R 3.4.2, Macbook Air 2017

2017-11-20 Thread Jeff Newmiller
This is an excellent example of a question that would be appropriate for the 
R-sig-mac mailing list. Do read the Posting Guide. 
-- 
Sent from my phone. Please excuse my brevity.

On November 20, 2017 7:27:44 AM PST, kevin bleakley  
wrote:
>Hi,
>
>I'm running High Sierra on a new "2017" Macbook Air.  I upgraded R from
>a
>previous version (3.2 or 3.3 ?) and now there is a huge lag on the
>curser
>in the R command window itself and in script files. I am not using
>RStudio.
>
>There is a page on GitHub detailing the same problem currently when
>using
>Rstudio. I have no idea whether this problem is related or not.
>
>Cheers
>Kevin
>
>   [[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-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] help

2017-11-21 Thread Jeff Newmiller
Your example is incomplete... as the bottom of this and every post says, we 
need to be able to proceed from an empty R environment to wherever you are 
having the problem (reproducible), in as few steps as possible (minimal). The 
example needs to include data, preferably in R syntax as the dput function 
creates... see the howtos referenced below for help with that.  [1], [2], [3]

You also need to set your email program to send plain text format, since HTML 
gets mangled to various degrees as it gets forced into text format going 
through the mailing list. Read the Posting Guide. 

A wild guess is that you have negative values in your data or too few data 
points...

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette) 
-- 
Sent from my phone. Please excuse my brevity.

On November 21, 2017 12:48:08 AM PST, yadav neog  wrote:
>I am working on  Johansen cointegration test,  using urca and var
>package.
>in the selection of var, I have got following results.
>
>>VARselect(newd, lag.max = 10,type = "none")
>
>$selection
>AIC(n)  HQ(n)  SC(n) FPE(n)
> 6  6  6  5
>
>$criteria
>   1 2 3 4
> 56789
>AIC(n) -3.818646e+01 -3.864064e+01 -3.833435e+01 -4.089169e+01
> NaN -Inf -Inf -Inf -Inf
>HQ(n)  -3.754345e+01 -3.744647e+01 -3.658903e+01 -3.859523e+01
> NaN -Inf -Inf -Inf -Inf
>SC(n)  -3.630096e+01 -3.513899e+01 -3.321655e+01 -3.415775e+01
> NaN -Inf -Inf -Inf -Inf
>FPE(n)  2.700145e-17  2.114513e-17  5.350381e-17  2.035215e-17
>-9.147714e-650000
> 10
>AIC(n) -Inf
>HQ(n)  -Inf
>SC(n)  -Inf
>FPE(n)0
>
>Warning messages:
>1: In log(sigma.det) : NaNs produced
>2: In log(sigma.det) : NaNs produced
>3: In log(sigma.det) : NaNs produced
>
>so do in my ca.jo test... I have found similar NaNs results. please
>help me
>in solving the problem.
>Yadawananda Neog
>Research Scholar
>Department of Economics
>Banaras Hindu University
>Mob. 9838545073
>
>   [[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-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] help

2017-11-21 Thread Jeff Newmiller
Microsoft Word documents are inappropriate, and attachments almost always get 
stripped by the mailing list.

Please read the referenced information this time before trying again, and 
especially the Posting Guide. 
-- 
Sent from my phone. Please excuse my brevity.

On November 21, 2017 8:15:11 AM PST, yadav neog  wrote:
>thank you for your valuable reply. I  have attached my commands,
>results, and
>data with this mail..maybe it will be beneficial for you to feedback.
>
>On Tue, Nov 21, 2017 at 9:13 PM, Jeff Newmiller
>
>wrote:
>
>> Your example is incomplete... as the bottom of this and every post
>says,
>> we need to be able to proceed from an empty R environment to wherever
>you
>> are having the problem (reproducible), in as few steps as possible
>> (minimal). The example needs to include data, preferably in R syntax
>as the
>> dput function creates... see the howtos referenced below for help
>with
>> that.  [1], [2], [3]
>>
>> You also need to set your email program to send plain text format,
>since
>> HTML gets mangled to various degrees as it gets forced into text
>format
>> going through the mailing list. Read the Posting Guide.
>>
>> A wild guess is that you have negative values in your data or too few
>data
>> points...
>>
>> [1] http://stackoverflow.com/questions/5963269/how-to-make-
>> a-great-r-reproducible-example
>>
>> [2] http://adv-r.had.co.nz/Reproducibility.html
>>
>> [3] https://cran.r-project.org/web/packages/reprex/index.html (read
>the
>> vignette)
>> --
>> Sent from my phone. Please excuse my brevity.
>>
>> On November 21, 2017 12:48:08 AM PST, yadav neog
>
>> wrote:
>> >I am working on  Johansen cointegration test,  using urca and var
>> >package.
>> >in the selection of var, I have got following results.
>> >
>> >>VARselect(newd, lag.max = 10,type = "none")
>> >
>> >$selection
>> >AIC(n)  HQ(n)  SC(n) FPE(n)
>> > 6  6  6  5
>> >
>> >$criteria
>> >   1 2 3 4
>> > 56789
>> >AIC(n) -3.818646e+01 -3.864064e+01 -3.833435e+01 -4.089169e+01
>> > NaN -Inf -Inf -Inf -Inf
>> >HQ(n)  -3.754345e+01 -3.744647e+01 -3.658903e+01 -3.859523e+01
>> > NaN -Inf -Inf -Inf -Inf
>> >SC(n)  -3.630096e+01 -3.513899e+01 -3.321655e+01 -3.415775e+01
>> > NaN -Inf -Inf -Inf -Inf
>> >FPE(n)  2.700145e-17  2.114513e-17  5.350381e-17  2.035215e-17
>> >-9.147714e-650000
>> > 10
>> >AIC(n) -Inf
>> >HQ(n)  -Inf
>> >SC(n)  -Inf
>> >FPE(n)0
>> >
>> >Warning messages:
>> >1: In log(sigma.det) : NaNs produced
>> >2: In log(sigma.det) : NaNs produced
>> >3: In log(sigma.det) : NaNs produced
>> >
>> >so do in my ca.jo test... I have found similar NaNs results. please
>> >help me
>> >in solving the problem.
>> >Yadawananda Neog
>> >Research Scholar
>> >Department of Economics
>> >Banaras Hindu University
>> >Mob. 9838545073
>> >
>> >   [[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-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] Best way to study internals of R ( mix of C, C++, Fortran, and R itself)?

2017-11-21 Thread Jeff Newmiller
1) What is easy for one person may be very hard for another, so your question 
is really unanswerable. You do need to know C and Fortran to get through the 
source code. Get started soon reading the R Internals document if it sounds 
interesting to you... you are bound to learn something even if you don't stick 
with it. If you have questions about the internals though, you should read the 
Posting Guide to find out where to ask them (hint: not here).

2) There are lots of blogs and surveys out there about how R's popularity has 
increased over time, though Python seems to have higher billing in job 
descriptions I have seen. Generally if you know multiple tools and the 
underlying theory you are working with then you are more likely to succeed, so 
don't limit yourself by dismissing R for reasons of comparative popularity.
-- 
Sent from my phone. Please excuse my brevity.

On November 21, 2017 11:14:45 AM PST, Robert Wilkins  
wrote:
>How difficult is it to get a good feel for the internals of R, if you
>want
>to learn the general code base, but also the CPU intensive stuff ( much
>of
>it in C or Fortran?) and the ways in which the general code and the CPU
>intensive stuff is connected together?
>
>R has a very large audience, but my understanding is that only a small
>group have a good understanding of the internals (and some of those
>will
>eventually move on to something else in their career, or retire
>altogether).
>
>While I'm at it, a second question: 15 years ago, nobody would ever
>offer a
>job based on R skills ( SAS, yes, SPSS, maybe, but R skills, year after
>year, did not imply job offers). How much has that changed, both for R
>and
>for NumPy/Pandas/SciPy ?
>
>thanks in advance
>
>Robert
>
>   [[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-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] ccomp Composition and ggtern plot...

2017-11-22 Thread Jeff Newmiller
I have no clue what this package is for, but reading the help page for the 
ccomp function tells you that it returns a numeric vector or matrix. How do YOU 
want to display information from this numeric vector? That will determine how 
you would put it into a data frame.
-- 
Sent from my phone. Please excuse my brevity.

On November 22, 2017 3:13:01 AM PST, Levent TERLEMEZ via R-help 
 wrote:
>Dear Users,
>
>I would like to use compositions package with ggplot/ggtern, other
>composition classes of compositional package can be used with ggtern by
>converting to data frame but I could do anything with c(ount)comp
>class. Ggplot/ggtern can not recognise comp and also can not be
>converted to data frame. Is there any other way to do this?
>
>Thank you in advance,
>
>Levent TERLEMEZ.
>
>
>
>
>
>Bu elektronik posta ve onunla iletilen bütün dosyalar sadece yukarıda
>isimleri belirtilen kişiler arasında özel haberleşme amacını taşımakta
>olup gönderici tarafından alınması amaçlanan yetkili gerçek ya da tüzel
>kişinin kullanımına aittir. Eğer bu elektronik posta size yanlışlıkla
>ulaşmışsa, elektronik postanın içeriğini açıklamanız, kopyalamanız,
>yönlendirmeniz ve kullanmanız kesinlikle yasaktır. Bu durumda, lütfen
>mesajı geri gönderiniz ve sisteminizden siliniz. Anadolu Üniversitesi
>bu mesajın içerdiği bilgilerin doğruluğu veya eksiksiz olduğu konusunda
>herhangi bir garanti vermemektedir. Bu nedenle bu bilgilerin ne şekilde
>olursa olsun içeriğinden, iletilmesinden, alınmasından ve
>saklanmasından sorumlu değildir. Bu mesajdaki görüşler yalnızca
>gönderen kişiye aittir ve Anadolu Üniversitesinin görüşlerini
>yansıtmayabilir.
>
>This electronic mail and any files transmitted with it are intended for
>the private use of the people named above. If you are not the intended
>recipient and received this message in error, forwarding, copying or
>use of any of the information is strictly prohibited. Any dissemination
>or use of this information by a person other than the intended
>recipient is unauthorized and may be illegal. In this case, please
>immediately notify the sender and delete it from your system. Anadolu
>University does not guarantee the accuracy or completeness of any
>information included in this message. Therefore, by any means Anadolu
>University is not responsible for the content of the message, and the
>transmission, reception, storage, and use of the information. The
>opinions expressed in this message only belong to the sender of it and
>may not reflect the opinions of Anadolu University.
>
>   [[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-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] Scatterplot of many variables against a single variable

2017-11-27 Thread Jeff Newmiller
You do not appear to have read the Posting Guide mentioned at the bottom if 
this and every posting on the mailing list. 

Only a very few attachment types are allowed through the mailing list... and 
due to the way many email programs fail to identify them properly, even those 
few types may not make it through.

Also, this is a plain text email list... any time you send HTML-formatted email 
it gets converted to plain text with varying amounts of scrambling... you 
really need to tell your email program to send plain text format or we may see 
something very different than you saw when you sent it. 

Luckily, R is a text based programing environment, so if you include a complete 
(with sample data), minimal (so we don't get lost looking at code you already 
have working), reproducible (so we can run it from scratch in our R 
environment) example of your problem in the main body of your plain text email, 
we should be able to help you efficiently. If you don't do that, we usually 
won't understand what your problem is and could either bounce useless emails 
back and forth or may just not reply at all. 

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette)
-- 
Sent from my phone. Please excuse my brevity.

On November 27, 2017 2:59:10 AM PST, Engin YILMAZ  wrote:
>Dear Berger and Jim
>
>Can you see my eviews example in the annex? (scattersample.jpg)
>
>Sincerely
>Engin
>
>2017-11-27 13:27 GMT+03:00 Eric Berger :
>
>> LOL. Great reply Jim.
>> (N.B. Jim's conclusion is "debatable" by a judicious choice of seed.
>e.g.
>> set.seed(79) suggests that making the request more readable will
>actually
>> lower the number of useful answers. :-))
>>
>>
>> On Mon, Nov 27, 2017 at 11:42 AM, Jim Lemon 
>wrote:
>>
>>> Hi Engin,
>>> Sadly, your illustration was ambushed on the way to the list.
>Perhaps
>>> you want something like this:
>>>
>>> # proportion of useful answers to your request
>>> pua<-sort(runif(20))
>>> #legibility of your request
>>> lor<-sort(runif(20))+runif(20,-0.5,0.5)
>>> # is a data set provided?
>>> dsp<-sort(runif(20))+runif(20,-0.5,0.5)
>>> # generate a linear model for the above
>>> pua.lm<-lm(pua~lor+dsp)
>>> # get the coefficients
>>> pua.lm
>>>
>>> Call:
>>> lm(formula = pua ~ lor + dsp)
>>>
>>> Coefficients:
>>> (Intercept)  lor  dsp
>>> 0.1692   0.6132   0.3311
>>>
>>> plot(pua~lor,col="red",main="Proportion of useful answers by request
>>> quality")
>>> points(pua~dsp,col="blue",pch=2)
>>> abline(0.1692,0.6132,col="red")
>>> abline(0.1692,0.3311,col="blue")
>>>
>>> So, the more readable your request and the quality of the data that
>>> you provide, the more useful answers you are likely to receive.
>>>
>>> Jim
>>>
>>>
>>> On Mon, Nov 27, 2017 at 7:56 PM, Engin YILMAZ
>
>>> wrote:
>>> > Dear
>>> >
>>> > I try to realize one scatter matrix which draws *one single
>variable to
>>> all
>>> > variables* with *regression line* . You can see my eviews version 
>in
>>> the
>>> > annex .
>>> >
>>> > How can I draw this graph with R studio?
>>> >
>>> >
>>> > Sincerely
>>> > Engin YILMAZ
>>> > __
>>> > 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/posti
>>> ng-guide.html
>>> > and provide commented, minimal, self-contained, reproducible code.
>>>
>>> __
>>> 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/posti
>>> ng-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>
>
>-- 
>*Saygılarımla*
>Engin YILMAZ
>__
>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-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] SAMseq errors

2017-11-29 Thread Jeff Newmiller
A) This list is a general interest list on the R language... you have posed 
your question as if you were looking for domain experts such as you might be 
more likely to find on the Bioconductor mailing list. 

B) Example is not reproducible. [1][2][3]

C) Just because your data don't have missing values does not mean that your 
early analysis steps don't create them, e.g. by taking the logarithm of 
negative numbers. Look at intermediate values in your analysis, and read the 
documentation for steps you are treating as "magic black boxes".

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette)
-- 
Sent from my phone. Please excuse my brevity.

On November 29, 2017 9:39:24 AM PST, array chip via R-help 
 wrote:
>Sorry forgot to use plain text format, hope this time it works:
>
>Hi, I am trying to using SAMseq() to analyze my RNA-seq experiment
>(2 genes x 550 samples) with survival endpoint. It quickly give the
>following error:
>
>> library(samr)
>Loading required package: impute
>Loading required package: matrixStats
>
>Attaching package: ‘matrixStats’
>
>The following objects are masked from ‘package:Biobase’:
>
>    anyMissing, rowMedians
>
>Warning messages:
>1: package ‘samr’ was built under R version 3.3.3 
>2: package ‘matrixStats’ was built under R version 3.3.3
>
>> samfit<-SAMseq(data, PFI.time,censoring.status=PFI.status,
>resp.type="Survival")
>
>Estimating sequencing depths...
>Error in quantile.default(prop, c(0.25, 0.75)) : 
>  missing values and NaN's not allowed if 'na.rm' is FALSE
>In addition: Warning message:
>In sum(x) : integer overflow - use sum(as.numeric(.))
>Error during wrapup: cannot open the connection
>
>> sessionInfo()
>R version 3.3.2 (2016-10-31)
>Platform: x86_64-w64-mingw32/x64 (64-bit)
>Running under: Windows 7 x64 (build 7601) Service Pack 1
>
>locale:
>[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
>States.1252    LC_MONETARY=English_United States.1252
>[4] LC_NUMERIC=C                           LC_TIME=English_United
>States.1252    
>
>attached base packages:
>[1] stats     graphics  grDevices datasets  utils     methods   base   
> 
>
>other attached packages:
>[1] samr_2.0             matrixStats_0.52.2   impute_1.48.0       
>BiocInstaller_1.24.0 rcom_3.1-3           rscproxy_2.1-1      
>
>loaded via a namespace (and not attached):
>[1] tools_3.3.2
>
>
>I checked, my data matrix and y variables have no missing values.
>Anyone has suggestions what's going on?
>
>Thank you!
>
>John
>
>__
>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-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] Dynamic reference, right-hand side of function

2017-12-04 Thread Jeff Newmiller
 isn't kosher among you more devoted R-users, and 
eventually I hope I will learn to use lists in the future instead.

Thanks!
Love


for (year in 2000:2007){
varname <- paste0("aa_",year)
assign(paste0(varname), as.vector(eval(as.name(varname
}

-Ursprungligt meddelande-
Fr?n: peter dalgaard [mailto:pda...@gmail.com]
Skickat: den 4 december 2017 16:39
Till: Love Bohman 
Kopia: r-help@r-project.org
?mne: Re: [R] Dynamic reference, right-hand side of function

The generic rule is that R is not a macro language, so looping of names of 
things gets awkward. It is usually easier to use compound objects like lists 
and iterate over them. E.g.

datanames <- paste0("aa_", 2000:2007)
datalist <- lapply(datanames, get)
names(datalist) <- datanames
col1 <- lapply(datalist, "[[", 1)
colnum <- lapply(col1, as.numeric)

(The 2nd line assumes that the damage has already been done so that
you have aa_2000 ... aa_2007 in your workspace. You might
alternatively create the list directly while importing the data.)

-pd


On 4 Dec 2017, at 12:33 , Love Bohman  wrote:

Hi R-users!
Being new to R, and a fairly advanced Stata-user, I guess part of my problem is 
that my mindset (and probably my language as well) is wrong. Anyway, I have 
what I guess is a rather simple problem, that I now without success spent days 
trying to solve.

I have a bunch of datasets imported from Stata that is labelled aa_2000 aa_2001 
aa_2002, etc. Each dataset is imported as a matrix, and consists of one column 
only. The columns consists of integer numbers. I need to convert the data to 
vectors, which I found several ways to do. I use, for example:
aa_2000 <- as.numeric(aa_2000[,1])
However, when trying to automate the task, so I don't have to write a line of 
code for each dataset, I get stuck. Since I'm a Stata user, my first attempt is 
trying to make a loop in order to loop over all datasets. However, I manage to 
write a loop that works for the left-hand side of the syntax, but not for the 
right-hand side.
I have included some examples from my struggles to solve the issue below, what they all 
have in common is that I don't manage to call for any "macro" (is that only a 
Stata-word?) in the right hand side of the functions. When I try to replace the static 
reference with a dynamic one (like in the left-hand side), the syntax just doesn't work.

I would very much appreciate some help with this issue!
All the best,
Love

year <- 2002
dataname <- paste0("aa_",year)
assign(paste0(dataname), as.numeric(aa_2002[,1]))

year <- 2003
assign(paste0("aa_",year), as.numeric(aa_2003))

year <- 2005
assign(paste0("aa_",year), aa_2005[,1])

list1 <- c(2000:2007)
list1[c(7)]
assign(paste0("aa_",list1[c(7)]), as.numeric(paste0(aa_2006)))


[[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.


--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School Solbjerg Plads 3,
2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com











--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 
Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com









__
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.


---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

__
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] Remove

2017-12-06 Thread Jeff Newmiller
subset( DM, "B" != x )

This is covered in the Introduction to R document that comes with R.
-- 
Sent from my phone. Please excuse my brevity.

On December 6, 2017 3:21:12 PM PST, David Winsemius  
wrote:
>
>> On Dec 6, 2017, at 3:15 PM, Ashta  wrote:
>> 
>> Hi all,
>> In a data set I have group(GR) and two variables   x and y. I want to
>> remove a  group that have  the same record for the x variable in each
>> row.
>> 
>> DM <- read.table( text='GR x y
>> A 25 125
>> A 23 135
>> A 14 145
>> A 12 230
>> B 25 321
>> B 25 512
>> B 25 123
>> B 25 451
>> C 11 521
>> C 14 235
>> C 15 258
>> C 10 654',header = TRUE, stringsAsFactors = FALSE)
>> 
>> In this example the output should contain group A and C  as group B
>> has   the same record  for the variable x .
>> 
>> The result will be
>> A 25 125
>> A 23 135
>> A 14 145
>> A 12 230
>> C 11 521
>> C 14 235
>> C 15 258
>> C 10 654
>
>Try:
>
>DM[ !duplicated(DM$x) , ]
>> 
>> How do I do it R?
>> Thank you.
>> 
>> __
>> 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.
>
>David Winsemius
>Alameda, CA, USA
>
>'Any technology distinguishable from magic is insufficiently advanced.'
>  -Gehm's Corollary to Clarke's Third Law
>
>__
>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-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] trying to find the multiple combinations...

2017-12-08 Thread Jeff Newmiller
Solve for one of your variables and it will be given in terms of the other two. 
That is, there is a whole infinite plane of solutions. No, aggregate will not 
be sufficient to enumerate the solution set.. 
-- 
Sent from my phone. Please excuse my brevity.

On December 7, 2017 10:37:37 PM PST, Benjamin Sabatini  
wrote:
>Hi,
>
>I'm trying to find a way to determine what multiples of the combination
>of three or more numbers equals a forth number.
>
>So, if I had a number set like:
>
>c(13.4689, 12.85212, 17.05071)
>
>What combination and multiples of these numbers would average to
>15.0078? (so, something that would tell me x, y, and z in (x*13.4689 +
>y*12.85212+ z*17.05071) / x+y+z) = 15.0078
>
>I think this is doable with aggregate?
>
>   [[alternative HTML version deleted]]

This is a plain text mailing list. Please learn how to use your email program. 

>
>__
>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-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] lmerTest Issues

2017-12-08 Thread Jeff Newmiller
Have you read the error and installed package "purrr"? On Windows at least, 
previously-installed packages can get removed if you attempt to update them 
while you have another instance of R open at that time using said packages. 
Best to close all your instances of R before updating, but you can do that now 
to recover. 
-- 
Sent from my phone. Please excuse my brevity.

On December 8, 2017 2:30:09 PM PST, Andrew Harmon  
wrote:
>Hello all,
>
>Everything was working very well. Now when I try to load lmerTest
>using:
>library("lmerTest"), I get this error:
>
>Error: package or namespace load failed for ‘lmerTest’ in
>loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck =
>vI[[j]]):
> there is no package called ‘purrr’
>
>
>Nothing I've done has worked. I have uninstalled both R and R studio.
>I've
>updated packages as well, but nothing works.
>
>Any suggestions?
>
>Thanks,
>
>Drew
>
>   [[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-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] Remove

2017-12-08 Thread Jeff Newmiller
In this case I cannot see an advantage to using dplyr over subset, other 
than if dplyr is your hammer then the problem will look like a nail, or if 
this is one step in a larger context where dplyr is more useful.


Nor do I think this is a good use for mapply (or dplyr::group_by) because 
the groups are handled differently... better to introduce a data-driven 
columnar approach than to have three separate algorithms and bind the data 
frames together again.


Here are three ways I came up with. I sometimes use a variation of method 
3 when the logical tests are rather more complicated than this and I want 
to characterize those tests in the final report.


### reprex
DM <- read.table( text =
"GR x y
A 25 125
A 23 135
A 14 145
A 35 230
B 45 321
B 47 512
B 53 123
B 55 451
C 61 521
C 68 235
C 85 258
C 80 654", header = TRUE, stringsAsFactors = FALSE )

# 1 Hardcoded logic
DM1 <- subset( DM
 ,   "A" == GR & 15 <= x & x <= 30
   | "B" == GR & 40 <= x & x <= 50
   | "C" == GR & 60 <= x & x <= 75
 )
DM1
#>GR  x   y
#> 1   A 25 125
#> 2   A 23 135
#> 5   B 45 321
#> 6   B 47 512
#> 9   C 61 521
#> 10  C 68 235

# 2 relational approach
cond <- read.table( text =
"GR minx maxx
A   15   30
B   40   50
C   60   75
", header = TRUE )
DM2 <- merge( DM, cond, by = "GR" )
DM2 <- subset( DM2, minx <= x & x <= maxx, select = -c( minx, maxx ) )
DM2
#>GR  x   y
#> 1   A 25 125
#> 2   A 23 135
#> 5   B 45 321
#> 6   B 47 512
#> 9   C 61 521
#> 10  C 68 235

# 3 Construct selection vector
sel <- rep( FALSE, nrow( DM ) )
for ( i in seq.int( nrow( cond ) ) ) {
sel <- sel | ( cond$GR[ i ] == DM$GR
 & cond$minx[ i ] <= DM$x
 & DM$x <= cond$maxx[ i ]
 )
}
DM3 <- DM[ sel, ]
DM3
#>GR  x   y
#> 1   A 25 125
#> 2   A 23 135
#> 5   B 45 321
#> 6   B 47 512
#> 9   C 61 521
#> 10  C 68 235
###


On Fri, 8 Dec 2017, Michael Hannon wrote:


library(dplyr)

DM <- read.table( text='GR x y
A 25 125
A 23 135
.
.
.
)

DM %>% filter((GR == "A" & (x >= 15) & (x <= 30)) |
   (GR == "B" & (x >= 40) & (x <= 50)) |
   (GR == "C" & (x >= 60) & (x <= 75)))


On Fri, Dec 8, 2017 at 4:48 PM, Ashta  wrote:

Hi David, Ista and all,

I  have one related question  Within one group I want to keep records
conditionally.
example within
group A I want keep rows that have  " x" values  ranged  between 15 and 30.
group B I want keep rows that have  " x" values  ranged  between  40 and 50.
group C I want keep rows that have  " x" values  ranged  between  60 and 75.


DM <- read.table( text='GR x y
A 25 125
A 23 135
A 14 145
A 35 230
B 45 321
B 47 512
B 53 123
B 55 451
C 61 521
C 68 235
C 85 258
C 80 654',header = TRUE, stringsAsFactors = FALSE)


The end result will be
A 25 125
A 23 135
B 45 321
B 47 512
C 61 521
C 68 235

Thank you

On Wed, Dec 6, 2017 at 10:34 PM, David Winsemius  wrote:



On Dec 6, 2017, at 4:27 PM, Ashta  wrote:

Thank you Ista! Worked fine.


Here's another (possibly more direct in its logic?):

 DM[ !ave(DM$x, DM$GR, FUN= function(x) {!length(unique(x))==1}), ]
  GR  x   y
5  B 25 321
6  B 25 512
7  B 25 123
8  B 25 451

--
David


On Wed, Dec 6, 2017 at 5:59 PM, Ista Zahn  wrote:

Hi Ashta,

There are many ways to do it. Here is one:

vars <- sapply(split(DM$x, DM$GR), var)
DM[DM$GR %in% names(vars[vars > 0]), ]

Best
Ista

On Wed, Dec 6, 2017 at 6:58 PM, Ashta  wrote:

Thank you Jeff,

subset( DM, "B" != x ), this works if I know the group only.
But if I don't know that group in this case "B", how do I identify
group(s) that  all elements of x have the same value?

On Wed, Dec 6, 2017 at 5:48 PM, Jeff Newmiller  wrote:

subset( DM, "B" != x )

This is covered in the Introduction to R document that comes with R.
--
Sent from my phone. Please excuse my brevity.

On December 6, 2017 3:21:12 PM PST, David Winsemius  
wrote:



On Dec 6, 2017, at 3:15 PM, Ashta  wrote:

Hi all,
In a data set I have group(GR) and two variables   x and y. I want to
remove a  group that have  the same record for the x variable in each
row.

DM <- read.table( text='GR x y
A 25 125
A 23 135
A 14 145
A 12 230
B 25 321
B 25 512
B 25 123
B 25 451
C 11 521
C 14 235
C 15 258
C 10 654',header = TRUE, stringsAsFactors = FALSE)

In this example the output should contain group A and C  as group B
has   the same record  for the variable x .

The result will be
A 25 125
A 23 135
A 14 145
A 12 230
C 11 521
C 14 235
C 15 258
C 10 654


Try:

DM[ !duplicated(DM$x) , ]


How do I do it R?
Thank you.

___

Re: [R] Gaussian Process Classification R packages

2017-12-11 Thread Jeff Newmiller
While a plea about struggling may seem appropriate to you, it is just as 
content-free as a reply telling you to use Google... and like it or not, that 
tit-for-tat arises due to frustration with lack of specificity as detailed by 
Charles. That is, if you are constructive about documenting your issue with a 
reproducible example and mentioning what you have tried and how it failed, you 
won't prompt such frustrated/unhelpful responses in the future.

Did you find [1] or [2]?

[1] 
https://stats.stackexchange.com/questions/177677/gaussian-process-prediction-interval

[2] 
https://stats.stackexchange.com/questions/9131/obtaining-a-formula-for-prediction-limits-in-a-linear-model/9144#9144
-- 
Sent from my phone. Please excuse my brevity.

On December 11, 2017 9:53:01 AM PST, Damjan Krstajic  
wrote:
>Thank you Charles Berry for your kind reply. I don't see anything wrong
>with the word "struggling". I have spent several hours trying various R
>packages like kernlab and GPfit to use GP to create a binary
>classification model which produces a prediction interval for each
>sample. I have been struggling because with all of them you may create
>a GP classification model but it only produces a single prediction
>probability, and not a prediction interval of probabilities. Packages
>that I have tried may provide a prediction interval for regression but
>not for binary classification.
>
>
>You mention "The Gaussian Processes Web Site", have you checked how
>many R packages are listed there?
>
>
>I have been coding in R for more than a decade and contact r-help when
>I am struggling (I don't see anything wrong with this word) to find a
>solution in R. Replies like "Google it!" are below my level of my
>communication and understanding of others.
>
>
>Best wishes
>
>DK
>
>
>
>From: Berry, Charles 
>Sent: 11 December 2017 17:04
>To: Damjan Krstajic
>Cc: Bert Gunter; r-help@r-project.org
>Subject: Re: Gaussian Process Classification R packages
>
>
>> On Dec 11, 2017, at 8:06 AM, Damjan Krstajic 
>wrote:
>>
>> I have kindly asked for help and I am sad to receive such a reply
>from some on the r-help list.
>>
>>
>
>Well, you only said you were `struggling' to find a package.
>
>Bert may well have done the Google search himself and found numerous
>resources on such models including links to R (as I did, see below). 
>If so, his response seems quite natural.
>
>Perhaps, you need to say what is wrong with the hits you got and the
>packages that they describe to keep a potential response from running
>in the wrong direction. Perhaps, you have misunderstood the
>capabilities of a package or failed to grasp an inobvious way to use
>the package to reach your goal.  In any case, providing some background
>of why you think the obvious leads do not work in your case can be
>helpful.
>
>Doing that search myself I see links to R packages, R functions, and to
>"The Gaussian Processes Web Site" which has a table of possibly
>relevant softwares.  It seems like there is a lot there to digest.
>
>HTH,
>
>Chuck
>
>> I did google it prior to sending my request, and I could not find any
>R package which provides GP classification model which produces
>prediction intervals for each sample. I would be grateful if anybody
>could inform me about it. Thank you.
>>
>>
>> 
>> From: Bert Gunter 
>> Sent: 11 December 2017 15:50
>> To: Damjan Krstajic
>> Cc: r-help@r-project.org
>> Subject: Re: [R] Gaussian Process Classification R packages
>>
>> Google it!
>>
>> "R Gaussian process model binary classification."
>>
>> Cheers,
>> Bert
>>
>
>
>
>   [[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-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] Add vectors of unequal length without recycling?

2017-12-12 Thread Jeff Newmiller
Better get over it, because it isn't going to change. To avoid it, always work 
with vectors of the same length. 

This is a logical extension of the idea that a scalar adds to every element of 
a vector. 
-- 
Sent from my phone. Please excuse my brevity.

On December 12, 2017 9:41:06 PM PST, Maingo via R-help  
wrote:
>I'm a newbie for R lang. And I recently came across the "Recycling
>Rule" when adding two vectors of unequal length.
>
>I learned from this tutor [
>http://www.r-tutor.com/r-introduction/vector/vector-arithmetics ] that:
>
>""
>
>If two vectors are of unequal length, the shorter one will be recycled
>in order to match the longer vector. For example, the following vectors
>u and v have different lengths, and their sum is computed by recycling
>values of the shorter vector u.
>
>> u = c(10, 20, 30)
>
>> v = c(1, 2, 3, 4, 5, 6, 7, 8, 9)
>
>> u + v
>
>[1] 11 22 33 14 25 36 17 28 39
>
>""
>
>And I wondered, why the shorter vecter u should be recycled? Why not
>just leave the extra values(4,5,6,7,8,9) in the longer vector untouched
>by default?
>
>Otherwise is it better to have another function that could add vectors
>without recycling? Right now the recycling feature bugs me a lot.
>
>Sent with [ProtonMail](https://protonmail.com) Secure Email.
>   [[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-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] something weird has happened....!!!!!!!!!!

2017-12-15 Thread Jeff Newmiller
Entry 250 is different between the two. However, I (we?) have no idea what that 
function is so it might be using randomness as part of its calculation.
-- 
Sent from my phone. Please excuse my brevity.

On December 15, 2017 7:11:30 AM PST, Duncan Murdoch  
wrote:
>On 15/12/2017 7:45 AM, akshay kulkarni wrote:
>> dear Members,
>> 
>> 
>> 
>> Today something weird has happened on my R console. I have attached
>two screenshots of the same vector in my R console but they differ.
>
>Those are function calls, you aren't just printing the same vector 
>twice, you're producing two vectors.
>
>But in what way do they differ?  I looked at 3 entries, and they were 
>identical.
>
>Duncan Murdoch
>> 
>> 
>> Also one of my function returns negative values, even after double
>checking the code, which should return only positive values..
>> 
>> 
>> Whats wrong..? Reinstall R?
>> 
>> 
>> Thanks for help
>> 
>> 
>> AKSHAY M KULKARNI
>> 
>> 
>> 
>> 
>> __
>> 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-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-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] something weird has happened....!!!!!!!!!!

2017-12-15 Thread Jeff Newmiller
Be sure to keep the mailing list in the loop by using reply-all or equivalent 
in your email program. 

You can use the set.seed function with any fixed value before you call 
functions that use randomness to create a reproducible output. 
-- 
Sent from my phone. Please excuse my brevity.

On December 15, 2017 9:07:24 AM PST, akshay kulkarni  
wrote:
>dear Jeff,
>
> I think you have hit the bulls eye.
>
>I am using MICE to populate NA values(imputation) in the source data.
>Everytime I call the function MICE populates different values instead
>of the NA's , right? Is this the randomness you are speaking about?
>
>
>I will test the function again tomorrow. Hope you are right!!
>
>
>Thanks a lot..
>
>
>yours
>
>AKSHAY M KULKARNI
>
>
>From: Jeff Newmiller 
>Sent: Friday, December 15, 2017 10:09 PM
>To: r-help@r-project.org; Duncan Murdoch; akshay kulkarni;
>r-help@r-project.org
>Subject: Re: [R] something weird has happened!!
>
>Entry 250 is different between the two. However, I (we?) have no idea
>what that function is so it might be using randomness as part of its
>calculation.
>--
>Sent from my phone. Please excuse my brevity.
>
>On December 15, 2017 7:11:30 AM PST, Duncan Murdoch
> wrote:
>>On 15/12/2017 7:45 AM, akshay kulkarni wrote:
>>> dear Members,
>>>
>>>
>>>
>>> Today something weird has happened on my R console. I have attached
>>two screenshots of the same vector in my R console but they differ.
>>
>>Those are function calls, you aren't just printing the same vector
>>twice, you're producing two vectors.
>>
>>But in what way do they differ?  I looked at 3 entries, and they were
>>identical.
>>
>>Duncan Murdoch
>>>
>>>
>>> Also one of my function returns negative values, even after double
>>checking the code, which should return only positive values..
>>>
>>>
>>> Whats wrong..? Reinstall R?
>>>
>>>
>>> Thanks for help
>>>
>>>
>>> AKSHAY M KULKARNI
>>>
>>>
>>>
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>R-help -- Main R Mailing List: Primary help - Homepage -
>SfS<https://stat.ethz.ch/mailman/listinfo/r-help>
>stat.ethz.ch
>The main R mailing list, for announcements about the development of R
>and the availability of new code, questions and answers about problems
>and solutions using R ...
>
>
>
>>> PLEASE do read the posting guide
>>http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>__
>>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>https://stat.ethz.ch/mailman/listinfo/r-help
>R-help -- Main R Mailing List: Primary help - Homepage -
>SfS<https://stat.ethz.ch/mailman/listinfo/r-help>
>stat.ethz.ch
>The main R mailing list, for announcements about the development of R
>and the availability of new code, questions and answers about problems
>and solutions using R ...
>
>
>
>>PLEASE do read the posting guide
>>http://www.R-project.org/posting-guide.html
>>and provide commented, minimal, self-contained, reproducible code.

__
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] Errors in reading in txt files

2017-12-15 Thread Jeff Newmiller
Your times are formatted as

01.01.2001-24:00:00

but the default format is

2001-01-01 24:00:00

so you need to specify a format argument with as.POSIXct. Read about format 
strings in ?strptime.
-- 
Sent from my phone. Please excuse my brevity.

On December 15, 2017 9:21:54 AM PST, lily li  wrote:
>I use the method, df$Time = as.POSIXct(df$Time), but it has the warning
>message:
>Error in as.POSIXlt.character(x, tz, ...) :
>  character string is not in a standard unambiguous format
>
>On Thu, Dec 14, 2017 at 1:31 PM, MacQueen, Don 
>wrote:
>
>> In addition to which, I would recommend
>>
>> df <- read.table("DATAM", header = TRUE, fill = TRUE,
>> stringsAsFactors=FALSE)
>>
>> and then converting the Time column to POSIXct date-time values using
>>   as.POSIXct()
>> specifying the format using formatting codes found in
>>   ?strptime
>> because the times are not in the POSIXct default format.
>>
>>
>> This example might indicate the idea:
>>
>> > as.POSIXct('2012-10-12 13:14')
>> [1] "2012-10-12 13:14:00 PDT"
>> > class(as.POSIXct('2012-10-12 13:14'))
>> [1] "POSIXct" "POSIXt"
>>
>> -Don
>>
>> --
>> Don MacQueen
>> Lawrence Livermore National Laboratory
>> 7000 East Ave., L-627
>> Livermore, CA 94550
>> 925-423-1062
>> Lab cell 925-724-7509
>>
>>
>>
>> On 12/14/17, 11:01 AM, "R-help on behalf of Ista Zahn" <
>> r-help-boun...@r-project.org on behalf of istaz...@gmail.com> wrote:
>>
>> On Thu, Dec 14, 2017 at 1:58 PM, Berend Hasselman 
>> wrote:
>> >
>> >> On 14 Dec 2017, at 19:36, lily li  wrote:
>> >>
>> >> Hi R users,
>> >>
>> >> I have a question about reading from text files. The file has
>the
>> structure
>> >> below:
>> >>
>> >> TimeColumn1   Column2
>> >> 01.01.2001-12:00:00
>> >
>> > This line does not contain 3 elements; only one.
>> > You'll have to fix that line. Delete it, prepend it with a
>comment
>> character of add enough columns.
>>
>> I definitely don't recommend that. Instead, read
>>
>> ?read.table
>>
>> to learn about the "fill" and "header" arguments.
>>
>> df = read.table("DATAM", header = TRUE, fill = TRUE)
>>
>> will probably work.
>>
>> Best,
>> Ista
>>
>>
>> >
>> >
>> > Berend
>> >
>> >> 01.01.2001-24:00:0012 11
>> >> 01.02.2001-12:00:0013 10
>> >> 01.02.2001-24:00:0011 12
>> >> 01.03.2001-12:00:0015 11
>> >> 01.03.2001-24:00:0016 10
>> >> ...
>> >>
>> >> I just use the simple script to open it: df =
>read.table('DATAM',
>> head=T).
>> >>
>> >> But it has the error and thus cannot read the file:
>> >> Error in scan(file = file, what = what, sep = sep, quote =
>quote,
>> dec =
>> >> dec,  :
>> >>  line 1 did not have 3 elements
>> >>
>> >> How to read it with three fixed columns, and how to read the
>time
>> format in
>> >> the first column correctly? Thanks for your help.
>> >>
>> >>   [[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-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-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-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] Nonlinear regression

2017-12-19 Thread Jeff Newmiller
Your text has unreadable characters in it. Use plain text. 

Also, your attachments are not coming through. Read the Posting Guide about 
attachments... best results are usually obtained by inserting the R code in the 
body of your email and not attaching anything. 
-- 
Sent from my phone. Please excuse my brevity.

On December 19, 2017 2:13:03 PM PST, Timothy Axberg  
wrote:
>Hello, I am working on a small data set and trying to find values of
>Qmax
>and Kl for the equation
>
>qe = (Qmax * Kl * ce) / (1 + 𝐾l* ce)
>
>I found my Qmax and Kl through the linear model butam now trying to
>find
>them through the "nls" function however an error comes up that I am
>unfamiliar with. I have the file loaded for reference. Any help is
>appreciated. Thank you.
>
>-Timothy
>__
>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-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] Nonlinear regression

2017-12-19 Thread Jeff Newmiller
You also need to reply-all so the mailing list stays in the loop. 
-- 
Sent from my phone. Please excuse my brevity.

On December 19, 2017 4:00:29 PM PST, Timothy Axberg  
wrote:
>Sorry about that. Here is the code typed directly on the email.
>
>qe = (Qmax * Kl * ce) / (1 + Kl * ce)
>
>##The data
>ce <- c(15.17, 42.15, 69.12, 237.7, 419.77)
>qe <- c(17.65, 30.07, 65.36, 81.7, 90.2)
>
>##The linearized data
>celin <- 1/ce
>qelin <- 1/qe
>
>plot(ce, qe, xlim = xlim, ylim = ylim)
>
>##The linear model
>fit1 <- lm(qelin ~ celin)
>intercept1 <- fit1$coefficients[1]
>slope1 <- fit1$coeffecients[2]
>summary(fit1)
>
>Qmax <- 1/intercept1
>Kl <- .735011*Qmax
>
>xlim <- range(ce, celin)
>ylim <- range(qe, qelin)
>
>abline(lm(qelin ~ celin))
>
>c <- seq(min(ce), max(ce))
>q <- (Qmax*Kl*c)/(1+(Kl*c))
>
>lines(c, q)
>
>
>##My attempt at the nonlinear regression
>fit2 <- nls(qe ~ ((Qmax*Kl*ce)/(1+(Kl*ce))), start = list(Qmax = Qmax,
>Kl =
>Kl))
>results <- fit2$m$getpars()
>Qmax2 <- fit2$m$getpars()[1]
>Kl2 <- fit2$m$getpars()[2]
>summary(fit2)
>
>-Timothy

__
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] Error when trying to install package rggobi

2017-12-26 Thread Jeff Newmiller
Have you read [1]? Specifically the SystemRequirements and URL fields? If you 
have installed GGobi previously, perhaps you need to do it again?

[1] https://cran.r-project.org/web/packages/rggobi/index.html
-- 
Sent from my phone. Please excuse my brevity.

On December 26, 2017 8:27:52 AM PST, Paul Bernal  wrote:
>Dear friends,
>
>I am currently using R version 3.4.2 (64-bit for Windows) and when
>trying
>to download package rggobi an error pops up with the following message:
>
>"The program can´t start because libxml2-2.dll is missing from your
>computer. Try reinstalling the program to fix this problem"
>
>Is this suggesting me to reinstall R or is there a way to get the
>libxml2-2.dll somewhere to solve this issue?
>
>Best regards,
>
>Paul
>
>   [[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-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] Writing text files out of a dataset

2017-12-29 Thread Jeff Newmiller
This presumes that 'data[["material"]]' is numeric.

It is unnecessary to put the output data into a separate vector d (it is 
already in a vector that is part of the 'data' data frame).  I would just 
overwrite `d` (or `d1`) each time through the loop:

 for (i in seq_along( data[["material"]] ) ){
d <- data[i,c("material")]
fileConn <- file(paste0("TESTI/d", i, ".txt"))
writeLines(d, fileConn)
close(fileConn)
}

or

for ( i in seq_along( data[["material"]] ) ){
   writeLines( data[i,c("material")], file=paste0("TESTI/d", i, ".txt" ) )
}
-- 
Sent from my phone. Please excuse my brevity.

On December 29, 2017 9:49:20 AM PST, Rui Barradas  wrote:
>Hello,
>
>You have to create the vector 'd' outside the loop before using it.
>
>d <- numeric(nrow(data))
>
>Only then comes the loop.
>
>Hope this helps,
>
>Rui Barradas
>
>On 12/29/2017 2:31 PM, Luca Meyer wrote:
>> Hello,
>> 
>> I am trying to run the following syntax for all cases within the
>dataframe
>> "data"
>> 
>> d1 <- data[1,c("material")]
>> fileConn<-file("TESTI/d1.txt")
>> writeLines(d1, fileConn)
>> close(fileConn)
>> 
>> I am trying to use the for function:
>> 
>>   for (i in 1:nrow(data)){
>>d[i] <- data[i,c("material")]
>>fileConn<-file("TESTI/d[i].txt")
>>writeLines(d[i], fileConn)
>>close(fileConn)
>> }
>> 
>> but I get the error:
>> 
>> Object "d" not found
>> 
>> Any suggestion on how I can solve the above?
>> 
>> Thanks,
>> 
>> Luca
>> 
>>  [[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-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-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] RQuantLib

2017-12-30 Thread Jeff Newmiller
Sometimes that message appears when using a CRAN mirror that is not up-to-date 
or has communication problems. Might also try another mirror.
-- 
Sent from my phone. Please excuse my brevity.

On December 30, 2017 5:25:15 AM PST, Michael Dewey  
wrote:
>Dear Bob
>
>In fact the current release is 3.4.3 I can think of no reason why that 
>should matter here but it might be worth trying to upgrade to it.
>
>Michael
>
>On 29/12/2017 18:31, rsherry8 wrote:
>> Joshua,
>> 
>> Thanks for the response. When you said at least version 3.4.0, I 
>> upgraded to 3.4.2 which I believe is the current version. Now, I 
>> attempted to install the package RQuantLib but it did not work. Here
>is 
>> what I got:
>> 
>>  > install.packages("RQuantLib")
>> Installing package into ‘C:/Users/rsher/Documents/R/win-library/3.4’
>> (as ‘lib’ is unspecified)
>> Warning message:
>> package ‘RQuantLib’ is not available (for R version 3.4.2)
>> 
>> 
>> Please help.
>> Thanks,
>> Bob Sherry
>> 
>> On 12/28/2017 10:28 PM, Joshua Ulrich wrote:
>>> On Thu, Dec 28, 2017 at 6:02 PM, rsherry8 
>wrote:
 I have recently installed R on my new computer. I also want to 
 install the
 package RQuantLib. So I run the following command and get the
>following
 output:

>   install.packages("RQuantLib")
 Installing package into
>‘C:/Users/rsher/Documents/R/win-library/3.2’
 (as ‘lib’ is unspecified)
 --- Please select a CRAN mirror for use in this session ---
 Warning message:
 package ‘RQuantLib’ is not available (for R version 3.2.4 Revised)

 The package did not install. Am I doing something wrong. Is the
>package
 going to be updated for the latest version of R?

>>> Windows binary packages are only built for the most current (major)
>>> version of R.  You need to upgrade to at least R-3.4.0, or you will
>>> have to install RQuantLib (and therefore QuantLib itself) from
>source.
>>>
 Thanks,
 Bob

 __
 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-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.
>
>-- 
>Michael
>http://www.dewey.myzen.co.uk/home.html
>
>__
>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-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] RQuantLib

2017-12-30 Thread Jeff Newmiller
I am not a user of this package, but I think you should read [1], particularly 
the README and system requirements. You may need to learn about compiling from 
source (.tar.gz) if you cannot find a recent precompiled package file (.zip).

[1] https://cran.r-project.org/web/packages/RQuantLib/index.html
-- 
Sent from my phone. Please excuse my brevity.

On December 30, 2017 8:08:55 AM PST, rsherry8  wrote:
>Jeff,
>
>I tired another mirror but that did not work. I tired the following two
>
>commands:
>
> > ap <- available.packages()
> > View(ap)
>
>The output of the View command showed numerous packages available but
>it 
>did not show RQuantLib.
>
>Bob Sherry
>
>On 12/30/2017 8:48 AM, Jeff Newmiller wrote:
>> Sometimes that message appears when using a CRAN mirror that is not
>up-to-date or has communication problems. Might also try another
>mirror.
>> -- Sent from my phone. Please excuse my brevity. On December 30, 2017
>
>> 5:25:15 AM PST, Michael Dewey  wrote:
>>> >Dear Bob
>>> >
>>> >In fact the current release is 3.4.3 I can think of no reason why
>that
>>> >should matter here but it might be worth trying to upgrade to it.
>>> >
>>> >Michael
>>> >
>>> >On 29/12/2017 18:31, rsherry8 wrote:
>>>> >>Joshua,
>>>> >>
>>>> >>Thanks for the response. When you said at least version 3.4.0, I
>>>> >>upgraded to 3.4.2 which I believe is the current version. Now, I
>>>> >>attempted to install the package RQuantLib but it did not work.
>Here
>>> >is
>>>> >>what I got:
>>>> >>
>>>> >>  > install.packages("RQuantLib")
>>>> >>Installing package into
>‘C:/Users/rsher/Documents/R/win-library/3.4’
>>>> >>(as ‘lib’ is unspecified)
>>>> >>Warning message:
>>>> >>package ‘RQuantLib’ is not available (for R version 3.4.2)
>>>> >>
>>>> >>
>>>> >>Please help.
>>>> >>Thanks,
>>>> >>Bob Sherry
>>>> >>
>>>> >>On 12/28/2017 10:28 PM, Joshua Ulrich wrote:
>>>>> >>>On Thu, Dec 28, 2017 at 6:02 PM, rsherry8
>>> >wrote:
>>>>>> >>>>I have recently installed R on my new computer. I also want
>to
>>>>>> >>>>install the
>>>>>> >>>>package RQuantLib. So I run the following command and get the
>>> >following
>>>>>> >>>>output:
>>>>>> >>>>
>>>>>>> >>>>>   install.packages("RQuantLib")
>>>>>> >>>>Installing package into
>>> >‘C:/Users/rsher/Documents/R/win-library/3.2’
>>>>>> >>>>(as ‘lib’ is unspecified)
>>>>>> >>>>--- Please select a CRAN mirror for use in this session ---
>>>>>> >>>>Warning message:
>>>>>> >>>>package ‘RQuantLib’ is not available (for R version 3.2.4
>Revised)
>>>>>> >>>>
>>>>>> >>>>The package did not install. Am I doing something wrong. Is
>the
>>> >package
>>>>>> >>>>going to be updated for the latest version of R?
>>>>>> >>>>
>>>>> >>>Windows binary packages are only built for the most current
>(major)
>>>>> >>>version of R.  You need to upgrade to at least R-3.4.0, or you
>will
>>>>> >>>have to install RQuantLib (and therefore QuantLib itself) from
>>> >source.
>>>>> >>>
>>>>>> >>>>Thanks,
>>>>>> >>>>Bob
>>>>>> >>>>
>>>>>> >>>>__
>>>>>> >>>>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-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.
>>> >
>>> >-- 
>>> >Michael
>>> >http://www.dewey.myzen.co.uk/home.html
>>> >
>>> >__
>>> >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-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] Error in adabag

2018-01-01 Thread Jeff Newmiller
Not reproducible [1][2][3]. (Missing references to packages and "b" data 
frame.) Also, posting with html format makes extracting your code unreliable, 
so set your email program to send plain text for this mailing list. 

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette) 
-- 
Sent from my phone. Please excuse my brevity.

On January 1, 2018 12:02:30 PM PST, greg holly  wrote:
>Hi all;
>
>Happy new year. I have got the following error
>
>rror in if (nrow(object$splits) > 0) { : argument is of length zero
>
> when I am running the following codes.
>
>train <- c(sample(1:27,18), sample(28:54, 18), sample(55:81, 8))
>a2011.adaboost <- boosting(median_kod ~ ., data = b[train, ],
>boos=TRUE,
>mfinal = 10,  control = rpart.control(minsplit = 0))
>
>Regards,
>
>Greg
>
>   [[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-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] Help with first S3-class

2018-01-02 Thread Jeff Newmiller
Function arguments are not pass-by-reference... they are pass-by-value. You 
need to return the altered object to the caller when you are done messing with 
it.

Note that R is a data processing language... your example will not scale to 
real world use cases because you make no use of vectorization to handle 
multiple accounts. It is better to focus on the functional aspect of computing 
and let the objects carry the results until you have a chance to summarize or 
plot them.  Study the "lm" function and associated print and plot methods. 
-- 
Sent from my phone. Please excuse my brevity.

On January 2, 2018 4:37:01 PM PST, "Martin Møller Skarbiniks Pedersen" 
 wrote:
>Some mistake:
>
>> I expect this output:
>
>[1] 100
>Martin
>Saldo is: 100
>
>but I get
>
>[1] 0
>Martn
>Saldo is: 0
>
>__
>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-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] Replace NAs in split lists

2018-01-07 Thread Jeff Newmiller
Why do you want to modify df1?

Why not just reassemble the parts as a new data frame and use that going 
forward in your calculations? That is generally the preferred approach in R so 
you can re-do your calculations easily if you find a mistake later. 
-- 
Sent from my phone. Please excuse my brevity.

On January 7, 2018 7:35:59 PM PST, Ek Esawi  wrote:
>I just came up with a solution right after i posted the question, but
>i figured there must be a better and shorter one.than my solution
>sdf1[[1]][1,4]<-lapplyresults[[1]]
>sdf1[[2]][1,4]<-lapplyresults[[2]]
>
>EK
>
>On Sun, Jan 7, 2018 at 10:13 PM, Ek Esawi  wrote:
>> Hi all--
>>
>> I stumbled on this problem online. I did not like the solution given
>> there which was a long UDF. I thought why cannot split and l/s apply
>> work here. My aim is to split the data frame, use l/sapply, make
>> changes on the split lists and combine the split lists to new data
>> frame with the desired changes/output.
>>
>> The data frame shown below has a column named ID which has 2
>variables
>> a and b; i want to replace the NAs on the Value column by 2, which is
>> the only numeric entry, for ID=a and by 5 for ID=b.
>>
>> I worked out the solution but could not replace the results in the
>split lists.
>>
>> Original dataframe , df1
>>   ID ID_2 Firist Value
>> 1  a   aa   TRUE 2
>> 2  a   ab  FALSENA
>> 3  a   ac  FALSENA
>> 4  b   aa   TRUE 5
>> 5  b   ab  FALSENA
>> Sdf1
>> $a
>> ID ID_2 Firist Value
>> 1  a   aa   TRUE 2
>> 2  a   ab  FALSENA
>> 3  a   ac  FALSENA
>> $b
>>   ID ID_2 Firist Value
>> 4  b   aa   TRUE 5
>> 5  b   ab  FALSENA
>> Desired results
>> ID ID_2 Firist Value
>> 1  a   aa   TRUE2
>> 2  a   ab  FALSE2
>> 3  a   ac  FALSE2
>>
>> $b
>>   ID ID_2 Firist Value
>> 4  b   aa   TRUE 5
>> 5  b   ab  FALSE 5
>>
>> My code
>>
>> sdf <- split(df1,df$ID)
>> lapply(sdf, function(z)
>ifelse(is.na(z$Value),z$Value[!is.na(z$Value)],z$Value))
>> result:
>> $ a: num [1:3] 2 2 2
>> $ b: num [1:2] 5 5
>>
>> How could I put these two lists back in the split data frame, sdf1?
>> Then I could use do.call to reassemble a data frame from the split
>> lists,
>>
>> Thanks,
>> EK
>
>__
>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-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] Replace NAs in split lists

2018-01-08 Thread Jeff Newmiller
Upon closer examination I see that you are not using the split version of 
df1 as I usually would, so here is a reproducible example:


#
df1 <- read.table( text=
"ID ID_2 Firist Value
1  a   aa   TRUE 2
2  a   ab  FALSENA
3  a   ac  FALSENA
4  b   aa   TRUE 5
5  b   ab  FALSENA
", header=TRUE, as.is=TRUE )

sdf <- split( df1, df1$ID )
# note the extra [ 1 ] in case you have more than one non-NA value 
# per ID

sdf2 <- lapply( sdf
  , function( z ) {
 z$Value <- ifelse( is.na( z$Value )
  , z$Value[ !is.na( z$Value ) ][ 1 ]
  , z$Value
  )
 z
}
  )
df2 <- do.call( rbind, sdf2 )
df2
#> ID ID_2 Firist Value
#> a.1  a   aa   TRUE 2
#> a.2  a   ab  FALSE 2
#> a.3  a   ac  FALSE 2
#> b.4  b   aa   TRUE 5
#> b.5  b   ab  FALSE 5

# or using tidyverse methods

library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
df3 <- (   df1
   %>% group_by( ID )
   %>% do({
  mutate( .
, Value = ifelse( is.na( Value )
, Value[ !is.na( Value ) ][ 1 ]
, Value
)
)
   })
   %>% ungroup
   )
df3
#> # A tibble: 5 x 4
#>   IDID_2  Firist Value
#>   
#> 1 a aaT  2
#> 2 a abF  2
#> 3 a acF  2
#> 4 b aaT  5
#> 5 b abF  5
#

On Sun, 7 Jan 2018, Jeff Newmiller wrote:


Why do you want to modify df1?

Why not just reassemble the parts as a new data frame and use that going 
forward in your calculations? That is generally the preferred approach 
in R so you can re-do your calculations easily if you find a mistake 
later.

--
Sent from my phone. Please excuse my brevity.

On January 7, 2018 7:35:59 PM PST, Ek Esawi  wrote:

I just came up with a solution right after i posted the question, but
i figured there must be a better and shorter one.than my solution
sdf1[[1]][1,4]<-lapplyresults[[1]]
sdf1[[2]][1,4]<-lapplyresults[[2]]

EK

On Sun, Jan 7, 2018 at 10:13 PM, Ek Esawi  wrote:

Hi all--

I stumbled on this problem online. I did not like the solution given
there which was a long UDF. I thought why cannot split and l/s apply
work here. My aim is to split the data frame, use l/sapply, make
changes on the split lists and combine the split lists to new data
frame with the desired changes/output.

The data frame shown below has a column named ID which has 2

variables

a and b; i want to replace the NAs on the Value column by 2, which is
the only numeric entry, for ID=a and by 5 for ID=b.

I worked out the solution but could not replace the results in the

split lists.


Original dataframe , df1
  ID ID_2 Firist Value
1  a   aa   TRUE 2
2  a   ab  FALSENA
3  a   ac  FALSENA
4  b   aa   TRUE 5
5  b   ab  FALSENA
Sdf1
$a
ID ID_2 Firist Value
1  a   aa   TRUE 2
2  a   ab  FALSENA
3  a   ac  FALSENA
$b
  ID ID_2 Firist Value
4  b   aa   TRUE 5
5  b   ab  FALSENA
Desired results
ID ID_2 Firist Value
1  a   aa   TRUE2
2  a   ab  FALSE2
3  a   ac  FALSE2

$b
  ID ID_2 Firist Value
4  b   aa   TRUE 5
5  b   ab  FALSE 5

My code

sdf <- split(df1,df$ID)
lapply(sdf, function(z)

ifelse(is.na(z$Value),z$Value[!is.na(z$Value)],z$Value))

result:
$ a: num [1:3] 2 2 2
$ b: num [1:2] 5 5

How could I put these two lists back in the split data frame, sdf1?
Then I could use do.call to reassemble a data frame from the split
lists,

Thanks,
EK


__
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-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.



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Co

Re: [R] foverlaps data.table error

2018-01-08 Thread Jeff Newmiller

Disclaimer: I am not a user of this package.

1) This is a plain text mailing list... your email was mangled in transit. 
Send in plain text format to the R mailing lists to avoid confusing 
potential respondents.


2) It is bad form to post here and not point out that you have already 
asked elsewhere [1]. It looks like you already received a quality answer 
there. Failing to link to previous threads is almost as impolite as 
cross-posting to multiple mailing lists... read the Posting Guide for more 
on mailing list etiquette.


3) Note that there is a mailing list intended for questions about this 
package: the datatable-help mailing list.


[1] 
https://stackoverflow.com/questions/48141991/foverlaps-and-within-in-data-table

On Sun, 7 Jan 2018, Rahul Sharm wrote:


Hello All
Have 2 tables
dt1:
start end kwh10min
2013-04-01 00:00:54 UTC 2013-04-01 01:00:10 UTC 0.05
2013-04-01 00:40:26 UTC 2013-04-01 00:50:00 UTC 0.1
2013-04-01 02:13:20 UTC 2013-04-01 04:53:42 UTC 0.15
2013-04-02 02:22:00 UTC 2013-04-01 04:33:12 UTC 0.2
2013-04-01 02:26:23 UTC 2013-04-01 04:05:12 UTC 0.25
2013-04-01 02:42:47 UTC 2013-04-01 04:34:33 UTC 0.3
2013-04-01 02:53:12 UTC 2013-04-03 05:27:05 UTC 0.35
2013-04-02 02:54:08 UTC 2013-04-02 05:31:15 UTC 0.4
2013-04-03 02:57:16 UTC 2013-04-03 05:29:32 UTC 0.45
dt2: start and end are 10 minute interval blocks spanning 2013-4-1 00:00:00
to 2013-04-04

I want to add the column 3 of dt1 to map as long as the start and end time
are within the 10 minute blocks and keep appending the columns

ideally the output should be
4/1/2013 0:00
4/1/2013 0:10
0.05 0

4/1/2013 0:10
4/1/2013 0:20
0.05 0

4/1/2013 0:20
4/1/2013 0:30
0.05 0

4/1/2013 0:30
4/1/2013 0:40
0.05 0

4/1/2013 0:40
4/1/2013 0:50
0.05 0.01

4/1/2013 0:50
4/1/2013 1:00
0.05 0.01
I tried
setkey(dums,start,end)
setkey(map,start,end)
foverlaps(map,dums,type="within",nomatch=0L)

I keep getting the error
Error in foverlaps(map, dums, type = "within", nomatch = 0L) :
 All entries in column start should be <= corresponding entries in column
end in data.table 'y'

[[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.



-------
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

__
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] Replace NAs in split lists

2018-01-08 Thread Jeff Newmiller
Yes, you are right if the IDs are always sequentially-adjacent and the first 
non-NA value appears in the first record for each ID.
-- 
Sent from my phone. Please excuse my brevity.

On January 8, 2018 2:29:40 AM PST, PIKAL Petr  wrote:
>Hi
>
>With the example, na.locf seems to be the easiest way.
>> library(zoo)
>
>> na.locf(df1)
>  ID ID_2 Firist Value
>1  a   aa   TRUE 2
>2  a   ab  FALSE 2
>3  a   ac  FALSE 2
>4  b   aa   TRUE 5
>5  b   ab  FALSE 5
>
>Cheers
>Petr
>
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff
>> Newmiller
>> Sent: Monday, January 8, 2018 9:13 AM
>> To: r-help@r-project.org; Ek Esawi 
>> Subject: Re: [R] Replace NAs in split lists
>>
>> Upon closer examination I see that you are not using the split
>version of
>> df1 as I usually would, so here is a reproducible example:
>>
>> #
>> df1 <- read.table( text=
>> "ID ID_2 Firist Value
>> 1  a   aa   TRUE 2
>> 2  a   ab  FALSENA
>> 3  a   ac  FALSENA
>> 4  b   aa   TRUE 5
>> 5  b   ab  FALSENA
>> ", header=TRUE, as.is=TRUE )
>>
>> sdf <- split( df1, df1$ID )
>> # note the extra [ 1 ] in case you have more than one non-NA value #
>per ID
>> sdf2 <- lapply( sdf
>>, function( z ) {
>>   z$Value <- ifelse( is.na( z$Value )
>>, z$Value[ !is.na( z$Value ) ][ 1
>]
>>, z$Value
>>)
>>   z
>>  }
>>)
>> df2 <- do.call( rbind, sdf2 )
>> df2
>> #> ID ID_2 Firist Value
>> #> a.1  a   aa   TRUE 2
>> #> a.2  a   ab  FALSE 2
>> #> a.3  a   ac  FALSE 2
>> #> b.4  b   aa   TRUE 5
>> #> b.5  b   ab  FALSE 5
>>
>> # or using tidyverse methods
>>
>> library(dplyr)
>> #>
>> #> Attaching package: 'dplyr'
>> #> The following objects are masked from 'package:stats':
>> #>
>> #> filter, lag
>> #> The following objects are masked from 'package:base':
>> #>
>> #> intersect, setdiff, setequal, union
>> df3 <- (   df1
>> %>% group_by( ID )
>> %>% do({
>>mutate( .
>>  , Value = ifelse( is.na( Value )
>>      , Value[ !is.na( Value ) ][ 1 ]
>>  , Value
>>  )
>>  )
>> })
>> %>% ungroup
>> )
>> df3
>> #> # A tibble: 5 x 4
>> #>   IDID_2  Firist Value
>> #>   
>> #> 1 a aaT  2
>> #> 2 a abF  2
>> #> 3 a acF  2
>> #> 4 b aaT  5
>> #> 5 b abF  5
>> #
>>
>> On Sun, 7 Jan 2018, Jeff Newmiller wrote:
>>
>> > Why do you want to modify df1?
>> >
>> > Why not just reassemble the parts as a new data frame and use that
>> > going forward in your calculations? That is generally the preferred
>> > approach in R so you can re-do your calculations easily if you find
>a
>> > mistake later.
>> > --
>> > Sent from my phone. Please excuse my brevity.
>> >
>> > On January 7, 2018 7:35:59 PM PST, Ek Esawi 
>wrote:
>> >> I just came up with a solution right after i posted the question,
>but
>> >> i figured there must be a better and shorter one.than my solution
>> >> sdf1[[1]][1,4]<-lapplyresults[[1]]
>> >> sdf1[[2]][1,4]<-lapplyresults[[2]]
>> >>
>> >> EK
>> >>
>> >> On Sun, Jan 7, 2018 at 10:13 PM, Ek Esawi 
>wrote:
>> >>> Hi all--
>> >>>
>> >>> I stumbled on this problem online. I did not like the solution
>given
>> >>> there which was a long UDF. I thought why cannot split and l/s
>apply
>> >>> work here. My aim is to split the data frame, use l/sapply, make
>> >>> changes on the split lists and combine the split lists to new
>data
>> >>> frame with the desired changes/output.
>> >>>
>> >>> The data frame shown below has a column named ID which has 2
>> >> variables
>> >>&g

Re: [R] Replace NAs in split lists

2018-01-08 Thread Jeff Newmiller
"Enforce" is overstating it... results will differ if there are no non-NA 
values for a given ID, and there is a potential further discrepancy if there 
are multiple non-NA values. But these issues were not identified by the OP, so 
may not be relevant in their case. 
-- 
Sent from my phone. Please excuse my brevity.

On January 8, 2018 6:41:33 AM PST, Eric Berger  wrote:
>You can enforce these assumptions by sorting on multiple columns, which
>leads to
>
>na.locf(df1[ order(df1$ID,df1$Value), ])
>
>
>
>On Mon, Jan 8, 2018 at 4:19 PM, Jeff Newmiller
>
>wrote:
>
>> Yes, you are right if the IDs are always sequentially-adjacent and
>the
>> first non-NA value appears in the first record for each ID.
>> --
>> Sent from my phone. Please excuse my brevity.
>>
>> On January 8, 2018 2:29:40 AM PST, PIKAL Petr
>
>> wrote:
>> >Hi
>> >
>> >With the example, na.locf seems to be the easiest way.
>> >> library(zoo)
>> >
>> >> na.locf(df1)
>> >  ID ID_2 Firist Value
>> >1  a   aa   TRUE 2
>> >2  a   ab  FALSE 2
>> >3  a   ac  FALSE 2
>> >4  b   aa   TRUE 5
>> >5  b   ab  FALSE 5
>> >
>> >Cheers
>> >Petr
>> >
>> >> -Original Message-
>> >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
>Jeff
>> >> Newmiller
>> >> Sent: Monday, January 8, 2018 9:13 AM
>> >> To: r-help@r-project.org; Ek Esawi 
>> >> Subject: Re: [R] Replace NAs in split lists
>> >>
>> >> Upon closer examination I see that you are not using the split
>> >version of
>> >> df1 as I usually would, so here is a reproducible example:
>> >>
>> >> #
>> >> df1 <- read.table( text=
>> >> "ID ID_2 Firist Value
>> >> 1  a   aa   TRUE 2
>> >> 2  a   ab  FALSENA
>> >> 3  a   ac  FALSENA
>> >> 4  b   aa   TRUE 5
>> >> 5  b   ab  FALSENA
>> >> ", header=TRUE, as.is=TRUE )
>> >>
>> >> sdf <- split( df1, df1$ID )
>> >> # note the extra [ 1 ] in case you have more than one non-NA value
>#
>> >per ID
>> >> sdf2 <- lapply( sdf
>> >>, function( z ) {
>> >>   z$Value <- ifelse( is.na( z$Value )
>> >>, z$Value[ !is.na( z$Value ) ][
>1
>> >]
>> >>, z$Value
>> >>)
>> >>   z
>> >>  }
>> >>)
>> >> df2 <- do.call( rbind, sdf2 )
>> >> df2
>> >> #> ID ID_2 Firist Value
>> >> #> a.1  a   aa   TRUE 2
>> >> #> a.2  a   ab  FALSE 2
>> >> #> a.3  a   ac  FALSE 2
>> >> #> b.4  b   aa   TRUE 5
>> >> #> b.5  b   ab  FALSE 5
>> >>
>> >> # or using tidyverse methods
>> >>
>> >> library(dplyr)
>> >> #>
>> >> #> Attaching package: 'dplyr'
>> >> #> The following objects are masked from 'package:stats':
>> >> #>
>> >> #> filter, lag
>> >> #> The following objects are masked from 'package:base':
>> >> #>
>> >> #> intersect, setdiff, setequal, union
>> >> df3 <- (   df1
>> >> %>% group_by( ID )
>> >> %>% do({
>> >>mutate( .
>> >>  , Value = ifelse( is.na( Value )
>> >>  , Value[ !is.na( Value ) ][ 1
>]
>> >>  , Value
>> >>  )
>> >>  )
>> >> })
>> >> %>% ungroup
>> >> )
>> >> df3
>> >> #> # A tibble: 5 x 4
>> >> #>   IDID_2  Firist Value
>> >> #>   
>> >> #> 1 a aaT  2
>> >> #> 2 a abF  2
>> >> #> 3 a acF  2
>> >> #> 4 b aaT  5
>> >> #> 5 b abF  5
>> >> #
>> >>
>> >> On Sun, 7 Jan 2018, Jeff Newmiller wrote:
>> >>
>> &g

Re: [R] Replace NAs in split lists

2018-01-08 Thread Jeff Newmiller
I don't know. You seem to be posting in HTML so your code is mangled. Can you 
post plain text and use the reprex package to make sure it produces the errorin 
a clean R session? 
-- 
Sent from my phone. Please excuse my brevity.

On January 8, 2018 8:03:45 AM PST, Ek Esawi  wrote:
>Thank you Jeff. Your code works, as usual , perfectly. I am just
>wondering why if i put the whole code in one line, i get an error
>message.
>sdf2 <- lapply( sdf, function(z){z$Value
><-ifelse(is.na(z$Value),z$Value[!is.na(z$Value)][1],z$Value)z})
>error. unexpected symbol in sdf2
>
>Thanks again
>
>EK
>
>
>On Mon, Jan 8, 2018 at 3:12 AM, Jeff Newmiller
> wrote:
>> Upon closer examination I see that you are not using the split
>version of
>> df1 as I usually would, so here is a reproducible example:
>>
>> #
>> df1 <- read.table( text=
>> "ID ID_2 Firist Value
>> 1  a   aa   TRUE 2
>> 2  a   ab  FALSENA
>> 3  a   ac  FALSENA
>> 4  b   aa   TRUE 5
>> 5  b   ab  FALSENA
>> ", header=TRUE, as.is=TRUE )
>>
>> sdf <- split( df1, df1$ID )
>> # note the extra [ 1 ] in case you have more than one non-NA value #
>per ID
>> sdf2 <- lapply( sdf
>>   , function( z ) {
>>  z$Value <- ifelse( is.na( z$Value )
>>   , z$Value[ !is.na( z$Value ) ][ 1 ]
>>   , z$Value
>>   )
>>  z
>> }
>>   )
>> df2 <- do.call( rbind, sdf2 )
>> df2
>> #> ID ID_2 Firist Value
>> #> a.1  a   aa   TRUE 2
>> #> a.2  a   ab  FALSE 2
>> #> a.3  a   ac  FALSE 2
>> #> b.4  b   aa   TRUE 5
>> #> b.5  b   ab  FALSE 5
>>
>> # or using tidyverse methods
>>
>> library(dplyr)
>> #>
>> #> Attaching package: 'dplyr'
>> #> The following objects are masked from 'package:stats':
>> #>
>> #> filter, lag
>> #> The following objects are masked from 'package:base':
>> #>
>> #> intersect, setdiff, setequal, union
>> df3 <- (   df1
>>%>% group_by( ID )
>>%>% do({
>>   mutate( .
>> , Value = ifelse( is.na( Value )
>> , Value[ !is.na( Value ) ][ 1 ]
>> , Value
>> )
>> )
>>})
>>%>% ungroup
>>)
>> df3
>> #> # A tibble: 5 x 4
>> #>   IDID_2  Firist Value
>> #>   
>> #> 1 a aaT  2
>> #> 2 a abF  2
>> #> 3 a acF  2
>> #> 4 b aaT  5
>> #> 5 b abF  5
>> #
>>
>>
>> On Sun, 7 Jan 2018, Jeff Newmiller wrote:
>>
>>> Why do you want to modify df1?
>>>
>>> Why not just reassemble the parts as a new data frame and use that
>going
>>> forward in your calculations? That is generally the preferred
>approach in R
>>> so you can re-do your calculations easily if you find a mistake
>later.
>>> --
>>> Sent from my phone. Please excuse my brevity.
>>>
>>> On January 7, 2018 7:35:59 PM PST, Ek Esawi 
>wrote:
>>>>
>>>> I just came up with a solution right after i posted the question,
>but
>>>> i figured there must be a better and shorter one.than my solution
>>>> sdf1[[1]][1,4]<-lapplyresults[[1]]
>>>> sdf1[[2]][1,4]<-lapplyresults[[2]]
>>>>
>>>> EK
>>>>
>>>> On Sun, Jan 7, 2018 at 10:13 PM, Ek Esawi 
>wrote:
>>>>>
>>>>> Hi all--
>>>>>
>>>>> I stumbled on this problem online. I did not like the solution
>given
>>>>> there which was a long UDF. I thought why cannot split and l/s
>apply
>>>>> work here. My aim is to split the data frame, use l/sapply, make
>>>>> changes on the split lists and combine the split lists to new data
>>>>> frame with the desired changes/output.
>>>>>
>>>>> The data frame shown below has a column named ID which has 2
>>>>
>>>> variables
>>>>>
>>>>> a and b; i want to replace the NAs on the Value column by 2, which
>is
>>>>> the onl

Re: [R] No keyboard control in the R terminal

2018-01-08 Thread Jeff Newmiller
Unlikely. My guess is you compiled it yourself without having readline 
development support installed where the configure script could find it.
-- 
Sent from my phone. Please excuse my brevity.

On January 8, 2018 6:23:34 PM PST, Olson Roman  wrote:
>Dear R Users,
>
>There is no R keyboard control in my R terminal. Specifically, I can
>not use the up and down arrows, use autocomplete, or “backspace” to
>delete. I am using R 3.3.3 on 
>Linux  2.6.18-164.el5 #1 SMP Thu Sep 3 03:28:30 EDT 2009 x86_64
>x86_64 x86_64 GNU/Linux
>
>Is this an R bug?
>
>Best,
>-R
>__
>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-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] UseDevel: version requires a more recent R

2018-01-09 Thread Jeff Newmiller
Wrong forum.

https://support.bioconductor.org/
-- 
Sent from my phone. Please excuse my brevity.

On January 9, 2018 10:32:15 AM PST, "Sariya, Sanjeev" 
 wrote:
>Hello R experts:
>
>I need a developer version of a Bioconductor library.
>
>> sessionInfo()
>R version 3.4.2 (2017-09-28)
>Platform: x86_64-w64-mingw32/x64 (64-bit)
>Running under: Windows 7 x64 (build 7601) Service Pack 1
>
>When I try to useDevel it fails.
>
>I've removed packages and again loaded but I get the same error
>message.
>
>remove.packages("BiocInstaller")
>source("https://bioconductor.org/biocLite.R";)
>library(BiocInstaller)
>
>Bioconductor version 3.6 (BiocInstaller 1.28.0), ?biocLite for help
>
>
>> useDevel()
>
>Error: 'devel' version requires a more recent R
>
>I'm running into this error for few days now. I close R after removing
>biocInstaller and proceed with following steps.
>
>Please guide me to fix this.
>
>Thanks,
>SS
>
>   [[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-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] R-hts

2018-01-10 Thread Jeff Newmiller
You are the one with data. Supply what you have (or a simulated version of 
same, hence the reading recommendation) using dput, and someone may suggest how 
to transform it. In most cases a simple tabular format (data frame) is 
sufficient. 
-- 
Sent from my phone. Please excuse my brevity.

On January 10, 2018 12:20:47 PM PST, "Jérémie Juste"  
wrote:
>Hello,
>
>It's difficult to help without a sample of the format. Can you provide
>a
>short sample like 10 lines and a few columns.?
>
>Best regards,
>Jeremie
>
>
>On Wed, Jan 10, 2018 at 6:12 PM, John Kane via R-help
>
>wrote:
>
>> Have a look at
>http://stackoverflow.com/questions/5963269/how-to-make-
>> a-great-r-reproducible-example
>> and
>> http://adv-r.had.co.nz/Reproducibility.html
>>
>>
>>
>>
>> On Wednesday, January 10, 2018, 11:51:22 AM EST, deva d <
>> devazresea...@gmail.com> wrote:
>>
>>  dear all,
>>
>> i need some help in structuring my data file for a hierarchical time
>series
>> analysis.
>>
>> can someone help please ?
>>
>> i have a 600 row database in the nature of a panel data, with 3 time
>series
>> values of interest. the data also has 4 classificatory variables
>comprising
>> a code for each entity in the panel, a value for time (year), and
>> classification of type of entity and a further sub-group of the type.
>>
>> i am unable to structure the data file for performing the hts
>analysis.
>>
>> thanks in advance.
>>
>> **
>>
>> *Deva*
>>
>>
>> ...
>>
>>
>>
>> *in search of knowledge, everyday something is added *
>>
>> *in search of wisdom, everyday something is dropped  ... an old
>Chinese
>> Proverb*
>> :
>>
>> [[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.
>>
>
>
>
>-- 
>Jérémie Juste
>
>   [[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-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] R-hts

2018-01-10 Thread Jeff Newmiller
Sorry Jérémie, I mis-read who the OP was. Deva needs to get the ball rolling. 

I would say that for a hierarchical analysis the sample data generally needs to 
be larger than for other types of analysis to illustrate correlation between 
classification variables or the example calculation will break. That is, 10 
rows will likely be insufficient for a dry run. 

-- 
Sent from my phone. Please excuse my brevity.

On January 10, 2018 2:02:29 PM PST, Jeff Newmiller  
wrote:
>You are the one with data. Supply what you have (or a simulated version
>of same, hence the reading recommendation) using dput, and someone may
>suggest how to transform it. In most cases a simple tabular format
>(data frame) is sufficient. 
>-- 
>Sent from my phone. Please excuse my brevity.
>
>On January 10, 2018 12:20:47 PM PST, "Jérémie Juste"
> wrote:
>>Hello,
>>
>>It's difficult to help without a sample of the format. Can you provide
>>a
>>short sample like 10 lines and a few columns.?
>>
>>Best regards,
>>Jeremie
>>
>>
>>On Wed, Jan 10, 2018 at 6:12 PM, John Kane via R-help
>>
>>wrote:
>>
>>> Have a look at
>>http://stackoverflow.com/questions/5963269/how-to-make-
>>> a-great-r-reproducible-example
>>> and
>>> http://adv-r.had.co.nz/Reproducibility.html
>>>
>>>
>>>
>>>
>>> On Wednesday, January 10, 2018, 11:51:22 AM EST, deva d <
>>> devazresea...@gmail.com> wrote:
>>>
>>>  dear all,
>>>
>>> i need some help in structuring my data file for a hierarchical time
>>series
>>> analysis.
>>>
>>> can someone help please ?
>>>
>>> i have a 600 row database in the nature of a panel data, with 3 time
>>series
>>> values of interest. the data also has 4 classificatory variables
>>comprising
>>> a code for each entity in the panel, a value for time (year), and
>>> classification of type of entity and a further sub-group of the
>type.
>>>
>>> i am unable to structure the data file for performing the hts
>>analysis.
>>>
>>> thanks in advance.
>>>
>>> **
>>>
>>> *Deva*
>>>
>>>
>>> ...
>>>
>>>
>>>
>>> *in search of knowledge, everyday something is added *
>>>
>>> *in search of wisdom, everyday something is dropped  ... an old
>>Chinese
>>> Proverb*
>>> :
>>>
>>> [[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.
>>>
>>
>>
>>
>>-- 
>>Jérémie Juste
>>
>>  [[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-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-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] application of R

2018-01-11 Thread Jeff Newmiller
Because many technical people need to accomplish statistical data analysis with 
computers that depend on existing algorithms applied in new ways, or with new 
algorithms that are not implemented by commercial software.  Often such people 
have no desire to provide step-by-step support of their tools for every user of 
their code indefinitely, so developing commercial software for others is less 
useful to them than having access to existing software that can be adapted. 
They often find that allowing others access to their code is a reasonable trade 
for being able to re-use the work of others before them. 

You might read the book "The Cathedral and the Bazaar" for more detail about 
this perspective, but this line of discussion is not really on topic here.
-- 
Sent from my phone. Please excuse my brevity.

On January 11, 2018 7:09:20 PM PST, muhammad ramzi  wrote:
>Thank you very much this really helped me a lot . 
>So actually why would people learn R(other than personal interests ) if
>you can't really build anything that can be sold ? I'm sorry if I'm
>asking bad questions 
>
>
>> On 12 Jan 2018, at 4:43 AM, Marc Schwartz 
>wrote:
>> 
>> 
>> 
>>> On Jan 11, 2018, at 2:15 PM, muhammad ramzi 
>wrote:
>>> 
>>> hello guys,
>>> 
>>> i am a petroleum engineering student and i will be having a long
>semester
>>> break and currently i am learning THE R PROGRAMMING LANGUAGE just
>out of
>>> interest. I would just like to know if i am able to design a
>business
>>> analysis software using R as in create a type of software that can
>be sold
>>> to business people. can this be done in R language?
>>> 
>>> another thing is if i do learn this all the way, what advantages
>will it
>>> give me in terms of future prospects and career development?
>> 
>> 
>> Hi,
>> 
>> To your first question, as R is open source and released under the
>GPL, there are legal issues that you will need to consider, which will
>be specific to the details of your plans, how your "application" is
>built, how it interacts with R, and importantly, the copying and
>distribution of the end product.
>> 
>> You should, first and foremost, contact a lawyer familiar with open
>source software, specifically GPL compatible licenses, so that you can
>get proper legal advice, which you will not get here. You risk
>legal/financial liabilities down the road if not done in compliance
>with the license requirements.
>> 
>> As a first pass, you should read:
>> 
>> 
>https://cran.r-project.org/doc/FAQ/R-FAQ.html#Can-I-use-R-for-commercial-purposes_003f
>> 
>> and
>> 
>>  https://www.gnu.org/licenses/old-licenses/gpl-2.0-faq.html
>> 
>> so that you can gain initial insights into some of the general
>implications of building a product for distribution (whether you give
>it away or sell it) that depends upon a GPL licensed application. 
>> 
>> Whether or not there is utility for the application you envision such
>that people would be willing to pay for it, will depend upon a variety
>of factors, not the least of which is what competition you face and the
>value of your planned application over others that are already in the
>marketplace.
>> 
>> To your second question, you are asking a biased, self selected
>audience. Thus, take that into account for any responses that you may
>get.
>> 
>> The responses relative to advantages are going to be, to some extent,
>broadly industry specific. That being said, in many domains, knowing R,
>along with other relevant applications and programming languages can
>only be beneficial in many cases.
>> 
>> R is becoming increasingly popular (e.g. see:
>https://www.tiobe.com/tiobe-index/). However, depending upon the
>subject matter domain you will work in and to a large extent, the
>company or institution you will work for, those factors can have a
>material influence on the role that R might play in that environment.
>> 
>> Others can perhaps chime in with other thoughts and perhaps even
>industry specific insights for you.
>> 
>> Regards,
>> 
>> Marc Schwartz
>> 
>
>__
>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-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] sum multiple csv files

2018-01-15 Thread Jeff Newmiller
Your message seems unclear, and as evidence the respondents are giving various 
answers. You should provide a small sample of input and output data as it would 
look in R to avoid this kind of thrashing about. See [1][2][3] for guidance. 
Note that you also really need to figure out how to make sure your email 
program sends plain text, because HTML formatting WILL be stripped by the 
mailing list (read the Posting Guide) and that process often garbles it. 

My own possibly-confused reading of your question ("each cvs file has 47 rows 
and colunms, so the final data frame should have the same") is that you do not 
yet understand the difference between matrices and data frames ([4]), and you 
want to perform matrix (element-wise) addition. This would require that you 
convert the data frames read in by read.csv into matrices before adding them:

All_data <- lapply(filenames
,function(i){
###read cvs files and add the row and column names to each data frame
###
 as.matrix( read.csv(i, header=FALSE, sep = "", col.names = col_names, 
row.names = row_names)
})

result <- Reduce( `+`, All_data )

This will fail if any of the values in your csv files are non-numeric, but 
dealing with that would require us to know specifics about your files or intent 
that you have omitted. (The dput function is indispensable for clarifying such 
issues [1][2].)
---

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette)

[4] see "Introduction to R" (part of the R documentation)

-- 
Sent from my phone. Please excuse my brevity.

On January 15, 2018 1:29:05 AM PST, Alejandra Lopez-Galan 
 wrote:
>Hi, I am pretty new to R and I would apreciatte very much your help to
>solve my problem. I have 40 csv files that have the same structure, and
>I
>want to merge them into a single data frame.
>
>I already have load and combined all the cvs files into a large list,
>and I
>created two
>
>filenames <- list.files('data',full.names=TRUE)
>
>All_data <- lapply(filenames,function(i){
>###read cvs files and add the row and column names to each data
>frame###
> read.csv(i, header=FALSE, sep = "", col.names = col_names, row.names =
>row_names)
> })
>
>However I would like to sum the rows of cvs files to get a single data
>frame (each cvs file has 47 rows and colunms, so the final data frame
>should have the same). I could only do it one by one data data frame,
>but I
>was wondering if anyone could give an idea of how to write a function
>for
>this.
>
>Thanks,
>Alejandra
>
>   [[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-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] barplot that displays sums of values of 2 y colums grouped by different variables

2018-01-15 Thread Jeff Newmiller
It is not generally advisable to get too fancy with stat functions in 
ggplot... things can easily get more complicated than ggplot is ready to 
handle when it comes to calculations. It is better to create data that 
corresponds directly to the graphical representations you are mapping 
them to.


Read [1] for more on this philosophy.

[1] H. Wickham, Tidy Data, Journal of Statistical Software, vol. 59, no. 
10, pp. 123, Sep. 2014. http://www.jstatsoft.org/v59/i10/


#---
library(ggplot2) # ggplot
library(dplyr)   # `%>%`, group_by, summarise
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(tidyr)   # gather

dta <- read.table( text =
"city n y
mon 100 200
tor 209 300
edm 98 87
mon 20 76
tor 50 96
edm 62 27
", header = TRUE )

dta2 <- (   dta
%>% group_by( city )
%>% summarise( n = sum( n )
 , y = sum( y )
 )
%>% gather( Response, value, -city )
)

ggplot( dta2, aes( x=city, y=value, fill = Response ) ) +
geom_bar( stat="identity", position="dodge" )

#' ![](https://i.imgur.com/cosFf3B.png)
#---

On Mon, 15 Jan 2018, kenneth dyson wrote:

I am trying to create a barplot displaying the sums of 2 columns of data 
grouped by a variable. the data is set up like this:


"city" "n" "y" 
mon 100 200 
tor 209 300 
edm 98 87 
mon 20 76 
tor 50 96 
edm 62 27 

the resulting plot should have city as the x-axis, 2 bars per city, 1 
representing the sum of "n" in that city, the other the sum of "y" in that 
city.


If possible also show the sum in each bar as a label?

I aggregated the data into sums like this:

sum_data <- aggregate(. ~ City,data=raw_data,sum)

this gave me the sums per city as I wanted but for some reason 1 of the 
cities is missing in the output.


Using this code for the plot:

ggplot(sum_data,aes(x = City,y = n)) + geom_bar(aes(fill = y),stat = 
"identity",position = "dodge")


gave be a bar plot with one bar per city showing the sum of y as a color 
gradient. not what I expected given the "dodge" command in geom_bar.


Thanks.

__
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.



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

__
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] Steps to create spatial plots

2018-01-15 Thread Jeff Newmiller

Also note that there is an R-sig-geo mailing list dedicated to this topic.

You might also like to look at [1] for more on coordinate projections.

[1] 
https://www.nceas.ucsb.edu/~frazier/RSpatialGuides/OverviewCoordinateReferenceSystems.pdf

On Mon, 15 Jan 2018, Roman Lu?trik wrote:


You will need to coerce your data into a "spatial" kind, as implemented in
`sp` or as of late, `sf` packages. You might want to give the vignettes a
whirl before you proceed.
Roughly, you will have to coerce the data to Spatial* (you could go for a
point, raster or grid type, I think) and also specify the projection. Once
you have that, plotting should be handled by packages.

Here are a few quick links that might come handy:

https://cran.r-project.org/web/views/Spatial.html
http://www.datacarpentry.org/R-spatial-raster-vector-lesson/10-vector-csv-to-shapefile-in-r/


Cheers,
Roman

On Mon, Jan 15, 2018 at 11:22 PM, lily li  wrote:


Hi users,

I have no clear clue about plotting spatial data. For example, I just have
a table with attribute values of each grid cell, such as elevation. Then I
have coordinates of the upper left corner in UTM, the number of rows and
columns, and grid cell size. How to create spatial plot of elevations for
the grid cells, in color ramp? Should I create a spatial grid layer with
all the polygons first? Thanks.

--
--
You received this message because you are subscribed to the ggplot2
mailing list.
Please provide a reproducible example: https://github.com/hadley/
devtools/wiki/Reproducibility

To post: email ggpl...@googlegroups.com
To unsubscribe: email ggplot2+unsubscr...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups
"ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ggplot2+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.





--
In God we trust, all others bring data.

[[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.



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

__
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] flatpak installation package?

2018-01-16 Thread Jeff Newmiller
Of course... R _is_ open source. However, it is unwise to assume that the 
volunteers scratching itches for their preferred distros will take on 
additional work... it is more likely that you will need to take on scratching 
that new itch.
-- 
Sent from my phone. Please excuse my brevity.

On January 16, 2018 7:36:45 AM PST, Treutwein Bernhard 
 wrote:
>Is there any chance for a distribution independent flatpak installation
>package for R ?
>
>See: http://flatpak.org 
>
>Background: I recently bought an Acer notebook with endless OS
>preinstalled
>(see: http://endlessos.com).  It is Debian based, but uses only flatpak
>as installation
>package format.
>
>regards
>--
>  Bernhard Treutwein
>
>__
>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-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] error while loading ggplot2

2018-01-17 Thread Jeff Newmiller
Please post using plain text... the mailing list will strip HTML anyway and 
mess up what you send. 

Send the output of sessionInfo() so we know what versions of R and packages you 
have. 
-- 
Sent from my phone. Please excuse my brevity.

On January 17, 2018 4:37:06 PM PST, shijin mathew via R-help 
 wrote:
>Getting the following error while loading ggplot2.
>
>> library(ggplot2)
>Error: package or namespace load failed for ‘ggplot2’ in
>loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
> object 'vI' not found
>Tried different version of R and ggplot2 but still doesnt work.
>Any help to resolve is appreciated. Appreciate any pointers.
>-S
>
>   [[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-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] Time-dependent coefficients in a Cox model with categorical variants

2018-01-18 Thread Jeff Newmiller
Offlist... for your information...

It is unfair to suggest that the mailing list participants are at fault for 
using old software.  Even if the mailing list participants use email programs 
that can handle HTML, any email that goes through the list gets the formatting 
stripped, which leaves it damaged to some degree. It might not seem like this 
because sometimes you CAN see formatting, but that only happens when you are 
listed in the "To" or "Cc" fields... the rest of the list saw a stripped 
version regardless of how good their mail program was. Just go look at the 
archives to confirm this. Net result is the rest of the participants see a more 
or less damaged version of the discussion/code whenever HTML is used on list.
-- 
Sent from my phone. Please excuse my brevity.

On January 18, 2018 11:38:17 AM PST, "Therneau, Terry M., Ph.D." 
 wrote:
>
>First, as others have said please obey the mailing list rules and turn
>of
>First, as others have said please obey the mailing list rules and turn
>off html, not everyone uses an html email client.
>
>Here is your code, formatted and with line numbers added.  I also fixed
>one error: "y" should be "status".
>
>1. fit0 <- coxph(Surv(futime, status) ~ x1 + x2 + x3, data = data0)
>2. p <- log(predict(fit0, newdata = data1, type = "expected"))
>3. lp <- predict(fit0, newdata = data1, type = "lp")
>4. logbase <- p - lp
>5. fit1 <- glm(status ~ offset(p), family = poisson, data = data1)
>6. fit2 <- glm(status~ lp + offset(logbase), family = poisson, data =
>data1)
>7. group <- cut(lp, c(-Inf, quantile(lp, (1:9) / 10), Inf))
>8. fit3 <- glm(status ~ -1 + group + offset(p), family = poisson, data
>= data1)
>
>The key idea of the paper you referenced is that the counterpart to the
>Hosmer-Lemishow test (wrong if used directly in a Cox model) is to look
>at the predicted values from a Cox model as input to a Poisson
>regression.  That means adding the expected from the Cox model as a
>fixed term in the Poisson.  And like any other poisson that means
>offset(log(expected)) as a term.
>
>The presence of time dependent covariates does nothing to change this,
>per se, since expected for time fixed is the same as for time varying. 
>In practice it does matter, at least philosophically.  Lines 1, 2, 5 do
>this just fine.
>
>If data1 is not the same as data0, a new study say, then the test for
>intercept=0 from fit1 is a test of overall calibration.  Models like
>line 8 try to partition out where any differences actually lie.
>
>The time-dependent covariates part lies in the fact that a single
>subject may be represented by multiple lines in data0 and/or data1.  Do
>you want to collapse that person into a single row before the glm fits?
>If subject "Jones" is represented by 15 lines in the data and "Smith"
>by 2, it does seem a bit unfair to give Jones 15 observations in the
>glm fit.  But full discussion of this is as much philosophy as
>statistics, and is perhaps best done over a beer.
>
>Terry T.
>
>
>From: Max Shell [archerr...@gmail.com]
>Sent: Wednesday, January 17, 2018 10:25 AM
>To: Therneau, Terry M., Ph.D.
>Subject: Re: Time-dependent coefficients in a Cox model with
>categorical variants
>
>Assessing calibration of Cox model with time-dependent
>coefficients
>
>I am trying to find methods for testing and visualizing calibration to
>Cox models with time-depended coefficients. I have read your nice
>article. In
>this paper, we can fit three models:
>
>fit0 <- coxph(Surv(futime, status) ~ x1 + x2 + x3, data = data0) p <-
>log(predict(fit0, newdata = data1, type = "expected")) lp <-
>predict(fit0, newdata = data1, type = "lp") logbase <- p - lp fit1 <-
>glm(y ~ offset(p), family = poisson, data = data1) fit2 <- glm(y ~ lp +
>offset(logbase), family = poisson, data = data1) group <- cut(lp,
>c(-Inf, quantile(lp, (1:9) / 10), Inf)) fit3 <- glm(y ~ -1 + group +
>offset(p), family = poisson, data = data1)
>
>Here$B!$(BI simplely use data1$B!!(B<- data0[1:500,]
>
>First, I get following error when running line 5.
>
>Error in eval(predvars, data, env) : object 'y' not found
>
>So I modifited the code by replacing the y as status looks like this:
>
>fit1 <- glm(status ~ offset(p), family = poisson, data = data1) fit2 <-
>glm(status ~ lp + offset(logbase), family = poisson, data = data1)
>group <- cut(lp, c(-Inf, quantile(lp, (1:9) / 10), Inf)) fit3 <-
>glm(status ~ -1 + group + offset(p), family = poisson, data = data1)
>
>Is this replacing correct?
>
>Second, I try to introduce the time-transform use coxph with
>ttparament.
>
>My code is:  fit0 <- coxph(Surv(time, status) ~ x1 + x2 + x3 + tt(x3),
>data = data0, function(x, t, ...) x * t) p <- log(predict(fit0, newdata
>= data1, type = "expected")) lp <- predict(fit0, newdata = data1, type
>= "lp") logbase <- p - lp

Re: [R] Specification: Bi variate minimization problem

2018-01-20 Thread Jeff Newmiller
You probably ought to read the CRAN Optimization Task View. [1]

You should also read the Posting Guide mentioned at the bottom of every R-help 
email (e.g. no homework, use plain text email). You should also read some 
guides on asking questions online (e.g. [2][3][4]).

[1] https://cran.r-project.org/web/views/Optimization.html

[2] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[3] http://adv-r.had.co.nz/Reproducibility.html

[4] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette)
-- 
Sent from my phone. Please excuse my brevity.

On January 20, 2018 3:43:32 AM PST, BARLAS Marios 247554  
wrote:
>--- Version 2 of my problem improving the definition of
>what the optimal solution would be.
>Dear all,
>
>I'm working on the following problem:
>
>Assume two datasets: Y, Y that represent the same physical quantity Q.
>Dataset X contains values of Q after an event A while dataset Y
>contains values of Q after an event B.
>
>In R X, Y are vectors of the same length, containing effectivelly a
>number of observations of Q in each state.
>
>Q is a continous variable.
>
>Now, the two datasets should ideally not have any range of overlapping
>values. That is
>
>max(x) << min (Y)
>
>but that is not the reality of the problem. there are usually overlaps,
>bigger or smaller.
>
>Now, what I want to do is the following:
>
>Suppose that we choose a value P so that.
>
>Any X <= P is understood as belonging to group X while
>any Y > P is understood as belonging to group Y.
>
>now any values of X > P or of Y <= P are wrongly understood as
>belonging to Y nad X effectively.
>
>Hence we have Xerr -- > Sum( X >P) and Yerror --> Sum(Y<=P).
>
>I want to solve this bivariate optimization problem where I want to at
>the same time minimize the error of X and Y for a given P. Ultimately
>the target is to optimize the value of P so that the errors of both X
>and Y are optimized. More specifically, the optimal solution is one
>where
>
>1. The total error (Xerr + Yerr) is minimized
>2. The values or Xerr and Yerr are balanced as much as possible,
>probably.
>
>Does any1 have some functions in mind that can help with parts of this
>problem ? It's not impossible to write the algorithm but it will take
>time and things like convergence and robustness need to be checked
>!
>
>thank you for your help.
>
>Best regards,
>Marios Barlas
>
>   [[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-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] Scraping from different level URLs website

2018-01-23 Thread Jeff Newmiller
They seem to release their data in xml and csv formats also... why are you 
scraping? 
-- 
Sent from my phone. Please excuse my brevity.

On January 23, 2018 9:31:01 AM PST, Ilio Fornasero  
wrote:
>I am doing a research on World Bank (WB) projects on developing
>countries. To do so, I am scraping their website in order to collect
>the data I am interested in.
>
>The structure of the webpage I want to scrape is the following:
>
>1.  List of countries the list of all countries in which WB has
>developed projects
>
>1.1. By clicking on a single country on 1. , one gets the single
>countries project list (that includes many webpages) it includes all
>the projects in a single countries
>
>. Of course, here I have included just one page of a single countries,
>but every country has a number of pages dedicated to this subject
>
>1.1.1. By clicking on a a single project on 1.1. , one gets - among the
>others - the project's overview
>option I
>am interested in.
>
>In other words, my problem is to find out a way to create a dataframe
>including all the countries, a complete list of all projects for each
>country and an overview of any single project.
>
>
>Yet, this is the code that I have (unsuccessfully) written:
>
>WB_links <-
>"http://projects.worldbank.org/country?lang=en&page=projects";
>
> WB_proj <- function(x) {
>
>  Sys.sleep(5)
>url <-
>sprintf("http://projects.worldbank.org/search?lang=en&searchTerm=&countrycode_exact=%s";,
>x)
>
> html <- read_html(url)
>
>tibble(title = html_nodes(html, ".grid_20") %>% html_text(trim = TRUE),
> project_url = html_nodes(html, ".grid_20") %>% html_attr("href"))
>}
>
> WB_scrape <- map_df(1:5, WB_proj) %>%
> mutate(study_description =
>   map(project_url,
>   ~read_html(sprintf
>("http://projects.worldbank.org/search?lang=en&searchTerm=&countrycode_exact=%s";,
>.x)) %>%
>html_node() %>%
>html_text()))
>
>
>Any suggestion?
>
>Note: I am sorry if this question seems trivial, but I am quite a
>newbie in R and I haven't found a help on this by looking around
>(though I could have missed something, of course).
>
>
>   [[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-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] Newbie - Scrape Data From PDFs?

2018-01-24 Thread Jeff Newmiller
And a warning to the OP... PDF files are like packages a wide variety of 
things can be inside, including text in semi-random order, or bitmap images of 
text... so having a tool that extracts text from the file will only be of use 
if your PDF files happen to be of the type that contain reasonably unscrambled  
text.
-- 
Sent from my phone. Please excuse my brevity.

On January 23, 2018 11:35:38 PM PST, Ulrik Stervbo  
wrote:
>I think I would use pdftk to extract the form data. All subsequent
>manipulation in R.
>
>HTH
>Ulrik
>
>Eric Berger  schrieb am Mi., 24. Jan. 2018,
>08:11:
>
>> Hi Scott,
>> I have never done this myself but I read something recently on the
>> r-help distribution that was related.
>> I just did a quick search and found a few hits that might work for
>you.
>>
>> 1.
>>
>https://medium.com/@CharlesBordet/how-to-extract-and-clean-data-from-pdf-files-in-r-da11964e252e
>> 2. http://bxhorn.com/2016/extract-data-tables-from-pdf-files-in-r/
>> 3.
>>
>https://www.rdocumentation.org/packages/textreadr/versions/0.7.0/topics/read_pdf
>>
>> HTH,
>> Eric
>>
>> On Wed, Jan 24, 2018 at 3:58 AM, Scott Clausen 
>> wrote:
>> > Hello,
>> >
>> > I’m new to R and am using it with RStudio to learn the language.
>I’m
>> doing so as I have quite a lot of traffic data I would like to
>explore. My
>> problem is that all the data is located on a number of PDFs. Can
>someone
>> point me to info on gathering data from other sources? I’ve been to
>the R
>> FAQ and didn’t see anything and would appreciate your thoughts.
>> >
>> >  I am quite sure now that often, very often, in matters concerning
>> religion and politics a man's reasoning powers are not above the
>monkey's.
>> >
>> > -- Mark Twain
>> >
>> > __
>> > 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-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-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] Function gutenberg_download in the gutenbergr package

2018-01-24 Thread Jeff Newmiller
I have never used that package, but it seems obvious to me that you need to 
"reflect" on the meaning of the word "mirror". There is no reason to assume 
that a site hosting a mirror of the CRAN archive is also going to host a mirror 
of Project Gutenberg [1].

If, after you know you are giving reasonable inputs the package does not seem 
to work as designed, please remember that contributed packages have maintainers 
[2] and not all of them subscribe to r-help.

[1] https://www.gutenberg.org/MIRRORS.ALL
[2] ?maintainer
-- 
Sent from my phone. Please excuse my brevity.

On January 23, 2018 11:23:06 PM PST, Patrick Connolly 
 wrote:
>
>I've been working through https://www.tidytextmining.com/tidytext.html
>wherein everything worked until I got to this part in section 1.5
>
>> hgwells <- gutenberg_download(c(35, 36, 5230, 159))
>Determining mirror for Project Gutenberg from
>http://www.gutenberg.org/robot/harvest
>Error in open.connection(con, "rb") : 
>  Failed to connect to www.gutenberg.org port 80: Connection timed out
>
>Which indicates the problem is at the very start:
>
>  if (is.null(mirror)) {
>mirror <- gutenberg_get_mirror(verbose = verbose)
>  }
>
>The documentation for gutenberg_get_mirror indicates there's nothing
>different I could set.
>
>So I tried specifying my usual mirror:
>
>> hgwells <- gutenberg_download(c(1260, 768, 969, 9182, 767), mirror =
>"http://cran.stat.auckland.ac.nz";)
>Error in read_zip_url(full_url) : could not find function
>"read_zip_url"
>> 
>
>Which is, indeed, strange since according to 
>
>> help.search("read_zip_url")
>Help files with alias or concept or title matching ‘read_zip_url’ using
>regular expression matching:
>
>
>gutenbergr::read_zip_url
>Read a file from a .zip URL
>  Aliases: read_zip_url
>
>[...]
>
>And according to 
>library(help = "gutenbergr")
>
>[...]
>Index:
>
>gutenberg_authors   Metadata about Project Gutenberg authors
>gutenberg_download  Download one or more works using a Project
>Gutenberg ID
>gutenberg_get_mirrorGet the recommended mirror for Gutenberg files
>gutenberg_metadata  Gutenberg metadata about each work
>gutenberg_strip Strip header and footer content from a Project
>Gutenberg book
>gutenberg_subjects  Gutenberg metadata about the subject of each
>work
>gutenberg_works Get a filtered table of Gutenberg work metadata
>read_zip_urlRead a file from a .zip URL
>
>[...]
>
>However, when I look at the list for that part of the search(), there
>is no read_zip_url but all the rest of that list are present.  So it's
>not surprising that it isn't found.  But it puzzles me that it is not
>there.
>
>Ideas as to where I should proceed gratefully appreciated.
>
>
>> sessionInfo()
>R version 3.4.2 (2017-09-28)
>Platform: x86_64-pc-linux-gnu (64-bit)
>Running under: Ubuntu 14.04.5 LTS
>
>Matrix products: default
>BLAS: /home/hrapgc/local/R-3.4.2/lib/libRblas.so
>LAPACK: /home/hrapgc/local/R-3.4.2/lib/libRlapack.so
>
>locale:
> [1] LC_CTYPE=en_NZ.UTF-8   LC_NUMERIC=C  
> [3] LC_TIME=en_NZ.UTF-8LC_COLLATE=en_NZ.UTF-8
> [5] LC_MONETARY=en_NZ.UTF-8LC_MESSAGES=en_NZ.UTF-8   
> [7] LC_PAPER=en_NZ.UTF-8   LC_NAME=C 
> [9] LC_ADDRESS=C   LC_TELEPHONE=C
>[11] LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C   
>
>attached base packages:
>[1] grDevices utils stats graphics  methods   base 
>
>other attached packages:
>[1] sos_2.0-0  brew_1.0-6 gutenbergr_0.1.3  
>ggplot2_2.2.1 
>[5] stringr_1.2.0  bindrcpp_0.2   dplyr_0.7.4   
>janeaustenr_0.1.5 
>[9] tidytext_0.1.6 FactoMineR_1.38readxl_1.0.0   tm_0.7-3  
>   
>[13] NLP_0.1-11 wordcloud_2.5  RColorBrewer_1.1-2
>lattice_0.20-35   
>
>loaded via a namespace (and not attached):
> [1] Rcpp_0.12.13 cellranger_1.1.0 compiler_3.4.2  
> [4] plyr_1.8.4   bindr_0.1tokenizers_0.1.4
> [7] tools_3.4.2  gtable_0.2.0 tibble_1.3.4
>[10] nlme_3.1-131 pkgconfig_2.0.1  rlang_0.1.2 
>[13] Matrix_1.2-11psych_1.7.8  curl_3.0
>[16] parallel_3.4.2   xml2_1.1.1   cluster_2.0.6   
>[19] hms_0.3  flashClust_1.01-2grid_3.4.2  
>[22] scatterplot3d_0.3-40 glue_1.1.1   ellipse_0.3-8   
>[25] R6_2.2.2 foreign_0.8-69   readr_1.1.1 
>[28] purrr_0.2.4  tidyr_0.7.2  reshape2_1.4.2  
>[31] magrittr_1.5 scales_0.5.0 SnowballC_0.5.1 
>[34] MASS_7.3-47  leaps_3.0assertthat_0.2.0
>[37] mnormt_1.5-5 colorspace_1.3-2 labeling_0.3
>[40] stringi_1.1.5lazyeval_0.2.1   munsell_0.4.3   
>[43] slam_0.1-42  broom_0.4.2 
>> 
>
>-- 
>~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

Re: [R] Geometry delaunayn and deldir results, differing results from Octave due to decimal precision?

2018-01-24 Thread Jeff Newmiller
, the results are identical with the exception of ordering.

*However* when I use a slightly larger set of data for input,
"geometry.delaunayn" and "deldir.deldir" seems to give results that are off
by one in a lot of instances.
The input for the Delaunay function has been exported from Octave to 9
d.p. and then imported into R by using the "foreign" package.

Example data is on the following link. It is a set of variables exported
from Octave 'x y tri xiflat yiflat tri_list.mat'
https://pastebin.com/xELkj6r6

the variable tri_list is just the tri_list = 
search(x,y,tri_deldir,xiflat,yiflat)
in Octave


The command history is a as follows:
library(deldir)
library(geometry)
library(foreign)
theData <- read.octave('x y tri xiflat yiflat tri_list.mat')
options(digits = 10)
x <- unlist(theData[1])
y <- unlist(theData[3])
tri_deldir <- triMat(deldir(x,y))
tri_delaunayn <- delaunayn(x,y)
tri_delaunayn <- delaunayn(cbind(x,y))
tri_list_from_deldir <- tsearch(x,y,tri_deldir,xiflat,yiflat)
xiflat <- unlist(theData[7])
yiflat <- unlist(theData[9])
tri_list_from_deldir <- tsearch(x,y,tri_deldir,xiflat,yiflat)
tri_list_from_delaunayn <- tsearch(x,y,tri_delaunayn,xiflat,yiflat)


Kam Yuen
Software Developer
T +44 (0)1491 820634| F +44 (0)1491 820599
k.y...@fugro.com<mailto:k.y...@fugro.com> | www.fugro.com<http://www.
fugro.com/>
Fugro GB Marine Limited
Fugro House, Hithercroft Road, Wallingford, Oxfordshire OX10 9RB, UK
Registration No: 1135456 | VAT No: GB 579 3459 84


[[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.



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

__
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] Issue with concatenation of URL losing

2018-01-24 Thread Jeff Newmiller
a) you need to read the help pages on the paste function... more likely 
you are looking for the paste0 function because extra spaces will most 
likely break the GET request format.


b) quotes do not become "stuck" as \" ... that is a visual representation 
intended to clarify that that quote is not terminating the string but is 
actually part of it. If you want to see the contents of the string without 
the escaping, use the cat function instead of depending on the default 
print behavior (which shows the escape characters).


c) The format of the GET request string includes parameter identifiers 
"lat" and "lon"... don't get confused between those strings being sent to 
the webserver and what your variables are called. Also, following those 
strings and a colon are numeric values... those are what you need to 
replace. Your attempt did not remove the literal digits from the 
surrounding strings.


d) You really need to post plain text as the Posting Guide warns you... 
your code was getting contaminated by the mailing list "fixing" this 
mistake on your part. This may completely obstruct your meaning in future 
questions, and only you can avoid this by using your email software 
properly.



lat <- 40.7
lon <- -76.5
tstring1 <- 
"https://elevation.mapzen.com/height?json={\"range\":false,\"shape\":[{\"lat\":40.7,\"lon\":-76.5}]}&api_key=mycode";

cat( tstring1, "\n" ) # output on its own line
#> 
https://elevation.mapzen.com/height?json={"range":false,"shape":[{"lat":40.7,"lon":-76.5}]}&api_key=mycode
tstring2 <- paste0( 
"https://elevation.mapzen.com/height?json={\"range\":false,\"shape\":[{\"lat\":",lat,",\"lon\":",lon,"}]}&api_key=mycode";
 )
tstring1 == tstring2 # confirm results are the same
#> [1] TRUE
lat <- 10
lon <- 20
tstring3 <- paste0( 
"https://elevation.mapzen.com/height?json={\"range\":false,\"shape\":[{\"lat\":",lat,",\"lon\":",lon,"}]}&api_key=mycode";
 )
cat( tstring3, "\n" ) # output on its own line
#> 
https://elevation.mapzen.com/height?json={"range":false,"shape":[{"lat":10,"lon":20}]}&api_key=mycode


On Wed, 24 Jan 2018, Oliver Morris wrote:


Thank you for your help in advance.


I am trying to pull some data back from a web service


library(httr)
sample2 <- 
GET("https://elevation.mapzen.com/height?json={\"range\":false,\"shape\":[{\"lat\":40.7,\"lon\":-76.5}]}&api_key=mycode";)
result2 <- content(sample2)
height <- result2$height[[1]]


I would like to put by own latitude and longitude in but alas when I use 
paste() to combine the double quotes become stuck as literally \"



lat <-10

long <20

library(httr)
sample2 <- GET(paste("https://elevation.mapzen.com/height?json={\"range\":false,\"shape\":[{\";, lat , 
\":40.7,\", long,\":-76.5}]}&api_key=mycode"))
result2 <- content(sample2)
height <- result2$height[[1]]


Can you please suggest a way around this, it has been driving me mad!


Thank you so much.


Oliver

[[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.



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

__
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] Portable R in zip file for Windows

2018-01-24 Thread Jeff Newmiller
I have never used it, but Google sez look here [1]. You should learn to speak 
Google also.

[1] https://sourceforge.net/projects/rportable/
-- 
Sent from my phone. Please excuse my brevity.

On January 24, 2018 7:11:49 PM PST, Juan Manuel Truppia  
wrote:
>I read a message from 2009 or 2010 where it mentioned the availability
>of R
>for Windows in a zip file, no installation required. It would be very
>useful for me. Is this still available somewhere?
>
>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-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] Problem saving .RData file with save.image

2018-01-26 Thread Jeff Newmiller
Google is your friend (e.g. [1]). Gist of story is that that an existing file 
of that name is being "protected" by the operating system and you need to use 
filesystem utilities or reboot your machine to release the existing file from 
this condition. 

[1] https://stat.ethz.ch/pipermail/r-help/2002-April/020169.html
-- 
Sent from my phone. Please excuse my brevity.

On January 26, 2018 12:27:55 AM PST, Steven Yen  wrote:
>I am running R-3.0.3 on RStudio 1.1.183. I have recently gotten the
>following error message while saving an .RData file with the save.image
>command. I have not had this problem until recently. Help appreciated.
>
>===
>Error in save.image("bope1a.RData") :
>   image could not be renamed and is left in bope1a.RDataTmp
>
>
>   [[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-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] Add ablines

2018-01-29 Thread Jeff Newmiller
A) Without your data, it is very difficult to see what your problem is. You 
need to include both data and code to create a reproducible example. [1][2][3]

B) Please follow the guidance in the Posting Guide mentioned in the footer of 
every message on this list; in particular note that this is a plain text 
mailing list and your message will be damaged to some unpredictable extent if 
you don't set your email program correctly. 

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette)
-- 
Sent from my phone. Please excuse my brevity.

On January 29, 2018 3:49:45 AM PST, "a.antonini...@hotmail.com" 
 wrote:
>Good morning,
>I have some problem adding ablines in Rstudio.
>The lines drew by the software doesen�t match with the added values,
>what can I do?
>
>pfaOK<-qcc(D[!trial], sizes=size[!trial], type="p", nsigmas=2,
>data.name="Polli positivi al Campylobacter")
>pfaOK1<-qcc(D[!trial], sizes=size[!trial], type="p", data.name="Polli
>positivi al Campylobacter")
>
>abline(h=pfaOK$limits[1], lty=1, col="red")
>abline(h=pfaOK$limits[2], lty=1, col="red")
>
>abline(h=0.02204175, col="red")
>abline(h=0.1996249, col="red")
>
>abline(h=2.204175, col="red")
>abline(h=19.96249, col="red")
>
>Thanks for the attention,
>   Arianna
>
>Inviato da Posta per
>Windows 10
>
>
>   [[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] variable names in lm formula ~.

2018-01-30 Thread Jeff Newmiller
Functions are first class objects, so some kind of collision is bound to happen 
if you do this... so don't. 
-- 
Sent from my phone. Please excuse my brevity.

On January 30, 2018 3:11:56 AM PST, "Vito M. R. Muggeo"  
wrote:
>dear all,
>Is the following intentional? Am I missing anything in documentation?
>
>d<-data.frame(y=rnorm(10,5,.5),exp=rnorm(10), age=rnorm(10))
>formula(lm(exp(y)~exp+age, data=d))
>#--> exp(y) ~ exp + age
>
>formula(lm(exp(y)~., data=d))
>#--> exp(y) ~ age
>
>variable 'exp' (maybe indicating "experience") is not included in the 
>model. The same happens with 'log' (and other function names, I
>suppose..)
>
>best,
>vito

__
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] Calculating angle of a polyline

2018-01-30 Thread Jeff Newmiller
A polyline by definition has many angles, so your question is ill-formed. And 
this is a question about math, not R, so is off topic here. I suggest reading 
Wikipedia.
-- 
Sent from my phone. Please excuse my brevity.

On January 29, 2018 11:10:02 PM PST, javad bayat  wrote:
>Dear R users
>I am trying to find a formula to calculate the angle of a polyline. Is
>there a way to do this?
>Many thanks.

__
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] Problems with "predict" function ii

2018-01-31 Thread Jeff Newmiller
This is the kind of thing that leads experienced R users to avoid attach for 
data analysis. Read "The R Inferno".

Use the "data" argument to lm, and the "newdata" argument to predict.lm.
-- 
Sent from my phone. Please excuse my brevity.

On January 31, 2018 9:20:10 AM PST, WRAY NICHOLAS via R-help 
 wrote:
>I  have realised that I should have used "detach" before attaching
>another
>dataframe, but even when I do this it's still giving me lots of lines,
>rather
>than just one:
>
>My code:
>
>
>m<-runif(1,0,1)
>m
>mres<-m*(seq(1,12))
>mres
>ssd<-rexp(1,1)
>ssd
>devs<-rep(0,length(mres))
>for(i in 1:length(mres)){devs[i]<-rnorm(1,0,ssd)}
>devs
>plot(-10,-10,xlim=c(1,24),ylim=c(0,2))
>sales<-round((mres+devs)*1000)
>
>points(sales,pch=19)
>
>ptr<-cbind(1:length(sales),sales,sales,sales)
>
>ptr
>sdf<-data.frame(cbind(1:nrow(ptr),sales))
>sdf
>
>colnames(sdf)<-c(“monat”,“mitte”)
>sdf
>attach(sdf)
>s.lm<-lm(mitte~monat)
>
>s.lm
>abline(s.lm,lty=2)
>news<-data.frame(monat=nrow(sdf)+1)
>news
>fcs<-predict(s.lm,news,interval=“predict”)
>fcs
>
>points(1+nrow(ptr),fcs[,1],col=“grey”,pch=19)
>points(1+nrow(ptr),fcs[,2])
>points(1+nrow(ptr),fcs[,3])
>ptr<-rbind(ptr,c(1+nrow(ptr),fcs[2],fcs[1],fcs[3]))
>ptr
>
>highdf<-data.frame(ptr[,c(1,4)])
>highdf
>colnames(highdf)<-c(“month”,“sales”)
>highdf
>detach(sdf)
>attach(highdf)
>h.lm<-lm(highdf[,2]~highdf[,1])
>h.lm
>abline(h.lm,col="gray",lty=2)
>news<-data.frame(month=nrow(ptr)+1)
>news
>hcs<-predict(h.lm,news,interval=“predict”)
>hcs
>   [[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-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] Error while working with png output on linux server

2018-02-01 Thread Jeff Newmiller
FAQ 7.19?

Also, read the Posting Guide, in particular about posting using plain text. 
-- 
Sent from my phone. Please excuse my brevity.

On February 1, 2018 6:50:42 AM PST, "Sariya, Sanjeev" 
 wrote:
>I'm working on linux server:
>Linux  4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64
>GNU/Linux
>
>I get error while creating png files. I'm sharing my commands and error
>while I run those commands:
>
>>png("abc", type="cairo")
>Error in .External2(C_X11, paste0("png::", filename), g$width,
>g$height,  :
>  unable to start device PNG
>In addition: Warning message:
>In png("abc", type = "cairo") : unable to open connection to X11
>display ''
>
>> png("apoeqqplot.png", res=600)
>Error in .External2(C_X11, paste0("png::", filename), g$width,
>g$height,  :
>  unable to start device PNG
>In addition: Warning message:
>In png("apoeqqplot.png", res = 600) :
>  unable to open connection to X11 display ''
>
>dev.off()
>
>R version 3.4.2 (2017-09-28)
>Platform: x86_64-pc-linux-gnu (64-bit)
>Running under: Debian GNU/Linux 9 (stretch)
>
>Matrix products: default
>BLAS: /mnt/mfs/cluster/bin/R-3.4/lib/libRblas.so
>LAPACK: /mnt/mfs/cluster/bin/R-3.4/lib/libRlapack.so
>
>locale:
>[1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
>[3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
>[5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
>[7] LC_PAPER=en_US.UTF-8   LC_NAME=C
>[9] LC_ADDRESS=C   LC_TELEPHONE=C
>[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
>attached base packages:
>[1] stats graphics  grDevices utils datasets  methods   base
>
>other attached packages:
>[1] CMplot_3.3.1
>
>loaded via a namespace (and not attached):
>[1] compiler_3.4.2 tools_3.4.2
>
>
>How do I fix this?
>
>
>   [[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-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] Error while working with png output on linux server

2018-02-01 Thread Jeff Newmiller
This is not an R issue so this is not a good venue... it has to do with which 
support software you have (not) installed. Try the R-sig-debian mailing list. 
Please clarify to them how you installed R... for Debian there are relevant deb 
packages and a corresponding Debian repository that provide the simplest route 
to a working system, but if you compile it yourself it is easy to miss 
dependencies.
-- 
Sent from my phone. Please excuse my brevity.

On February 1, 2018 8:23:13 AM PST, "Sariya, Sanjeev" 
 wrote:
>Thanks for your reply. I searched for the error on Google before
>resorting to the R forum (help group).
>I tried Sys.env(...) too, but didn't resolve the error I get. Hence I
>am looking for solution.
>
>
> 
>--
>
>
>-Original Message-
>From: Thierry Onkelinx [mailto:thierry.onkel...@inbo.be] 
>Sent: Thursday, February 01, 2018 10:57 AM
>To: Sariya, Sanjeev 
>Cc: Jeff Newmiller ; r-help@r-project.org
>Subject: Re: [R] Error while working with png output on linux server
>
>Dear Sanjeev,
>
>It seems that you system neither supports X11 devices nor cairo
>devices. See http://lmgtfy.com/?q=R+unable+to+open+connection+to+X11
>for possible solutions.
>
>Best regards,
>
>ir. Thierry Onkelinx
>Statisticus / Statistician
>
>Vlaamse Overheid / Government of Flanders INSTITUUT VOOR NATUUR- EN
>BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND FOREST Team Biometrie
>& Kwaliteitszorg / Team Biometrics & Quality Assurance
>thierry.onkel...@inbo.be Havenlaan 88 bus 73, 1000 Brussel www.inbo.be
>
>///
>To call in the statistician after the experiment is done may be no more
>than asking him to perform a post-mortem examination: he may be able to
>say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural
>of anecdote is not data. ~ Roger Brinner The combination of some data
>and an aching desire for an answer does not ensure that a reasonable
>answer can be extracted from a given body of data. ~ John Tukey
>///
>
>
>
>
>2018-02-01 16:18 GMT+01:00 Sariya, Sanjeev :
>> Thanks for pointing to FAQ: I tried with cairo (shared in commands),
>unfortunately didn't work.
>>
>> --
>> Sanjeev Sariya
>>
>>
>> -Original Message-
>> From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
>> Sent: Thursday, February 01, 2018 10:12 AM
>> To: r-help@r-project.org; Sariya, Sanjeev ;
>
>> r-help@r-project.org
>> Subject: Re: [R] Error while working with png output on linux server
>>
>> FAQ 7.19?
>>
>> Also, read the Posting Guide, in particular about posting using plain
>text.
>> --
>> Sent from my phone. Please excuse my brevity.
>>
>> On February 1, 2018 6:50:42 AM PST, "Sariya, Sanjeev"
> wrote:
>>>I'm working on linux server:
>>>Linux  4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64 
>>>GNU/Linux
>>>
>>>I get error while creating png files. I'm sharing my commands and 
>>>error while I run those commands:
>>>
>>>>png("abc", type="cairo")
>>>Error in .External2(C_X11, paste0("png::", filename), g$width, 
>>>g$height,  :
>>>  unable to start device PNG
>>>In addition: Warning message:
>>>In png("abc", type = "cairo") : unable to open connection to X11 
>>>display ''
>>>
>>>> png("apoeqqplot.png", res=600)
>>>Error in .External2(C_X11, paste0("png::", filename), g$width, 
>>>g$height,  :
>>>  unable to start device PNG
>>>In addition: Warning message:
>>>In png("apoeqqplot.png", res = 600) :
>>>  unable to open connection to X11 display ''
>>>
>>>dev.off()
>>>
>>>R version 3.4.2 (2017-09-28)
>>>Platform: x86_64-pc-linux-gnu (64-bit) Running under: Debian
>GNU/Linux 
>>>9 (stretch)
>>>
>>>Matrix products: default
>>>BLAS: /mnt/mfs/cluster/bin/R-3.4/lib/libRblas.so
>>>LAPACK: /mnt/mfs/cluster/bin/R-3.4/lib/libRlapack.so
>>>
>>>locale:
>>>[1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
>>>[3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
>>>[5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
>>>[7] LC_PAPER=en_US.UTF-8   LC_NAME=C
>>>[9] LC_ADDRESS=C   LC_TELEPHONE=C
>>>[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>>>

Re: [R] Data Table Merge Help

2018-02-01 Thread Jeff Newmiller
I rarely use data.table, but I think the vignette for the package discusses 
rolling joins. Also,  Google popped up [1].

[1] https://www.r-bloggers.com/understanding-data-table-rolling-joins/
-- 
Sent from my phone. Please excuse my brevity.

On February 1, 2018 9:45:53 AM PST, "Graeve, Nick"  
wrote:
>Hello
>
>I'm not sure if this is an appropriate use of this mailing list or not,
>please let me know if it isn't.  I'm struggling to figure out how to
>merge two data tables based on max effective date logic compared to
>when a payment occurred.  My dtDistributions DT is a transactional
>dataset while dtDepartments is a domain data set containing all
>department names and the effective date of when department name changes
>have occurred.  For the Bob example below, there was a payment on
>2016-01-01 which occurred in H229000.  In 2012, this department was
>named "Modified Name", in 2019 the department will be named "Final
>Name".  When I merge these two tables, I'd like it to pull the
>transactional data and match it up to department name "Modified Name"
>since that was the active department name at the time of that
>transaction.  I've read documentation on foverlaps, but I'm not sure if
>this problem is considered a range of dates or not.  At the bottom of
>this post is a temporarily solution that is working but it runs for a
>long time due to the amount of data in my actual source.
>
>Here is some sample data to get started:
>library(data.table)
>dtDistributions <- data.table(PayeeName = c("Bob", "Tracy", "Tom"),
>  Department = factor(c("H229000", "H135000",
>"H047800")),
>  Amount = c(5, 34, 87),
>  PaymentDT = as.Date(c("2016-01-01",
>"2015-01-01", "2015-01-01")))
>
>dtDepartments <- data.table(Department = factor(c("H229000", "H229000",
>"H229000", "H135000", "H047800")),
>    EffDT = as.Date(c("2019-01-01", "2012-01-01",
>"1901-01-01", "1901-01-01", "1901-01-01")),
>    Descr = c("Final Name","Modified
>Name","Original Name","Payables","Postal"))
>
>Here is the output I would like to see:
>PayeeName  Department PaymentDT   Amount
>Bob    Modified Name  2016-01-01  5
>Tracy  Payables   2015-01-01  34
>Tom    Postal     2015-01-01  87
>
>I was able to get this working by using the sqldf library, but it runs
>for a very long time in my actual dataset and I'd like to use
>data.table if at all possible.
>library(sqldf)
>joinString <- "SELECT A.PayeeName, B.Descr, A.PaymentDT, A.Amount
>    FROM dtDistributions A, dtDepartments B
>    WHERE A.DEPARTMENT = B.Department
>    AND B.EffDT = (SELECT MAX(ED.EffDT)
>    FROM dtDepartments ED
>    WHERE B.Department = ED.Department
>    AND ED.EffDT <= A.PaymentDT)"
>
>finalDT <- data.table(sqldf(joinString))
>
>
>
>-Message Disclaimer-
>
>This e-mail message is intended only for the use of the individual or
>entity to which it is addressed, and may contain information that is
>privileged, confidential and exempt from disclosure under applicable
>law. If you are not the intended recipient, any dissemination,
>distribution or copying of this communication is strictly prohibited.
>If you have received this communication in error, please notify us
>immediately by reply email to conn...@principal.com and delete or
>destroy all copies of the original message and attachments thereto.
>Email sent to or from the Principal Financial Group or any of its
>member companies may be retained as required by law or regulation.
>
>Nothing in this message is intended to constitute an Electronic
>signature for purposes of the Uniform Electronic Transactions Act
>(UETA) or the Electronic Signatures in Global and National Commerce Act
>("E-Sign") unless a specific statement to the contrary is included in
>this message.
>
>If you no longer wish to receive any further solicitation from the
>Principal Financial Group you may unsubscribe at
>https://www.principal.com/do-not-contact-form any time.
>
>If you are a Canadian resident and no longer wish to receive commercial
>electronic messages you may unsubscribe at
>https://www.principal.com/do-not-email-request-canadian-residents any
>time.
>
>
>
>
>
>This message was secured by Zix(R).
>
>__
>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-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] Updating Rcpp package when it is claimed by dplyr

2018-02-01 Thread Jeff Newmiller
Your last statement is extremely unlikely to be true. The dplyr package should 
not be present in a vanilla environment, so there should be no such conflict. 
-- 
Sent from my phone. Please excuse my brevity.

On February 1, 2018 11:00:01 PM PST, Patrick Connolly 
 wrote:
>When i  tried to install the hunspell package, I got this error
>message:
>
>Error: package ‘Rcpp’ 0.12.3 was found, but >= 0.12.12 is required by
>‘hunspell’
>
>So I set about installing a new version of Rcpp but I get this message:
>
>Error in unloadNamespace(pkg_name) : 
>  namespace ‘Rcpp’ is imported by ‘dplyr’ so cannot be unloaded
>
>How does one get around that?  I tried installing Rcpp in a vanilla
>session but the result was the same.
>
>TIA
>Patrick
>
>
>> sessionInfo()
>R version 3.4.3 (2017-11-30)
>Platform: x86_64-pc-linux-gnu (64-bit)
>Running under: Ubuntu 14.04.5 LTS
>
>Matrix products: default
>BLAS: /home/pat/local/R-3.4.3/lib/libRblas.so
>LAPACK: /home/pat/local/R-3.4.3/lib/libRlapack.so
>
>locale:
> [1] LC_CTYPE=en_NZ.UTF-8   LC_NUMERIC=C  
> [3] LC_TIME=en_NZ.UTF-8LC_COLLATE=en_NZ.UTF-8
> [5] LC_MONETARY=en_NZ.UTF-8LC_MESSAGES=en_NZ.UTF-8   
> [7] LC_PAPER=en_NZ.UTF-8   LC_NAME=C 
> [9] LC_ADDRESS=C   LC_TELEPHONE=C
>[11] LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C   
>
>attached base packages:
>[1] utils stats grDevices graphics  methods   base 
>
>other attached packages:
>[1] lattice_0.20-35
>
>loaded via a namespace (and not attached):
>[1] compiler_3.4.3 magrittr_1.5   R6_2.1.2   assertthat_0.1
>parallel_3.4.3
>[6] tools_3.4.3DBI_0.3.1  dplyr_0.4.3Rcpp_0.12.3   
>grid_3.4.3
>
>
>-- 
>~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>  
>   ___Patrick Connolly   
> {~._.~}   Great minds discuss ideas
> _( Y )_Average minds discuss events 
>(:_~*~_:)  Small minds discuss people  
> (_)-(_) . Eleanor Roosevelt
> 
>~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>
>__
>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-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] Updating Rcpp package when it is claimed by dplyr

2018-02-02 Thread Jeff Newmiller
Be sure to not put a space between the "---" and the "vanilla".
-- 
Sent from my phone. Please excuse my brevity.

On February 2, 2018 1:35:07 PM PST, Patrick Connolly 
 wrote:
>On Fri, 02-Feb-2018 at 10:25AM +0100, peter dalgaard wrote:
>
>|> Or, to avoid accusing you of lying. what you think is "vanilla"
>|> probably isn't. What exactly did you do? On Unix-likes, I would do
>|> something like this
>
>|> echo
>'options(repos=list(CRAN="cran.r-project.org"));install.packages("Rcpp")'
>| R --vanilla
>|> 
>|> (or maybe https://cloud.r-project.org is better...)
>
>Thanks for the suggestion.  
>
>I simply did 
>R -- vanilla
>
>I tried it again this morning so that I could compare the output.
>However, it *worked* fine -- just as I thought it would done
>yesterday.  Why it didn't work yesterday is a mystery.
>
>I've had a few other things behaving strangely on this machine so
>there might be an OS issue, not an R issue.
>
>Thanks for taking the time.
>
>Patrick
>
>|> 
>|> -pd
>|> 
>|> 
>|> 
>|> > On 2 Feb 2018, at 08:15 , Jeff Newmiller
> wrote:
>|> > 
>|> > Your last statement is extremely unlikely to be true. The dplyr
>package should not be present in a vanilla environment, so there should
>be no such conflict. 
>|> > -- 
>|> > Sent from my phone. Please excuse my brevity.
>|> > 
>|> > On February 1, 2018 11:00:01 PM PST, Patrick Connolly
> wrote:
>|> >> When i  tried to install the hunspell package, I got this error
>|> >> message:
>|> >> 
>|> >> Error: package ‘Rcpp’ 0.12.3 was found, but >= 0.12.12 is
>required by
>|> >> ‘hunspell’
>|> >> 
>|> >> So I set about installing a new version of Rcpp but I get this
>message:
>|> >> 
>|> >> Error in unloadNamespace(pkg_name) : 
>|> >> namespace ‘Rcpp’ is imported by ‘dplyr’ so cannot be unloaded
>|> >> 
>|> >> How does one get around that?  I tried installing Rcpp in a
>vanilla
>|> >> session but the result was the same.
>|> >> 
>|> >> TIA
>|> >> Patrick
>|> >> 
>|> >> 
>|> >>> sessionInfo()
>|> >> R version 3.4.3 (2017-11-30)
>|> >> Platform: x86_64-pc-linux-gnu (64-bit)
>|> >> Running under: Ubuntu 14.04.5 LTS
>|> >> 
>|> >> Matrix products: default
>|> >> BLAS: /home/pat/local/R-3.4.3/lib/libRblas.so
>|> >> LAPACK: /home/pat/local/R-3.4.3/lib/libRlapack.so
>|> >> 
>|> >> locale:
>|> >> [1] LC_CTYPE=en_NZ.UTF-8   LC_NUMERIC=C  
>|> >> [3] LC_TIME=en_NZ.UTF-8LC_COLLATE=en_NZ.UTF-8
>|> >> [5] LC_MONETARY=en_NZ.UTF-8LC_MESSAGES=en_NZ.UTF-8   
>|> >> [7] LC_PAPER=en_NZ.UTF-8   LC_NAME=C 
>|> >> [9] LC_ADDRESS=C   LC_TELEPHONE=C
>|> >> [11] LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C   
>|> >> 
>|> >> attached base packages:
>|> >> [1] utils stats grDevices graphics  methods   base 
>|> >> 
>|> >> other attached packages:
>|> >> [1] lattice_0.20-35
>|> >> 
>|> >> loaded via a namespace (and not attached):
>|> >> [1] compiler_3.4.3 magrittr_1.5   R6_2.1.2   assertthat_0.1
>|> >> parallel_3.4.3
>|> >> [6] tools_3.4.3DBI_0.3.1  dplyr_0.4.3Rcpp_0.12.3   
>|> >> grid_3.4.3
>|> >> 
>|> >> 
>|> >> -- 
>|> >>
>~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>|> >> 
>|> >>  ___Patrick Connolly   
>|> >> {~._.~}   Great minds discuss ideas
>|> >> _( Y )_   Average minds discuss events 
>|> >> (:_~*~_:)  Small minds discuss people  
>|> >> (_)-(_). Eleanor Roosevelt
>|> >>
>|> >>
>~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>|> >> 
>|> >> __
>|> >> 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-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.
>|> 
>|> -- 
>|> Peter Dalgaard, Professor,
>|> Center for Statistics, Copenhagen Business School
>|> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>|> Phone: (+45)38153501
>|> Office: A 4.23
>|> Email: pd@cbs.dk  Priv: pda...@gmail.com
>|> 
>|> 
>|> 
>|> 
>|> 
>|> 
>|> 
>|> 
>|> 

__
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] copy/paste of large amount of code to terminal leads to scrambled/missing characters

2018-02-03 Thread Jeff Newmiller
This sounds like a problem with your editor or the OS clipboard support rather 
than R. You might get a response here, but R-sig-mac seems more appropriate to 
me for such discussion.
-- 
Sent from my phone. Please excuse my brevity.

On February 3, 2018 4:23:54 PM PST, Martin Batholdy via R-help 
 wrote:
>Dear R-users,
>
>This question might not be restricted to R, but I hope that some might
>have experienced similar problems and could help me.
>
>When using R, I usually work with a text-editor (textmate2) in which I
>prepare the script.
>To execute code, I then copy and paste it to an R-session running in
>the terminal/shell (on Mac OS).
>
>Unfortunately, when pasting too much code into the terminal (e.g. 60
>lines), some characters are occasionally and randomly scrambled or
>missing.
>For example "col <- ifelse(..." turns into "col < col < cse(…".
>
>This happens very randomly, is difficult to predict, and while it only
>affects a hand full of characters in total, it leads to a lot of errors
>in the code execution along the way.
>Apparently, it has to do with the buffer size and paste-speed of the
>terminal.
>
>So far, I could not find any solution to the problem.
>
>Therefore, I wanted to ask; 
>Do others here use a similar workflow (i.e. having a text-editor for
>coding and using copy/paste to the terminal for code execution) and
>encountered similar problems with big chunks of code in the clipboard?
>Are there any solutions for this problem, specifically for running R
>over the shell?
>
>Thank you very much!
>
>__
>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-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] rJava garbage collect

2018-02-05 Thread Jeff Newmiller
rJava offers a mechanism to call arbitrary methods in Java. Wouldn't you use 
that mechanism to call whatever you would call if you were programming in Java 
(e.g. System.gc)? 
-- 
Sent from my phone. Please excuse my brevity.

On February 5, 2018 7:34:17 PM PST, Benjamin Tyner  wrote:
>Hi
>
>Does rJava offer a way to instruct the JVM to perform a garbage
>collection?
>
>Regards
>
>Ben
>
>__
>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-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] gdistance::shortestPath throws error "not a symmetric matrix"

2018-02-06 Thread Jeff Newmiller
It is really hard to help you fix a function usage error if you don't show us 
how you used the function. [1][2][3]

As for helping a customer by asking for help on the wrong list... you are not 
an expert on the topic, and are asking a group that might or might not know the 
theory behind your question. You might achieve success, but it might also be 
better to remove at least one handicap by either or both strategies of having 
the customer ask themselves or asking on the right list. 

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette)
-- 
Sent from my phone. Please excuse my brevity.

On February 6, 2018 6:01:08 AM PST, Loris Bennett  
wrote:
>Hi,
>
>Calling
>
>  gdistance::shortestPath
>
>gives me the error
>
>  Error in asMethod(object) : 
>not a symmetric matrix; consider forceSymmetric() or symmpart()
>
>The output of dput(.traceback()) is
>
>pairlist("stop(\"not a symmetric matrix; consider forceSymmetric() or
>symmpart()\")",
>  "asMethod(object)",
>  "as(Laplacian,\"symmetricMatrix\")",
>  ".Laplacian(x)", ".flowMap(x, ci, cj, tc)",
>  ".local(x, origin, goal, ...)",
>c("passage(conduct_Tobler, origin =sites@coords[5, ], goal =
>sites@coords[3, ", " ])"),
>c("passage(conduct_Tobler, origin = sites@coords[5, ], goal =
>sites@coords[3, ", " ])"),
>  "eval(ei, envir)", "eval(ei, envir)",
>  "withVisible(eval(ei, envir))",
>  "source(\"./Skript.R\")")
>
>Is that enough for anyone to point me in the right direction?
>
>I am aware that this question would be probably better posted on
>r-sig-geo, but as I am just an HPC janitor trying to help a customer
>and
>am not a geo-scientist myself, I thought I'd ask here first before
>signing up to (yet another) list.
>
>Cheers,
>
>Loris

__
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] Aggregate behaviour inconsistent (?) when FUN=table

2018-02-06 Thread Jeff Newmiller
The normal input to a factory that builds cars is car parts. Feeding whole 
trucks into such a factory is likely to yield odd-looking results.

Both aggregate and table do similar kinds of things, but yield differently 
constructed outputs. The output of the table function is not well-suited to be 
used as the aggregated value to be compiled into a data frame by the aggregate 
function, so having aggregate call the table function will yield surprises.

I am having some difficulty deciphering what it is you are trying to accomplish 
with all this, so I will guess that you are trying to reproduce the information 
output from

table( df$C, df$B )

so

aggregate( df$A, df[ , c( "C", "B" ) ], length )

but if that isn't what you want then perhaps you can clarify what result you 
want to see and we can help you get there. 
-- 
Sent from my phone. Please excuse my brevity.

On February 6, 2018 12:20:03 AM PST, Alain Guillet  
wrote:
>Dear R users,
>
>When I use aggregate with table as FUN, I get what I would call a 
>strange behaviour if it involves numerical vectors and one "level" of
>it 
>is not present for every "levels" of the "by" variable:
>
>---
>
> > df <- 
>data.frame(A=c(1,1,1,1,0,0,0,0),B=c(1,0,1,0,0,0,1,0),C=c(1,0,1,0,0,1,1,1))
> > aggregate(df[1:2],list(df$C),table,simplify = TRUE,drop=TRUE)
>   Group.1 A.0 A.1    B
>1   0   1   2    3
>2   1   3   2 2, 3
>
> > table(df$C,df$B)
>
>     0 1
>   0 3 0
>   1 2 3
>
>---
>
>As you can see, a comma appears in the column with the variable B in
>the 
>aggregate whereas when I call table I obtain the same result as if B
>was 
>defined as a factor (I suppose it comes from the fact "non-factor 
>arguments a are coerced via factor" according to the details of the 
>table help). I find it completely normal if I remember that aggregate 
>first splits the data into subsets and then compute the table. But then
>
>I don't understand why it works differently with character vectors. 
>Indeed if I use character vectors, I get the same result as with
>factors:
>
>
>
> > df <- 
>data.frame(A=factor(c("1","1","1","1","0","0","0","0")),B=factor(c("1","0","1","0","0","0","1","0")),C=factor(c("1","0","1","0","0","1","1","1")))
> > aggregate(df[1:2],list(df$C),table,simplify = TRUE,drop=TRUE)
>   Group.1 A.0 A.1 B.0 B.1
>1   0   1   2   3   0
>2   1   3   2   2   3
>
> > df <- 
>data.frame(A=factor(c(1,1,1,1,0,0,0,0)),B=factor(c(1,0,1,0,0,0,1,0)),C=factor(c(1,0,1,0,0,1,1,1)))
> > aggregate(df[1:2],list(df$C),table,simplify = TRUE,drop=TRUE)
>   Group.1 A.0 A.1 B.0 B.1
>1   0   1   2   3   0
>2   1   3   2   2   3
>
>-
>
>Is it possible to precise anything about this behaviour in the
>aggregate 
>help since the result is not completely compatible with the expectation
>
>of result we can have according to the table help? Or would it be 
>possible to have the same results independently of the vector type?
>This 
>post was rejected on the R-devel mailing list so I ask my question here
>
>as suggested.
>
>
>Best regards,
>Alain Guillet

__
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] please help me a little

2018-02-09 Thread Jeff Newmiller
I don't use coxphf, but it is generally a bad idea to reference variables via 
multiple environments (e.g. global and the data= argument in this case) 
directly from within a formula. Just use FAM138A.chr wherever you have used 
test[,6] and it should work. 
-- 
Sent from my phone. Please excuse my brevity.

On February 9, 2018 8:43:03 PM PST, "Ding, Yuan Chun"  wrote:
>Hi R Users,
>
>I am very frustrated with the following code. Please do me a favor to
>run it.
>
>after reading into the test data set (I also pasted the data set
>below), the first line of code for "res_coxphf" did not work and
>generated the error code below. but the other three line worked well.  
>the second line for "res_coxphf2" should be the same as the first line;
>I need to run more than 100 variables in a loop, so I want to do test[,
>i], that is why I want to use the first line.
>
>however, the fourth line for "res_coxphf_cnaRate " also worked well
>after I added one variable "cna.rate" to first line. Can you run them
>and tell me why the first line does not run correctly?
>
>please install coxphf package if you do not have it installed.
>
>Thank you very much!!!
>
>Ding
>
>test<-read.csv("data_coxphf.csv", head=T)
>res_coxphf <- coxphf(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE)
>~test[, 6], data=test)
>res_coxphf2 <- coxphf(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE)
>~ test$FAM138A.chr1, data=test)
>
>res_coxph <- coxph(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE) ~
>test[, 6], data=test)
>res_coxphf_cnaRate <- coxphf(formula=Surv(RFS_days2,
>OV_Had_a_Recurrence_CODE) ~ test[, 6]+ cna.rate, data=test)
>
>
>> test<-read.csv("data_coxphf.csv", head=T)
>> res_coxphf <- coxphf(formula=Surv(RFS_days2,
>OV_Had_a_Recurrence_CODE) ~ test[, 6], data=test)
>Error in mm1[, !colInter, drop = FALSE] :
>  (subscript) logical subscript too long
>> res_coxph <- coxph(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE)
>~ test[, 6], data=test)
>> res_coxphf_cnaRate <- coxphf(formula=Surv(RFS_days2,
>OV_Had_a_Recurrence_CODE) ~ test[, 6]+ cna.rate, data=test)
>> res_coxphf2 <- coxphf(formula=Surv(RFS_days2,
>OV_Had_a_Recurrence_CODE) ~ test$FAM138A.chr1, data=test)
>>
>
>
>
>id  cna.rateRFS_days2   OV_Had_a_Recurrence_CODE   
>DDX11L1.chr1FAM138A.chr1FAM138F.chr1
>sn1 150 560 1   0   0   0
>sn10216 581 1   0   0   0
>sn11191 455 1   0   0   0
>sn12135 118 1   0   0   0
>sn13199 25500   0   0   0
>sn14312 477 1   0   0   0
>sn15260 216 1   0   0   0
>sn16400 10561   0   0   0
>sn17350 398 1   1   1   1
>sn18324 583 1   0   0   0
>sn19174 136 1   0   0   0
>sn20262 98  1   0   0   0
>sn21172 516 1   0   0   0
>sn22490 14391   0   0   0
>sn23165 365 1   0   0   0
>sn24185 168 1   0   0   0
>sn25396 16631   0   0   0
>sn26240 299 1   0   0   0
>sn27114 29170   0   0   0
>sn28128 50  1   0   0   0
>sn29190 654 1   0   0   0
>sn3 435 429 1   0   0   0
>sn30268 31  1   0   0   0
>sn31175 34070   0   0   0
>sn32248 277 1   0   0   0
>sn33116 306 1   0   0   0
>sn34122 52  1   0   0   0
>sn35222 77  1   0   0   0
>sn36414 242 1   0   0   0
>sn37300 10341   1   1   1
>sn38268 32980   0   0   0
>sn4 556 24240   0   0   0
>sn40274 201 1   0   0   0
>sn41267 268 1   0   0   0
>sn42325 147 1   0   0   0
>sn43323 26110   0   0   0
>sn44115 573 1   0   0   0
>sn45265 215 1   0   0   0
>sn48129 259 1   0   0   0
>sn5 114 183 1   0   0   0
>sn51183 219 1   0   0   0
>sn52314 271 1   0   0   0
>sn53465 20710   0   0   0
>sn54207 44  1   0   0   0
>sn55321 347 1   0   0   0
>sn56217 12570   0   0   0
>sn57209 262 1   0   0   0
>sn58227 18110   0   0   0
>sn59130 463 1   0   0   0
>sn6 320 306 1   0   0   0
>sn60136 456 1   0   0   0
>sn62208 48  1   0   0   0
>sn63253 452 1   0  

Re: [R] Using gutenbergr with a firewall

2018-02-13 Thread Jeff Newmiller
Saying "a firewall" is like saying "a weapon". Some firewalls are much more 
strict than others, and yours may be different than any someone here might have 
encountered. You might also be having trouble with anti virus software.
-- 
Sent from my phone. Please excuse my brevity.

On February 13, 2018 10:55:40 PM PST, Patrick Connolly 
 wrote:
>I can use the gutenberg_download() function in the gutenbergr package
>on a computer that doeson't use a firewall, but on an almost identical
>installation that is behind a firewall, nothing happens, not even a
>time-out.
>
>Has anyone succeeded in using gutenberg_download() successfully with a
>firewall?  I tried raising an issue at
>https://github.com/ropenscilabs/gutenbergr/issues/17 with no usable
>response.  I also tried contacting the maintainer but got no response.
>
>The firewall might be a red-herring, but I thought it worthwhile
>eliminating it as a factor.
>
>I would welcome any information on anyone else's experience.
>
>Thank you.

__
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] long vectors not supported yet

2018-02-14 Thread Jeff Newmiller
This looks to me like a package development issue... which may be under 
discussion in R-sig-geo (search the archives), but more likely to be 
appropriate to discuss with the maintainer by email or through their 
development repository (R-forge, though it looks unused).
-- 
Sent from my phone. Please excuse my brevity.

On February 14, 2018 7:43:51 AM PST, Loris Bennett  
wrote:
>Hi,
>
>I am running R 3.3.3 and getting the following error:
>
>Error in add_edges(res, edges = t(as.matrix(el[, 1:2])), attr = weight)
>: 
>   long vectors not supported yet: ../../src/include/Rinlinedfuns.h:138
>
>when passing a 13 GB TransitionLayer object to shortestPath from the
>package 'gdistance'.
>
>The error, albeit in a different context, is discussed here:
>
>  https://github.com/tidyverse/readr/issues/309
>  https://github.com/tidyverse/readr/pull/433
>
>However it is not clear to me quite what the fix was and what kind of
>limit may still exist in subsequent R versions.
>
>Is this a general problem/issue with R, or is this something more
>package-specific which should be addressed on R-sig-Geo?
>
>Cheers,
>
>Loris

__
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] using cat to log to file with sapply

2018-02-14 Thread Jeff Newmiller
Your call to catf in testit is after the return,  so it is never called. 

FWIW my antibugging strategy (and readability strategy) is to never use the 
return function... I structure my logic to end up at the end with my desired 
function result in a variable and I simply put that variable on the last line 
of the function.
-- 
Sent from my phone. Please excuse my brevity.

On February 14, 2018 4:16:19 PM PST, alexander.h...@csiro.au wrote:
>Hi List,
>I am trying to write unsuccessfully to a logfile with cat. Here my
>example code:
>
>letters[1:5]->x
>logf<-"test.txt"
>cat('%%\n',file=logf)
>catf<-function(x,...,logfile='log.txt', append=TRUE){ cat(x,'\n',
>file=logfile, append=append)}
>testit<-function(x,...){
>  paste0('this is x: ',x)->y
>  return(y)
>  catf("++test=",...)
>  }  
>sapply(x, function(x) testit(x, logfile=logf))
>
>Any suggestions appreciated.
>
>Thanks
>Herry
>__
>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-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] long vectors not supported yet

2018-02-15 Thread Jeff Newmiller
It does appear to be an error message from R [1] regarding the difference 
between the maximum length of a data vector (~2^59) and the maximum length of a 
matrix/array/data frame dimension (~2^31).

As to whether this is under consideration for change, I don't know but I would 
not want such information to affect how I work around the limitation today 
because it may come with bugs initially anyway. 

[1] 
https://stackoverflow.com/questions/24335692/large-matrices-in-r-long-vectors-not-supported-yet
-- 
Sent from my phone. Please excuse my brevity.

On February 15, 2018 4:33:13 AM PST, Loris Bennett  
wrote:
>Hi Jeff,
>
>Jeff Newmiller  writes:
>
>>> Hi,
>>> 
>>> I am running R 3.3.3 and getting the following error:
>>> 
>>> Error in add_edges(res, edges = t(as.matrix(el[, 1:2])), attr =
>weight)
>>> : 
>>>long vectors not supported yet:
>../../src/include/Rinlinedfuns.h:138
>>> 
>>> when passing a 13 GB TransitionLayer object to shortestPath from the
>>> package 'gdistance'.
>>> 
>>> The error, albeit in a different context, is discussed here:
>>> 
>>>   https://github.com/tidyverse/readr/issues/309
>>>   https://github.com/tidyverse/readr/pull/433
>>> 
>>> However it is not clear to me quite what the fix was and what kind
>of
>>> limit may still exist in subsequent R versions.
>>> 
>>> Is this a general problem/issue with R, or is this something more
>>> package-specific which should be addressed on R-sig-Geo?
>
>> This looks to me like a package development issue... which may be
>> under discussion in R-sig-geo (search the archives), but more likely
>> to be appropriate to discuss with the maintainer by email or through
>> their development repository (R-forge, though it looks unused).
>
>Thanks for the information.  I reported the issue to the developers of
>'igraph', which is where 'add_edges' comes from, here
>
>  https://github.com/igraph/rigraph/issues/255
>
>The response there to the question of whether it is an R core or an
>igraph issue was
>
>  R core for sure, but probably both.
>
>Is this indeed the case for R core?  To my naive eye, the error message
>suggests more of a known limitation, rather than a bona fide bug.
>
>Cheers,
>
>Loris

__
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.


  1   2   3   4   5   6   7   8   9   10   >