Re: [R] convert microns to nm in a messy dataset

2019-05-10 Thread John McKown
This is my approach. It is based entirely on what you said (multiply by
1000 to convert from nm to µm, but I think it is divide by). It assumes
that the starting value is in µm. If the starting value is in nm, change
the "factor=1" to "factor=1000". That µm is micro-meters (10^-6) and nm is
nano-meters (10^-9), so divide by would be correct.

 factor=1;
 for (i in 1:length(my.data$V19)) {
 print("Start");print(factor);print(my.data[i,]);
 if (my.data$V19[i] == "nm") { factor=1000;
my.data$V19[i]="µm";print("nm");} else if (my.data$V19[i] == "µm")
{factor=1;};
 if (suppressWarnings(!is.na(as.numeric(my.data$V19[i] { my.data$V19[i]
= as.character(as.numeric(my.data$V19[i]) * factor); print("changed"); }
 print(factor);print(my.data[i,]);print("End");



On Fri, May 10, 2019 at 6:54 AM Ivan Calandra  wrote:

> Dear useRs,
>
> Below is a sample of my dataset (I have more rows and columns).
>
> As you can see in the 2nd column, there are values, the name of the
> parameter
> ('Sq' in that case), some integer ('45' in that case) and the unit ('µm' or
> 'nm').
> I know how to extract the rows of interest (those with values), but they
> are
> expressed in different units. All values following a line with the unit are
> expressed in that unit, but the number of lines is not constant (sometimes
> each
> value is expressed in a different unit so there will be a new unit line,
> but
> there are sometimes several values in a row expressed in the same unit so
> without unit lines in between). I hope this is clear (it should be with the
> example provided).
> This messy dataset comes from an external software so I don't have any
> means to
> format the ways the data are collated. I have to find a way to deal with
> it in
> R.
>
> What I would like to do is convert the values in nm to µm; I just need to
> multiply by 1000.
>
> What I don't know is how to identify the values that are expressed in nm
> (all
> values that follow a line with 'nm' until there is a line with 'µm').
>
> I don't even know how I should search online because I don't know how this
> kind
> of operation is called.
> Any help is appreciated.
>
> Thank you in advance.
> Ivan
>
>
> my.data <- structure(list(V1 = c("2019/05/10", "#", "#", "#", "2019/05/10",
> "2019/05/10", "2019/05/10", "#", "#", "#", "2019/05/10", "#", "#", "#",
> "2019/05/10", "#", "#", "#", "2019/05/10", "2019/05/10"), V19 =
> c("0.2012800083", "45", "Sq", "µm", "0.3634383236", "0.4360454777",
> "0.3767733568", "45", "Sq", "nm", "102.013048", "45", "Sq", "µm",
> "0.1413840498", "45", "Sq", "nm", "65.4459715", "46.45802917")), row.names
> =
> c(NA, 20L), class = "data.frame")
>
> --
> Dr. Ivan Calandra
> TraCEr, laboratory for Traceology and Controlled Experiments
> MONREPOS Archaeological Research Centre and
> Museum for Human Behavioural Evolution
> Schloss Monrepos
> 56567 Neuwied, Germany
> +49 (0) 2631 9772-243
> https://www.researchgate.net/profile/Ivan_Calandra
>
> __
> 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.
>


-- 
This is clearly another case of too many mad scientists, and not enough
hunchbacks.


Maranatha! <><
John McKown

[[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] OT --- grammar.

2018-06-25 Thread John McKown
On Sun, Jun 24, 2018 at 8:08 PM Michael Sumner  wrote:

> No it isn't. Your stature is diminished by hateful behaviour.
>

​I will most likely also be labelled "hateful" for saying this, but I found
Rolf's post to be accurate, although phrased in a bit of an elitist way.​
Being a bit of a grammar Nazi (I may as well label myself as others likely
will), I sometimes come across as elitist as well. I am come across this
way because in any scientific endeavour, under which I include programming,
precision and accuracy is the top priority. Because if people think that
_I_ am a grammar Nazi, they haven't run into very many compilers
(especially for the archaic language COBOL) who will simply refuse to
compile something which doesn't make sense according to _its_ rules.

However, unlike Rolf, I do not take offense when people use idiomatic
expressions or even make up phrases on an English speaking mailing list
(English not being any kind of pristine, planned, language). So long as I
can puzzle it out, it is good to me. If I can't puzzle it out, I ignore it.
​
​My apologies to Dr. Sumner for originally sending this to him directly.
That was my error in not double checking that "reply" went to the proper
recipient. ​



>
> Cheers, Mike
>
> On Mon, 25 Jun 2018, 07:26 Rolf Turner,  wrote:
>
> > On 25/06/18 12:03, Bert Gunter wrote:
> > > Ted, et. al.:
> > >
> > > Re: "Data is" vs "data are" ... Heh heh!
> > >
> > > "This is the kind of arrant pedantry up with which I will not put."
> > > (Attributed to Churchill in one form or another, likely wrongly.)
> > >
> > > See here for some semi-authoritative dicussion:
> > >
> > >
> >
> http://www.onlinegrammar.com.au/top-10-grammar-myths-data-is-plural-so-must-take-a-plural-verb/
> >
> > I beg to differ.  "The data was out of date" sounds just plain stupid to
> > my sensitive ears.
> >
> > It's rather like using the phrase "begs the question" to mean "raises
> > the question" or "invites the question" rather than to carry its
> > *correct* meaning of "assumes what is to be proved".  The fact that the
> > phrase is almost always used in its *incorrect* sense these days, and
> > almost never in its *correct* sense, does not diminish the fact that
> > those who use it incorrectly are ignorant scumbags!  The language is
> > weakened and diminished by the encroachment of incorrect usage.
> >
> >
> >
> > cheers,
> >
> > Rolf
> >
> >
> > --
> > Technical Editor ANZJS
> > Department of Statistics
> > University of Auckland
> > Phone: +64-9-373-7599 ext. 88276
> >
> > __
> > 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.
> >
> --
> Dr. Michael Sumner
> Software and Database Engineer
> Australian Antarctic Division
> 203 Channel Highway
> Kingston Tasmania 7050 Australia
>
> [[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.
>


-- 
There is no such thing as the Cloud. It is just somebody else’s computer.

Maranatha! <><
John McKown

[[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] Creating/Reading a complex string in R

2017-07-18 Thread John McKown
On Tue, Jul 18, 2017 at 12:05 PM, Christofer Bogaso <
bogaso.christo...@gmail.com> wrote:

> Thanks for your pointer.
>
> Is there any way in R how to replace " ' " with " /' " programmatically?
>
> My actual string is quite lengthy, so changing it manually may not be
> possible. I am aware of gsub() function, however not sure I can apply
> it directly on my original string.
>
> Regards,
>
>
​I guess your string value is in a file? And you'd like to update the file
contents. You didn't say which OS you're on. I'm a Linux person, and the
simplest for me would be:

sed -i -r "s/'/\\'/g" myfile.txt​ #note the \\ becomes a single \ in the
output. weird.

Or just edit the file in your favorite editor. In mine, vim, it would be
the command ":g/'/s/\\'/g" (the command is within the " marks).
You are correct that you could use gsub(). But you can't just paste your
string into an R program as is, as you have already seen. You'd need to put
it into a file. Then read that file into a program (perhaps an R program
using gsub()) to write the updated string to another file. Which contents
you could then cut'n'paste into your original R file.
something like:

#!/usr/bin/Rscript
#
files <- commandArgs(trailingOnly=TRUE);
#
for (infile in files) {
x=readLines(infile);
y=gsub("'","'",x);
ofile=paste0(infile,".new");
    writeLines(y,ofile);
}



-- 
Veni, Vidi, VISA: I came, I saw, I did a little shopping.

Maranatha! <><
John McKown

[[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] Creating/Reading a complex string in R

2017-07-18 Thread John McKown
Try:

String = '
  

Re: [R] Difference between R for the Mac and for Windows

2017-03-31 Thread John McKown
On Fri, Mar 31, 2017 at 12:15 PM, Berend Hasselman <b...@xs4all.nl> wrote:

>
> I have noted a difference between R on macOS en on Kubuntu Trusty (64bits)
> with complex division.
> I don't know what would happen R on Windows.
>
> R.3.3.3:
>
> macOS (10.11.6)
> -
> > (1+2i)/0
> [1] NaN+NaNi
> > (-1+2i)/0
> [1] NaN+NaNi
> >
> > 1i/0
> [1] NaN+NaNi
> > 1i/(0+0i)
> [1] NaN+NaNi
>
>
> KubuntuTrusty
> -
> > (1+2i)/0
> [1] Inf+Infi
> > (-1+2i)/0
> [1] -Inf+Infi
> >
> > 1i/0
> [1] NaN+Infi
> > 1i/(0+0i)
> [1] NaN+Infi
>
> Interesting to see what R on Windows delivers.
>

​> (1+2i)/0
[1] Inf+Infi
> (-1+2i)/0
[1] -Inf+Infi
> 1i/0
[1] NaN+Infi
> 1i/(0+0i)
[1] NaN+Infi
> Sys.info()
 sysname  release
   "Windows"  "7 x64"
 version nodename
"build 7601, Service Pack 1" "IT-JMCKOWN"
 machinelogin
"x86-64""John.Mckown"
user   effective_user
   "John.Mckown""John.Mckown"
>

Same as Kubuntu. I am _guessing_ that the MacOS somehow sets up the
floating point processing to work differently, since they are all on Intel
machines nowadays. Or the R was customized to detect division by zero in
software and not really do any floating point processing at all.
​

>
> Berend Hasselman
>
>

-- 
"Irrigation of the land with seawater desalinated by fusion power is
ancient. It's called 'rain'." -- Michael McClary, in alt.fusion

Maranatha! <><
John McKown

[[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] MS SQL Server R Services review.

2017-02-16 Thread John McKown
I just picked this up over on "Vulture Central"
http://www.theregister.co.uk/2017/02/16/r_sql_server_great_but_beware/

The author seems both pleased and not pleased. Mainly digging at R's use
(or abuse) of memory being a cause of many failures. And the fact that is
is "slow" (states Python runs 17x faster) due to being interpreted.

Also, to me, it seems weird to run R within the data base server itself,
rather than on a client using RODBC.

-- 
"Irrigation of the land with seawater desalinated by fusion power is
ancient. It's called 'rain'." -- Michael McClary, in alt.fusion

Maranatha! <><
John McKown

[[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] R studio server vs R server and Small computer to run R

2017-01-19 Thread John McKown
On Wed, Jan 18, 2017 at 11:03 AM, John Sorkin <jsor...@grecc.umaryland.edu>
wrote:

> Please forgive my resending this help request. I sent it two days ago. To
> date I have not received any responses.
> Thank you,
> John
>
>
> I am looking for a small computer low power that I make available on the
> web that will run R studio server or R server
>
> 1) can anyone recommend a computer?
>

The Raspberry Pi 3 runs a version of Debian. It is quite small. Mine runs a
BCM2709 processor. That's a
​64 bit ARM processor. HOWEVER! The Debian that I have to run is only 32
bit.  It has 1 GiB of RAM and 32 GiB of flash memory which is the disk. It
runs 1.2 Ghz. It has 4 USB ports so you could plug in a USB connected disk,
if you need more local disk space.


https://www.raspberrypi.org/products/raspberry-pi-3-model-b/



>
> 2) can anyone let me know the advantages and disadvantages of R studio
> server and R server?
>

​Sorry, I only use the basic R.



>
> Thank you
>
> John
>
> John David Sorkin M.D., Ph.D.
>
>
>


-- 
There’s no obfuscated Perl contest because it’s pointless.

—Jeff Polk

Maranatha! <><
John McKown

[[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] help for

2016-12-30 Thread John McKown
On Fri, Dec 30, 2016 at 12:08 PM, Sarah Goslee <sarah.gos...@gmail.com>
wrote:

> This isn't an R question, but a linux question.
>
> Open a new terminal window:
> The directions you are following tell you how to do that for the
> Ubuntu linux being used, right at the beginning:
>
> Open up a terminal (Applications->Accessories->Terminal from the the
> toolbar)
>
> As for your command, the $ is a prompt. You don't type that. Start with ls
>
> What should you do now? Read a little bit about using linux command line
> tools
>

​Well, this being the R language forum, perhaps you should enter "R" after
the command prompt?

Seriously, what do you want to accomplish? Since you are using Ubuntu, I
will assume that you are using the default shell program, BASH. There is a
BASH forum you could join called mailto:help-b...@gnu.org . It's easiest to
sign up here:
https://lists.gnu.org/mailman/listinfo/help-bash
This site has some nice articles about BASH and programming (scripting)
using it: http://wiki.bash-hackers.org/
BASH for beginners: http://www.tldp.org/LDP/Bash-Beginners-Guide/html/
Since you seem to be using Ubuntu:
https://help.ubuntu.com/community/Beginners/BashScripting

There are _TONS_ of commands installed in Ubuntu by default. Most of them
have manual (man) pages. Most of the defaults are in the directory
/usr/bin. You can list them simply by entering the command: "ls /usr/bin".
My system has over 6,500 programs stuffed in there. If you see something
interesting, you can get some basic documentation on it by using the
command: "man ". We've mentioned "ls", which lists the contents
of a directory. If you want to know more, try "man ls". In addition to
"man" there is a much more powerful information source called "info". Just
use it instead of "man" as the command name. That is, use "info ls" to get
some real detailed information on the ls command.

Another interesting command is "apropos". Think of it as being similar to
the R systems' double question mark search. As an example, suppose you want
to find out what commands might be helpful with a "zip" file. Enter the
command: "apropos zip". On my system, I get a (truncated) response such as:

bunzip2 (1)  - a block-sorting file compressor, v1.0.6
bzip2 (1)- a block-sorting file compressor, v1.0.6
bzip2recover (1) - recovers data from damaged bzip2 files
bzless (1)   - file perusal filter for crt viewing of bzip2
compressed text
decode (n)   - Access to zip archives
encode (n)   - Generation of zip archives
funzip (1)   - filter for extracting from a ZIP archive in a pipe
gunzip (1)   - compress or expand files
gzip (1) - compress or expand files
IO::Compress::Bzip2 (3pm) - Write bzip2 files/buffers
IO::Compress::Zip (3pm) - Write zip files/buffers
IO::Uncompress::Unzip (3pm) - Read zip files/buffers
unzip (1)- list, test and extract compressed files in a ZIP
archive
unzipsfx (1) - self-extracting stub for prepending to ZIP archives
zforce (1)   - force a '.gz' extension on all gzip files
zip (1)  - package and compress (archive) files
zipcloak (1) - encrypt entries in a zipfile

Note the number in the parentheses after the command. A "1" indicates this
is a normal command. Something which starts with a "3" (like 3pm) means
this is like a subroutine package (The "pm" in 3pm means "Perl Module" -
like an R package, sort of). Also note that some of the entries have
nothing to do with a normal "zip" file; such as the entires with bzip2 in
them - bzip2 is an alternative compressor program).

I'm fairly good with BASH, having programmed for over 3 decades, and used
BASH for about 10 years. Which is both good and bad. The good is that I
understand BASH fairly well. The bad is that I like "tricky coding" (a
personal problem).



>
> Sarah
>
>
-- 
There’s no obfuscated Perl contest because it’s pointless.

—Jeff Polk

Maranatha! <><
John McKown

[[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] [FORGED] Export R output in Excel

2016-12-30 Thread John McKown
On Thu, Dec 29, 2016 at 4:32 PM, Erich Subscriptions <
erich.s...@neuwirth.priv.at> wrote:

> Just a very brief footnote.
> I is easy to write badly structured spreadsheets.
> But if people dong this would not have spreadsheets
> and be forded to write code, they probably also
> would write badly structured code.
>

​Very true. ​There is a very old quote: "You can write FORTRAN in any
language." Basically FORTRAN was, I think, the very first "high level"
language (1957 - COBOL was in 1959) and it had very poor (NO) structuring.
Coding it in is much like writing a bad mathematical proof (yes, I know
FORTRAN). When better languages came along, the original programmers wrote
code in the "if it were only FORTRAN" mode.

ref: https://en.wikiquote.org/wiki/Fortran




>
> There is a lot of bad R code around also!
>
>

-- 
Heisenberg may have been here.

http://xkcd.com/1770/

Maranatha! <><
John McKown

[[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] data manipulation

2016-12-13 Thread John McKown
On Tue, Dec 13, 2016 at 3:23 AM, Farshad Fathian <farshad.fath...@gmail.com>
wrote:

> Hi,
>
> I couldn't access to data file about PSCoperwait by
> http://massey.ac.nz/~pscoperwait/ts/cbe.dat.
>

​First off, this post is nearly useless. You don't tell us what you tried
to do. And you didn't tell us what error message you got.​


​From a fast test, the reason is that the above URL is invalid.. It gets a
404 error. That is "requested document does not exist." You can't read that
which does not exist. Why doesn't it exist? I don't know - ask Massey
University of New Zealand.


>
> Looking forward to hearing from you,
>
>
>


-- 
Heisenberg may have been here.

http://xkcd.com/1770/

Maranatha! <><
John McKown

[[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] read

2016-11-28 Thread John McKown
On Mon, Nov 28, 2016 at 4:23 PM, Ashta <sewa...@gmail.com> wrote:

> Hi all,
>
> I have a script that  reads a file (dat.csv)  from several folders.
> However, in some folders the file name is (dat) with out csv  and in
> other folders it is dat.csv.  The format of data is the same(only the
> file name differs  with and without "csv".
>
> Is it possible to read these files  depending on their name in one?
> like read.csv("dat.csv"). How can I read both type of file names?
>
> Thank you in advance
>
>
​I'd do something like this:

> files=c('dat.csv','dat')
> file2read=files[file.exists(files)][1]
> file2read
[1] "dat.csv"

You put the possible file names into the variable in the order of
preference. E.g. I prefer "dat.csv" over "dat" if by chance both exist.

> files=c('not.csv','not')
> file2read=files[file.exists(files)][1]
> file2read
[1] NA

​The above shows the result should none of the files exist. So if
"file2read" has an NA, then you go on to the next directory.​


-- 
Heisenberg may have been here.

Unicode: http://xkcd.com/1726/

Maranatha! <><
John McKown​

[[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] Question about ‘The R Project’.

2016-11-14 Thread John McKown
On Mon, Nov 14, 2016 at 2:00 AM, 김세희 <jane...@zenithn.com> wrote:

> Hello,
>
> I’m Jane Kim from Zenith and Company.
>
> We have a question about ‘The R Project’.
>
> It looks like it’s an open source software, but the document from the
> website shows that it’s free of use not free of price.
>
> Please, confirm us the if it cost fees to use it for commercial use.


> If needed, could you inform us the price for it, too?
>
> Best regards,
> Jane Kim.
>
>
​According to
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Can-I-use-R-for-commercial-purposes_003f​
, R is released under the "GNU Public License" version 2.0. This means it
is "libre" (the source is available). Also, it is "gratis" (it is free from
cost to use, although it is permissible to charge a one-time "distribution"
fee - such as might be done if you want someone to mail you a DVD with the
source on it.)

​[quote]

2.11 Can I use R for commercial purposes?

R is released under the GNU General Public License (GPL), version 2
<https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>. If you have any
questions regarding the legality of using R in any particular situation you
should bring it up with your legal counsel. We are in no position to offer
legal advice.

It is the opinion of the R Core Team that one can use R for commercial
purposes (e.g., in business or in consulting). The GPL, like all Open
Source licenses, permits all and any use of the package. It only restricts
distribution of R or of other programs containing code from R. This is made
clear in clause 6 (“No Discrimination Against Fields of Endeavor”) of the Open
Source Definition <https://opensource.org/docs/definition.html>:

The license must not restrict anyone from making use of the program in a
specific field of endeavor. For example, it may not restrict the program
from being used in a business, or from being used for genetic research.

It is also explicitly stated in clause 0 of the GPL, which says in part

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of running the
Program is not restricted, and the output from the Program is covered only
if its contents constitute a work based on the Program.

Most add-on packages, including all recommended ones, also explicitly allow
commercial use in this way. A few packages are restricted to
“non-commercial use”; you should contact the author to clarify whether
these may be used or seek the advice of your legal counsel.

None of the discussion in this section constitutes legal advice. The R Core
Team does not provide legal advice under any circumstances.

[quote/]​



-- 
Heisenberg may have been here.

Unicode: http://xkcd.com/1726/

Maranatha! <><
John McKown

[[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] (no subject)

2016-10-06 Thread John McKown
On Thu, Oct 6, 2016 at 2:55 AM, abhishek pandey <
abhishekpandey_1...@rediffmail.com> wrote:

> kindly solve my problem sir.
>
>
​A very polite request. Unfortunately it is impossible because your email
was HTML formatted and the list software removed the most of your email
before sending it out. You must use "plain text" only. Also, depending on
exactly what your request is, your response may well be "we don't do
homework" (if it looks like class work), or if it appears that you want
someone to write code for you, instead of helping with a specific problem
in your code, then it is unlikely to be done because the list is not,
generall, inhabited by unpaid consultants.​



-- 
Heisenberg may have been here.

Unicode: http://xkcd.com/1726/

Maranatha! <><
John McKown

[[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] R Mysql Not reading all table names

2016-10-03 Thread John McKown
On Mon, Oct 3, 2016 at 11:13 AM, Vivek Singh <viv...@mail.usf.edu> wrote:

> Hi All:
>
> I am using R with MySQL, following is my code:
>
> library(RMySQL)
> con <- dbConnect(MySQL(), user="user", password="password", dbname="db",
> host="localhost")
> rs1 <- dbSendQuery(con, "show tables like \"%padded\"")
> all_tables3<- fetch(rs1, n=-1)
>
> There are 25 tables in the database when I execute the above query on the
> MySQL prompt. However, the above R code giving me only 9 tables. It seems
> there is some cache from which R is getting 9 tables instead of 25 tables.
> Please help.
>

​Just to be sure that I am understanding you correctly. When you say there
are "25 tables" do you mean a total of 25 tables, of all names, or a total
of 25 tables which whose names end with the characters "padded". I ask
because your SHOW TABLES is only looking for the names of tables which end
in "padded". Please forgive me if this is a stupid question.​



>
> Regards,
>
> Vivek Kumar Singh
>
> PhD student,
> Information Systems Decision Sciences,
> MUMA College of Business,
> USF
> Phone- (813) 5809131
> Web: http://vivek4.myweb.usf.edu/
>
>

-- 
Heisenberg may have been here.

Unicode: http://xkcd.com/1726/

Maranatha! <><
John McKown

[[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] Off topic, but hopefully not totally irrelevant: on MS Excel and genomics

2016-09-02 Thread John McKown
On Fri, Sep 2, 2016 at 9:10 AM, John Kane <jrkrid...@inbox.com> wrote:

> Over the last few years I came to the conclusion that using a spreadsheet
> for anything more complicated than my shopping list was madness.
>  I am now reconsidering my position on shopping lists.
>

​I got a real laugh out of that one! When used for the purpose of their
ancestors, they are an excellent tool. A screwdriver is an excellent tool.
But you can't use it alone to build a submarine.
https://www.cs.umd.edu/class/spring2002/cmsc434-0101/MUIseum/applications/spreadsheethistory1.html
​



>
> Thanks Bert. I have a small collection of spreadsheet errors that have
> been  published here and there and this is a great addition.
>
> John Kane
> Kingston ON Canada
>


-- 
Unix: Some say the learning curve is steep, but you only have to climb it
once. -- Karl Lehenbauer
Unicode: http://xkcd.com/1726/

Maranatha! <><
John McKown

[[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] Build command in library(devtools)

2016-07-19 Thread John McKown
On Tue, Jul 19, 2016 at 3:15 PM, Steven Yen <sye...@gmail.com> wrote:

> I recently updated my R and RStudio to the latest version and now the
> binary option in the "build" command in devtools stops working.
>
> I went around and used the binary=F option which worked by I get the
> .tar.gz file instead of the .zip file which I prefer.
>
> Does anyone understand the following error message:
>
> status 127
> running 'zip' failed
>

​I'm not totally sure, but I think that means that R cannot find the "zip"
program in order to run it. ​



>
> ===
> setwd("A:/R/yenlib/"); library(devtools)
> #build("yenlib",binary=T) # Thisfailed with an error message
> build("yenlib",binary=F) # This works
>
>  > build("yenlib",binary=T)
> "C:/PROGRA~1/R/R-33~1.1/bin/x64/R" --no-site-file  \
>--no-environ --no-save --no-restore --quiet CMD INSTALL \
>"A:\R\yenlib\yenlib" --build
>
> * installing to library
> 'C:/Users/syen01/AppData/Local/Temp/Rtmp8A7KEw/temp_libpath4074149a528e'
> * installing *source* package 'yenlib' ...
> ** R
> ** data
> ** preparing package for lazy loading
> ** help
> *** installing help indices
> ** building package indices
> ** testing if installed package can be loaded
> *** arch - i386
> *** arch - x64
> * MD5 sums
> Warning: running command '"zip" -r9Xq "A:/R/yenlib/yenlib_16.3.zip"
> yenlib' had status 127
> running 'zip' failed
> * DONE (yenlib)
> [1] "A:/R/yenlib/yenlib_16.3.zip"
>  >
>
>
> [[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.
>



-- 
"Worry was nothing more than paying interest on a loan that a man may never
borrow"

From: "Quest for the White Wind" by Alan Black

Maranatha! <><
John McKown

[[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] How to import sensitive data when multiple users collaborate on R-script?

2016-05-31 Thread John McKown
On Tue, May 31, 2016 at 5:44 AM, Nikolai Stenfors <
nikolai.stenf...@gapps.umu.se> wrote:

> We conduct medical research and our datafiles therefore contain sensitive
> data, not to be shared in the cloud (Dropboc, Box, Drive, Bitbucket,
> GitHub).
> When we collaborate on a r-analysis-script, we stumble upon the following
> annoyance. Researcher 1 has a line in the script importing the sensitive
> data from his/her personal computer. Researcher 2 has to put an additional
> line importing the data from his/her personal computer. Thus, we have lines
> in the script that are unnecessery for one or the other researcher. How can
> we avoid this? Is there another way of conducting the collaboration. Other
> workflow?
>
> I'm perhaps looking for something like:
> "If the script is run on researcher 1 computer, load file from this
> directory. If the script is run on researcher 2 computer, load data from
> that directory".
>
> Example:
> ## Import data-
> # Researcher 1 import data from laptop1, unnecessery line for Researcher 2
> data <- read.table("/path/to_researcher1_computer/sensitive_data.csv")
>
> # Researcher 2 import data from laptop2 (unnecessery line for Researcher 1)
> data <- read.table("/path/to_researcher2_computer/sensitive_data.csv")
>
> ## Clean data
> data$var1 <- NULL
>
> ## Analyze data
> boxplot(data$var2)
>
>
​Can you have the researchers input the name of the data file to be
analyzed? I use code similar to:

arguments <- commandArgs(trailingOnly=TRUE);
#
# I put in the next command due to my own ignorance
# If you invoke an R script file using just R, you
# need to say something like:
# R BATCH CMD script.R --args ... other arguments ...
#
# but if you use Rscript, you invoke it like:
# Rscript script.R ... other arguments ...
#
# Well, I got confused and did:
# Rscript script.R --args ... other arguments ...
#
# The next line adjusts for my own idiocy.
if ("--args" == arguments[1]) arguments <- arguments[-1];
#
for (file in arguments) {
...
}

Please ignore the line about my own idiocy :-}

Another thought is to use an environment variable which is set in the
user's logon profile (or the Windows registry, forgive my ignorance of
Windows). I think this would be something like:

filename <- Sys.getenv("FILENAME")
if (filename = "") {
... no file name in environment, what to do?
}

You could have someone do this for the user, if he is not familiar with ​
the process.
​


-- 
The unfacts, did we have them, are too imprecisely few to warrant our
certitude.

Maranatha! <><
John McKown

[[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] Whether statistical background is must to learn R language

2016-05-31 Thread John McKown
On Tue, May 31, 2016 at 2:22 AM, Prasad Kale <prasad.prasad.k...@gmail.com>
wrote:

> Hi,
>
> I am very new to R and just started learning R. But i am not from
> statistical background so can i learn R or to learn R statistical
> background is must.
>

​Well, I got a B.Sc. in Math back many years ago. I "earned" a C- in
Statistics (deserved). I don't use statistics normally. And I use R for
non-statistical purposes. In particular, I use it to read files into data
frames; do some minor statistical stuff (sum, mean, standard deviation,
other really simple stuff); then use ggplot2 to create really nice graphs
which I embed into a web page. I also use R to read a web site in order to
extract data in an HTML table into an R data frame. I then do some minor
manipulation and put the data into a PostgreSQL data base​. I even use it
to create Excel spreadsheets (for people at work who aren't wise enough to
abandon it for LibreOffice).

All that to say that, depending on your need, you don't need to learn
statistics to be able to use R. Of course, R was designed to make it easy
to do statistics. And many users here use it for that. But it is not a "one
trick pony".



>
> Please guide.
>
> Thanks in Advance
> Prasad
>
>

-- 
The unfacts, did we have them, are too imprecisely few to warrant our
certitude.

Maranatha! <><
John McKown

[[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] read.fortran format

2016-05-27 Thread John McKown
On Fri, May 27, 2016 at 12:56 PM, Steven Yen <sye...@gmail.com> wrote:

> Dear fellow R users:
> I am reading a data (ascii) file with fortran fixed format, containing
> multiple records. R does not recognize fortran's record break (a slash).
> I tried to do the following but it does not work. Help appreciated.
>
>   60 FORMAT(1X,F6.0,5F8.6/1X,5F8.4,F10.6/1X,2F6.0,3E15.9,F8.0,F5.2,F5.3
>   *  /1X,F7.0,2E15.9,F9.4,F5.3)
>
> mydata<-read.fortran("G:/Journals/Disk1/12_restat_95/estimate/GROUPD.DAT",
> ​​
>  c("1X","F6.0","5F8.6"/"1X","5F8.4","F10.6"
>   /"1X","2F6.0","3E15.9","F8.0","F5.2","F5.3"
>   /"1X","F7.0","2E15.9","F9.4","F5.3"),
> ​​
> col.names=c("year","w1","w2","w3","w4","w5","w6","v1","v2","v3",
> "v4","v5","v6","z","chyes","chno","ec","vc","cvc",
> "pop","ahs","fah","tnh","eq","vq","ups","zm1 "))
>

​Did you see this from ?read.fortran



 For a single-line record, ‘format’ should be a character vector.
 For a multiline record it should be a list with a character vector
 for each line.

​


​I think (not sure) you need:

mydata<-read.frotran("G:/Journals/Disk1/12_restat_95/estimate/GROUPD.DAT",
list(c("1X","F6.0","5F8.6"),c("1X","5F8.4","F10.6"),c("1X","2F6.0","3E15.9","F8.0","F5.2","F5.3"),c("1X","F7.0","2E15.9","F9.4","F5.3")).
​
col.names=c("year","w1","w2","w3","w4","w5","w6","v1","v2","v3",
"v4","v5","v6","z","chyes","chno","ec","vc","cvc",
"pop","ahs","fah","tnh","eq","vq","ups","zm1 "))





-- 
The unfacts, did we have them, are too imprecisely few to warrant our
certitude.

Maranatha! <><
John McKown

[[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] undefined columns selected!

2016-05-04 Thread John McKown
On Wed, May 4, 2016 at 8:05 AM, ch.elahe via R-help <r-help@r-project.org>
wrote:

>
> Hi all,
> I know it seems simple but I am trying to copy a code and I don't know
> what is the problem with this command!
>
> msubsub=msub[,cn]
>
> the error I get is : error in '[.data.frame '(msub, ,cn) : undefined
> columns selected
>

​First - very important - please change from HTML posting to plain text.
This forum doesn't handle HTML well and its use very often results in
​unreadable and thus unusable messages.

​TLI (Too Little Information). I would probably help if you would post the
information from things like:

dput(head(msub))

dput(head(cn)​)


Most want "dput(msub)" and "dput(cn)", but I use the "head()" to subset
that to examples which are usually easier to post. It depends on the
problem and the size of the data involved. Oh, please don't just
cut'n'paste the output from simply listing "msub" or "cn", that produces
output which cannot be cut and pasted easily into an R session. Thanks.


>
> Thanks for any help,
> Elahe
>
>

-- 
The unfacts, did we have them, are too imprecisely few to warrant our
certitude.

Maranatha! <><
John McKown

[[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] how to use AND in grepl

2016-05-02 Thread John McKown
On Mon, May 2, 2016 at 1:01 PM, ch.elahe via R-help <r-help@r-project.org>
wrote:

> I just changed all the names in Command to lowercase, then this
> str_extract works fine for "pd" and "t2", but not for "PDT2". Do you have
> any idea how I can bring PDT2  also in str_extract?
>

Looking at ​?grepl, I see the option: ignore.case=TRUE​

 PDT2=subset(df,grepl("(.*t2.*pd.*)|(.*pd.*t2.*)",df$
Command,ignore.case=TRUE)

Perhaps this will do the trick.

-- 
The unfacts, did we have them, are too imprecisely few to warrant our
certitude.

Maranatha! <><
John McKown

[[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] How to access the latitude & longitude for UK post codes in R

2016-04-29 Thread John McKown
On Fri, Apr 29, 2016 at 1:25 PM, Muhammad Bilal <
muhammad2.bi...@live.uwe.ac.uk> wrote:

> Hi All,
>
>
> I have a data frame with three columns i.e., pc, lat, lon.
>
>
> The pc column is populated with list of postcodes, and I want to execute R
> command that can get me the lat and lon for the every item in the pc column
> and populate the respective lat and lon columns.
>
>
> Is there any package that could be used?
>
>
> Any help will be really appreciated.
>
>
> Many Thanks and
>
>
> Kind Regards
>
> --
> Muhammad Bilal
> Research Fellow and Doctoral Researcher,
> Bristol Enterprise, Research, and Innovation Centre (BERIC),
> University of the West of England (UWE),
> Frenchay Campus,
> Bristol,
> BS16 1QY
>
> muhammad2.bi...@live.uwe.ac.uk<mailto:olugbenga2.akin...@live.uwe.ac.uk>
>
>
​I didn't find a package, but I did find this page:
https://www.freemaptools.com/map-tools.htm
If you scroll down to the UK section, you'll find:


   - Download UK Postcodes with Latitude and Longitude
   <https://www.freemaptools.com/download-uk-postcode-lat-lng.htm> -
   Download a list of UK out code postcodes with their latitude and longitude
   coordinates
   ​.​

On that page, you will find a link which will download a ZIP file which
contains a CSV file which says (I didn't download it) it contains the post
code, lat, long for the UK postcodes.
​You might be able to use that as a source for your own lookup code.​ I
found this via Google.


-- 
The unfacts, did we have them, are too imprecisely few to warrant our
certitude.

Maranatha! <><
John McKown

[[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] Query - 'R' for commercial use

2016-02-29 Thread John McKown
On Mon, Feb 29, 2016 at 10:37 AM, Vishal Vinayak Mujumdar 2 <
vmujumd...@sapient.com> wrote:

> Hello Sir,
>
> We are planning to recommend 'R' as solution for Micro Services
> implementation in one of the ongoing project.


​Sounds good to me.​



>


> Please can you assist us with providing information pertaining to license
> cost , commercial use , usage , warranty etc.
>

​licensing cost: completely free. The source is licensed under the GPL
version 2 or 3.

Commercial use: Allowed. Again ,no cost.​ However, as an aside, remember
that R is a _interpreter_ and not a _compiler_. This means that your
customers, if any, must receive the source in order to execute it. This may
be a consideration. Or, if this is via a "web" site as a service, it may
not. Internal use would not be any concern.

​Usage: Don't do evil! is about the only "usage". But, in reality, you can
use it however you want within its capabilities. I wouldn't used it to do
real time work, personally. If you want to use it as control software for a
nuclear reactor, please tell me so I can get a dosage meter to wear.

Warranty: If it breaks, you get to keep both pieces. That is, there is _no_
warranty at all. You _might_ be able to find a R consulting company which
will give you some sort of contract and include some sort of warranty. But
that is up to the consultant or consulting company. There is a bug
reporting system _for the community_. Which means that you can report a
bug, but there is no guarantee that anyone will every address it. OK, this
is latter _very_ unlikely to occur because the programmers et al. behind R
are conscientious, caring people.​ If you need a warranty, you'll need "3rd
party maintenance", if there is such from anyone.

Having said the above, there is no "damn it, I'm paying  for support
and I demand!! a fix NOW!" option (I've overhead this type of comment) .
I've even read message on some mailing lists similar to "I posted a
question 5 hours ago! Where's my answer? I'm in a hurry Don't you
people pay any attention?" That doesn't go over well here either.



>
> Thanks & Regards,
> Vishal Vinayak Mujumdar
> Specialist - Integration
> SCG Integration  Confluence<
> https://tools.sapient.com/confluence/display/ISCGCI/Integration+SCG+Home>
> | VOX<
> https://vox.sapient.com/groups/enterprise-integration-shared-services>
> Cell +1-617-331-4797
> --
> SapientNitro
>


-- 
The man has the intellect of a lobotomized turtle.

Maranatha! <><
John McKown

[[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] R Software Program Help

2016-02-23 Thread John McKown
On Tue, Feb 23, 2016 at 10:02 AM, Ashley Porter <
apor...@theplanetforward.com> wrote:

> Good Morning,
>
> I wanted to reach out as I am looking to learn more about the R Project / R
> Statistical Programming software, particularly as it's been utilizing in
> power plant industries. I work in the energy industry and my clients are
> starting to look for Risk Analysts proficient in this tool, and I find
> myself unaware of what this tool is. Any information or help would be
> greatly appreciated.
>
> Warmly,
>
>
> *Ashley Porter | Director of Recruiting*
>

​In a nutshell, it is a algorithmic programming language​ with an emphasis
on statistics. If you have heard of the SAS language, R is used for similar
needs. One of the main pluses of R is CRAN - The Comprehensive R Archive
Network. This is a large set of statistical packages, which can be used as
a library. A good web site is https://cran.revolutionanalytics.com/ to
start. A search of "r language review" will get you some good hits from
sites such as InfoWorld and NY Times as well as the usual "geek" sites.


-- 
The man has the intellect of a lobotomized turtle.

Maranatha! <><
John McKown

[[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] Subscribe to Post

2015-12-27 Thread John McKown
Yes. This is an _email_ group. It is not a web based discussion group.
There is an "archive" of emails somewhere around, but the proper (at least
IMO) way to ask a new question is to send a new email. A bit "old
fashioned", but in many way it is simpler for people on many different
types of computers (some of us are not Windows people!) to communicate.

And, very important, be sure to post in plain text. Avoid HTML encoded
email the the abomination that it is (IMO). They tend to be either ignored,
or replied to in a "corrective" way (i.e. you get a nasty note back for
some people).
​ What this means in most cases is that you cannot insert an "screen print"
as a "picture" (as you did in the email to which I am replying). That will
get nasty-grams. And eventually many of the really good R people will just
ignore you.​

​You can not longer post via Nabble (if you did in the past). It has
"abused" by way to many (the sending of HTML encoded email). ​


On Sun, Dec 27, 2015 at 4:06 AM, SHIVI BHATIA <shivi.bha...@safexpress.com>
wrote:
>
> Thanks John. Though I am in a fix now. Do I need to send in an email
every time for any help because I can’t find any URL to ask questions?
>
>
>
> I have tried the below URL’s: https://stat.ethz.ch/mailman/listinfo/r-help
- it only asks me to change or reset user preference.
>
>
-- 
Computer Science is the only discipline in which we view adding a new wing
to a building as being maintenance -- Jim Horning

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] exporting tables from an access database using parallel foreach

2015-11-21 Thread John McKown
On Sat, Nov 21, 2015 at 11:55 AM, Vivek Sutradhara <viveksu...@gmail.com>
wrote:

> Hi John and Jeff,
> Thanks a lot for your help. I agree that row numbers are not a standard
> feature in SQL. What I am looking for is some kind of a hack. After all,
> the sqlFetch command is able to return a specific number of rows. And the
> sqlFetchMore command is able to take up the baton from that row onwards to
> futher return rows corresponding to the max parameter.
>
> I wonder if it is possible to straight away hop to a certain row number
> (without going through sqlfetch and sqlFetchMore and without loading any
> data into memory) and then return the contents corresponding to a certain
> number of rows. The question is : is there a "catch" for accessing a row
> location, and what could be the "hook" for that? I am interested in the the
> recent updated rows to a table after a certain date. Is it possible to
> identify them in a quick way? Running sql queries on such large tables
> appears to take too long a time.
>
>  I understand that there is no provision to do this by available methods.
> But, is it possible to get under the hood and find some hack?
>

​Now you're talking about the internals of Microsoft Access. And you're
_way_ beyond my knowledge. Is there such knowledge? I sure there is. But,
unfortunately, once you get into that depth, you can get into real trouble
when (not if) MS decides to change the internals out from under you without
any warning at all. If you are really needing this, try looking the the
"MDB Tools" software at either https://github.com/brianb/mdbtools or
http://mdbtools.sourceforge.net/​ I don't think this does exactly what you
want, but it may give you the information you need to read the MDB file
yourself directly in R code. 

​What you would really want is something like the ROWID in SQLite. That is
a "system" maintained column in every table in SQLite. It is a 64-bit
unique number. Basically, it starts at 1 and increments every time you add
a new row.

What would be "best", IMO, would be if you could alter your Access database
to have a "serial" column which would be your "row number" You could then
get "directly" there by using a SELECT similar to:

SELECT * FROM table WHERE serial BETWEEN (first-row,last-row)



>
> Jeff, I will take your suggestion and try my luck at the R-sig-db mailing
> list.
> Thanks,
> Vivek
>
>
>
-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] exporting tables from an access database using parallel foreach

2015-11-20 Thread John McKown
My apologies, you wrote "access" and I read "Excel". I really should not
play a game on my smartphone while speed reading emails.

On Fri, Nov 20, 2015 at 11:38 AM, Vivek Sutradhara <viveksu...@gmail.com>
wrote:

> Hi
> I want to extract data from a Microsoft access database having many tables
> with more than 1e7 rows. I find that the following code works to export a
> table to a rds file :
> #
> setwd('C:/sFolder')
> library(RODBC);library(DBI)
> ch<-odbcConnect("sample")
>
> #No. of rows in the table not known
> rowN<-1e6  # no. of rows defined
> db<-sqlFetch(ch,"Table1",max=rowN,as.is=TRUE)
> file<-paste0('Table1',1,'.rds')
> df1<-saveRDS(db,file1)
>
> rm(db);gc()   # garbage collection to free up the memory
>
> # To successively obtain more chunks from the access database
> for (i in 2:10) {
>   rm(df);gc()
>   df<-sqlFetchMore(ch,"Table1",max=rowN,as.is=TRUE)
>   file<-paste0('Table1',i,'.rds')
>   df1<-saveRDS(df,file)
>   if (dim(df)[1]<rowN)
> break
> }
> rm(df);gc()
> odbcCloseAll()
> ##
>
> I would like to know the following :
> 1. Is there any way to extract data from a table by just specifying the row
> number range. I have extracted data before. Instead of repeating the
> operations, I would just like to obtain data from, let's say, 8e6 to 9e6
> row range. I cannot do this now. I have to successively use the
> sqlfetchMore command. I would like to know if it is possible to straight
> away go to the 8e6 to 9e6 row range.
> 2. Is it possible to use the foreach package in the extraction step (in
> place of the for loop above). I am planning to use the foreach command in
> parallel later for processing the data in the multiple files. I just wonder
> if it is possible to do parallel processing for the data extraction also.
> Thanks,
> Vivek Sutradhara
>
> [[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.
>



-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] exporting tables from an access database using parallel foreach

2015-11-20 Thread John McKown
A possibility could be to not use ODBC, but the CRAN package openslsx (
https://cran.revolutionanalytics.com/web/packages/openxlsx/index.html ).
Then use the read.xlsx() function.

Description Read data from an Excel file or Workbook object into a
data.frame

Usage read.xlsx(xlsxFile, sheet = 1, startRow = 1, colNames = TRUE,
rowNames = FALSE, detectDates = FALSE, skipEmptyRows = TRUE, rows = NULL,
cols = NULL, check.names = FALSE, namedRegion = NULL)

Arguments xlsxFile An xlsx file or Workbook object sheet The name or index
of the sheet to read data from.
startRow first row to begin looking for data. Empty rows at the top of a
file are always skipped, regardless of the value of startRow.
colNames If TRUE, the first row of data will be used as column names.
rowNames If TRUE, first column of data will be used as row names.
detectDates If TRUE, attempt to recognise dates and perform conversion.
skipEmptyRows If TRUE, empty rows are skipped else empty rows after the
first row containing data will return a row of NAs.
rows A numeric vector specifying which rows in the Excel file to read. If
NULL, all rows are read.
cols A numeric vector specifying which columns in the Excel file to read.
If NULL, all columns are read.
check.names logical. If TRUE then the names of the variables in the data
frame are checked to ensure that they are syntactically valid variable
names
namedRegion A named region in the Workbook. If not NULL startRow, rows and
cols paramters are ignored.


On Fri, Nov 20, 2015 at 11:38 AM, Vivek Sutradhara <viveksu...@gmail.com>
wrote:

> Hi
> I want to extract data from a Microsoft access database having many tables
> with more than 1e7 rows. I find that the following code works to export a
> table to a rds file :
> #
> setwd('C:/sFolder')
> library(RODBC);library(DBI)
> ch<-odbcConnect("sample")
>
> #No. of rows in the table not known
> rowN<-1e6  # no. of rows defined
> db<-sqlFetch(ch,"Table1",max=rowN,as.is=TRUE)
> file<-paste0('Table1',1,'.rds')
> df1<-saveRDS(db,file1)
>
> rm(db);gc()   # garbage collection to free up the memory
>
> # To successively obtain more chunks from the access database
> for (i in 2:10) {
>   rm(df);gc()
>   df<-sqlFetchMore(ch,"Table1",max=rowN,as.is=TRUE)
>   file<-paste0('Table1',i,'.rds')
>   df1<-saveRDS(df,file)
>   if (dim(df)[1]<rowN)
> break
> }
> rm(df);gc()
> odbcCloseAll()
> ##
>
> I would like to know the following :
> 1. Is there any way to extract data from a table by just specifying the row
> number range. I have extracted data before. Instead of repeating the
> operations, I would just like to obtain data from, let's say, 8e6 to 9e6
> row range. I cannot do this now. I have to successively use the
> sqlfetchMore command. I would like to know if it is possible to straight
> away go to the 8e6 to 9e6 row range.
> 2. Is it possible to use the foreach package in the extraction step (in
> place of the for loop above). I am planning to use the foreach command in
> parallel later for processing the data in the multiple files. I just wonder
> if it is possible to do parallel processing for the data extraction also.
> Thanks,
> Vivek Sutradhara
>
> [[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.
>



-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] *.rpt data

2015-11-12 Thread John McKown
On Thu, Nov 12, 2015 at 7:52 AM, PIKAL Petr <petr.pi...@precheza.cz> wrote:

> Hi
>
> If it is really "like" csv data you can import it by
>
> read.csv...
>
> or you can use any other read.* function.
>
> Did you try it? If yes, what was the result?
> If not, why not?
>
> Cheers
> Petr
>

​Purely as a guess, ".rpt" really seems to be short for "report". Which I
would guess indicates that this is some sort of file which was originally
physically printed to be read by a human. So I would _guess_ that perhaps
it is column oriented and might be readable using read.fwf() .Or course, it
if really is a "report" there are those irritating page headers & footers,
perhaps along with a summary at the end which would need to be ignored. The
OP really needs to cut'n'paste (NO HTML PLEASE!) about 10 lines for us to
all "eyeball".​


-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] Announcement - The Use Of Nabble For Posting To R-Help Will No Longer Be Supported Effective October 15, 2015

2015-10-01 Thread John McKown
+1

On Thu, Oct 1, 2015 at 5:55 AM, Marc Schwartz <marc_schwa...@me.com> wrote:

> Greetings all,
>
> On behalf of The R Foundation for Statistical Computing, this is an
> announcement that, effective October 15, 2015, the Nabble online forums
> will no longer be a supported vehicle for posting new threads and/or
> replying to existing threads on R-Help.
>
> This decision was not made lightly and is the result of issues that have
> developed over the past several years. These issues include:
>
> 1. The lack of any context for thread-replies in posts submitted via
> Nabble. This compels readers to take extra time to click on a link in the
> post and visit the Nabble web site to read the reply in context. Many
> email-based R-Help users do not take the time to do this, and therefore do
> not reply to Nabble-based posts.
>
> 2. The use of Nabble by a number of folks who have not subscribed to the R
> email lists directly. Since subscriptions to the R email lists are required
> for posting, these posts are held for moderation, which results in a
> substantial increase in the workload of the **volunteer** list moderators.
> The moderators must take additional time to log into the administrative web
> site interfaces for the R lists to manually review, and approve or reject,
> posts submitted via Nabble.
>
> 3. An increasing level of both publicly and privately expressed animosity
> and frustration on the R lists towards Nabble-based posts because of the
> above and related issues.
>
> Over the past several months, the R Foundation, in cooperation with
> Nabble, has incrementally removed the ability of multiple Nabble archives
> to post new threads on the R email lists, respond to existing threads, and
> privately reply to authors via the Nabble web site.
>
> R-Help, because it is the highest volume of the R lists, is the last R
> email list to undergo this transition. We are announcing the change two
> weeks in advance to afford Nabble users the opportunity to directly
> subscribe to and use the R email-based support lists in the manner
> originally intended.
>
> Information on the various R email lists, including R-Help, is available
> here:
>
>  https://www.r-project.org/mail.html
>
> The existing relevant Nabble archives will become just that -- read only
> and searchable archives -- as a valuable alternative to other R email list
> archives that are available online.
>
> We wish to express our sincere thanks to Hugo Teixeira at Nabble for his
> assistance over the past several months in this process.
>
> For those folks who prefer to use a web-based interface for R-related
> support matters, as opposed to email-based interactions, StackOverflow, as
> one example, provides such a vehicle at:
>
>  http://stackoverflow.com/questions/tagged/r
>
> For those who have general statistical support queries, as per the R
> Posting Guide, StackExchange/Cross Validated at:
>
>  http://stats.stackexchange.com
>
> provides a similar platform.
>
> The R Foundation does not support or endorse the above third-party
> resources, but is simply mentioning them as popular, web-based alternatives
> to the R email lists, which remain our recommended vehicles for focused
> community support for R.
>
> Thank you,
>
> Marc Schwartz
> On Behalf of the R Foundation for Statistical Computing
>
> __
> 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.
>



-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] R applications deployment models?

2015-09-28 Thread John McKown
On Mon, Sep 28, 2015 at 9:19 AM, Jeff Newmiller <jdnew...@dcn.davis.ca.us>
wrote:

> I am not necessarily referring to the business model (though many people
> asking this question are), but rather the install-to-bare-os deployment
> model that controls the user experience throughout. You typically need to
> install R as a separate product and use it interactively to kick your
> "application" into gear, should you choose to develop such.
>

​Thanks. That helps me understand better. A difficult task on a Monday
morning after coming back from vacation! ​


-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] R applications deployment models?

2015-09-28 Thread John McKown
On Mon, Sep 28, 2015 at 8:15 AM, Jeff Newmiller <jdnew...@dcn.davis.ca.us>
wrote:

> R is not designed as an application development programming language.


​This is an interesting statement to me. I don't really understand it. I
have developed some applications in R. Do do you mean _commercial_
applications (i.e. something paid for)?​ I think of R a bit like I think of
SAS (which may be stupid of me). There are some commercial SAS applications
(one that I know of is MXG for doing performance analysis and reporting on
a specific OS - z/OS, which runs on IBM z series "mainframes").

​​


-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] Running R on a hosting o server

2015-09-23 Thread John McKown
On Tue, Sep 22, 2015 at 2:55 PM, bgnumis bgnum <bgnu...@gmail.com> wrote:

> Hi all,
>
> Hope I can Explain:
>
> I want to "run" online some function (code written by me) so that this code
> "saves" an output file on my server and my html webpage read the file R
> plots and save (really manually I would run R function, open Filezilla, and
> pass the output png o jpg file).
>
> Is it possible to do this "authomatically" telling R, something like each
> 15 minutes run this "pru.txt" file, and take save this plot.png and execute
> filezilla with this inputs and save the plot in this folder?
>

​In Linux (or any UNIX like system), you can schedule tasks to be run by
using "cron" (do a "man crontab" for some information, if you need to). So,
if you can make a "shell script" which does all of your work without user
input, then you can use "cron" to schedule it periodically, every "n"
minutes, daily, weekly on ???day, monthly, etc. I don't know Filezilla, so
I don't know what you are really doing with it.

Windows has a similar scheduler to run "bat" files or "Power Shell"
scripts.​ I don't _DO_ Windows!  ->  -> 

Mac OSX - not a fanboy, try somebody else. 



>
> Hope you can understand me.
>
> In rmarkdown it is true that output html file but my intention is tu run my
> own function and the need is to run my function in R, and run and open
> filezilla and deposit the file in the right place.
>
>
​If you are using Filezilla to copy a file, where is it being copied to? In
UNIX, I'd see if I could use just the plain "cp" command (for local, NFS,
or CIFS attached places) or either the "ftp" or "scp" command to copy to a
different server. In Windows the "copy" command could be used to copy the
file to a different folder locally or on a "share" (Windows "share" is,
more or less, the same as UNIX CIFS, if you're interested)​. Again, if this
needs to go to some other server, then a scripted "ftp" should work. One of
my co-workers does this.

-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] Extract from data.frame

2015-09-21 Thread John McKown
On Mon, Sep 21, 2015 at 9:52 AM, Nico Gutierrez <nico.gutierr...@gmail.com>
wrote:

> Hi All,
>
> I need to do the following operation from data.frame:
>
> df <- data.frame(Year = c("2001", "2002", "2003", "2004", "2005", "2006",
> "2007"), Amount = c(150, 120, 175, 160, 120, 105, 135))
> df[which.max(df$Amount),]  #to extract row with max Amount.
>
> Now I need to do 3 years average around the max Amount value (ie:
> mean(120,175,160))
>
> Thanks!
> N
>
>
​The simplistic answer is something like:

df <- structure(list(Year = structure(1:7, .Label = c("2001", "2002",
"2003", "2004", "2005", "2006", "2007"), class = "factor"), Amount = c(150,
120, 175, 160, 120, 105, 135)), .Names = c("Year", "Amount"), row.names =
c(NA,
-7L), class = "data.frame");
wdf <- which.max(df$Amount);
adf3 <- mean(df$Amount[adf-1:adr+1]);

But that ignores the boundry condition where the maximum is at either end.
What do you want to do in that case?​


-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] Spreadsheet math problem (exponentiation)

2015-09-18 Thread John McKown
On Fri, Sep 18, 2015 at 8:39 AM, John Kane <jrkrid...@inbox.com> wrote:

> It appears that at least three major spreadsheets, Excel, Apache
> OpenOffice Cal and gnumeric have a problem with the correct order of
> operations when dealing with exponents. The gnumeric result is very strange.
>
> This problem has probably been reported before but just in case it has
> not, it would appear to be one more serious problem with spreadsheets. It
> might be useful in warning people away from using a spreadsheet for serious
> analysis.
>
> Excel
>
> -2^2 = 4
>
> 2^2^3 = 64
>
> Apache OpenOffice
>
> -2^2 = 4
>
> 2^2^3 = 64
>

My opinion: One correct, one error!​ R agrees with me on this:
> 2^2
[1] 4
> 2^2^3
[1] 256
> 2^(2^3)
[1] 256
> -2^2
[1] -4
> (-2)^2
[1] 4
>




>
> gnumeric # note one correct, one error!
>

​My opinion: two correct!​



>
> -2^2 = 4
>
> 2^2^3 = 256
>
> John Kane
> Kingston ON Canada
>
>
​Seems to be a bit off-topic. Unless your point to is to use R for
important work instead of some spreadsheet. A point with which I completely
agree!​


​MS-Excel, and Apache OpenOffice, appear to implement the above as
(2^2)^3==64. ​Whereas gnumeric implements appears to implement this as:
2^(2^3)==256. Which is "correct"? Depends on whom you ask.

ref: https://en.wikipedia.org/wiki/Order_of_operations


If exponentiation is indicated by stacked symbols, the usual rule is to
work from the top down, thus:
[image: a^{b^c} = a^{(b^c)}],

which typically is not equal to [image: (a^b)^c]. However, some computer
systems may resolve the ambiguous expression differently. For example,
Microsoft
Office Excel <https://en.wikipedia.org/wiki/Microsoft_Office_Excel>
 evaluates *a*^*b*^*c* as (*a*^*b*)^*c*, which is opposite of normally
accepted convention of top-down order of execution for exponentiation. If
a=4, p=3, and q=2, [image: a^{p^q}] is evaluated to 4096 in Microsoft Excel
2013, the same as [image: (a^p)^q]. The expression [image: a^{(p^q)}], on
the other hand, results in 262144 using the same program.


​Gnumeric abides by the above definition. FWIW. BTW - MS-Excel also has
1900 as a friggin' leap year (due to Lotus 1-2-3 apparently), so I don't
consider MS-Excel (or anything else from MS for that matter) to be a
definitive source of correctness.​ Personal opinion. FSF associate member.
Penguinista.

-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] Spreadsheet math problem (exponentiation)

2015-09-18 Thread John McKown
On Fri, Sep 18, 2015 at 11:06 AM, Erich Neuwirth <
erich.neuwi...@univie.ac.at> wrote:

> Methinks that any math teaching should make learners aware of the fact that
> math conventions are not laws of nature, and that ambiguous expressions may
> produce different values in different systems.
>
> I think -2^2=4 is perfectly reasonable.
>

​I agree. That is what APL would do. Of course, the number "minus 2" in APL
is not encoded as "-2". It is encoded (hope this works) ¯2 ​This removes
the ambiguity.​



>
> In my experience, most people after high school math do not know that
> binary - und unary - are very different operations.
> And that is the fault of the current way of teaching math!
>

​Agree. Perhaps we should just "bite the bullet" and go with Reverse Polish
Notation for equations. Much easier to parse. No parentheses and no
ambiguities. Of course, this would raise more howls that converting from
Imperial measures to Metric did. ​We still haven't done this in the U.S. I
really want to! I sound much taller and thinner in metric. No, I won't say
what the number are. Bad enough that I'm old.


-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] Spreadsheet math problem (exponentiation)

2015-09-18 Thread John McKown
On Fri, Sep 18, 2015 at 10:04 AM, David L Carlson <dcarl...@tamu.edu> wrote:

> Unfortunately the order of operations is not universal in computing. The
> real question is whether a program performs the way it is documented. Excel
> documents that unary operations take precedence over exponentiation and
> that within groups, the order is left to right. LibreOffice Calc behaves as
> Excel, but does not document the order of operations except to say */
> before +-, left to right. I couldn't find any statement about the order of
> operations in the documentation for Gnumeric.
>
> R documents that unary operations come after exponentiation and, within
> exponentiation, the order is right to left. Fortran puts unary operations
> with addition and subtraction after exponentiation with exponentiation
> right to left. C does not have an exponentiation operator, but unary
> operations come before multiplication and division.
>
> When in doubt, use parentheses to make sure you get what you want.
>
>
​Very true. I do that if there is almost any chance that I, or another,
might not actually know which is first. I especially adopted this when I
learned a language called APL. It has _no_ precedence of operations. And it
does them from right to left. E.g. A=B*C+D is interpreted as A=B*(C+D). I
did programming in it for a couple of months. Then went back to normal
programming. Wrote completely _wrong_ code. When I asked a friend why the
calculation didn't get the "right" answer (2*4+3 == 14 was example I gave),
he looked at me like I was insane . ​


-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] c(1:n, 1:(n-1), 1:(n-2), ... , 1)

2015-09-17 Thread John McKown
I'm not too sure this is any better:

n<-5
c<-0; # establish result as numeric
for(i in seq(n,1,-1)){ c<-c(c,seq(1,i)); str(c); }; #generate array
c<-c[2:length(c)]; #remove the leading 0

If you're a fan of recursive programming:

> mklist <- function(x) { if (x==1) return(1) else return(
c(seq(1,x),mklist(x-1)) ) ; }
> mklist(5);
 [1] 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
>

Of course, I've not done any error checking in my function definition. And,
for large values, it can nest too deeply and get

Error: evaluation nested too deeply: infinite recursion /
options(expressions=)?


On Thu, Sep 17, 2015 at 1:19 PM, Dan D <ddalth...@usgs.gov> wrote:

> Can anyone think of a slick way to create an array that looks like c(1:n,
> 1:(n-1), 1:(n-2), ... , 1)?
>
> The following works, but it's inefficient and a little hard to follow:
> n<-5
> junk<-array(1:n,dim=c(n,n))
> junk[((lower.tri(t(junk),diag=T)))[n:1,]]
>
> Any help would be greatly appreciated!
>
> -Dan
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/c-1-n-1-n-1-1-n-2-1-tp4712390.html
> Sent from the R help mailing list archive at Nabble.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.
>



-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] Issues with RPostgres

2015-08-27 Thread John McKown
On Thu, Aug 27, 2015 at 2:29 PM, Abraham Mathew mathewanalyt...@gmail.com
wrote:

 I have a user-defined function that I'm using alongside a postgresql
 connection to
 summarize some data. I've connected to the local machine with no problem.
 However,
 the connection keeps throwing the following error when I attempt to use it.
 Can anyone point
 to what I could be doing wrong.

  ds_summary(con, test, vars=c(Age), y=c(Class))
 Error in postgresqlNewConnection(drv, ...) :
   RS-DBI driver: (could not connect postgres@localhost on dbname test
 )


 con is the connection


​It would be helpful to see the assignment to con as well as any other
assignments related to this. If you are using the DBI package, then what I
am talking about would be something like:

drv-dbDriver(PgSQL)
con-dbConnect(drb,user=...,password=...,dbname=test');

From looking at the message, it appears to me that you are trying to
connect to PostgreSQL as the postgres user. That just seems wrong to me.
Normally that user is only for administration purposes. It does not
normally contain user tables such as test. I would think that what you
needed would be your PostgreSQL user id. Or the id of the owner of the
test table.​




 test is the database table
 age is the attribute that will be summarized
 class is the response variable

 Can anyone help?


 --


 *Abraham MathewData Ninja and Statistical Modeler*



 *Minneapolis, MN720-648-0108@abmathewksAnalytics_Blog
 https://mathewanalytics.wordpress.com/*

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




-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] How to download this data

2015-08-25 Thread John McKown
FWIW. This violates their terms of service, unless you have their
permission:

http://www.nseindia.com/global/content/termsofuse.htm

quote

You may not conduct any systematic or automated data collection activities
(including scraping, data mining, data extraction and data harvesting) on
or in relation to our website without our express written consent.

quote/

On Tue, Aug 25, 2015 at 1:10 PM, Christofer Bogaso 
bogaso.christo...@gmail.com wrote:

 Hi,

 I would like to download data from below page directly onto R.


 http://www.nseindia.com/live_market/dynaContent/live_watch/equities_stock_watch.htm

 Could you please assist me how can I do that programmatically.

 Thanks for your time.

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




-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] Running R in Server

2015-08-18 Thread John McKown
On Sun, Aug 16, 2015 at 3:27 AM, Swagato Chatterjee swagato1...@gmail.com
wrote:

 Hello,

 I have written a R script which runs a regression of a dataset and saves
 the result in a csv file.

 Now this dataset has to be edited periodically which is done in a server. I
 need to run the R script in a server so that the results can also be shared
 in a server and used in a web application.

 I have coded in R and have used R in windows. I have never used
 Ubuntu/Linux. Is there a step by step guide on how to run a R code in
 server?

 Thanks and Regards,

 Swagato


I
​ was going to answer yesterday, but work went insane. Also, I was hoping
someone else had something, because I don't have any step by step
instructions.

This is a rather complicated question. So I'm going to ask a number of
questions and make some statement for you to correct, if necessary.​

​Statement: You have a Windows desktop and have used R on it, so you are
familiar with R in a Windows environment.​
Statement: You are not Linux (Ubuntu) trained.
Statement: You wrote an R script on Windows, which works, but you need to
run it on Ubuntu.

The above is my starting point. Now I have some questions.

Can you connect to the Ubuntu server from your Windows desktop? If so, how?
If not, I'm confused about how you could get anything to run on the Ubuntu
server.

Where does this dataset reside? On you desktop? On a Windows shared
folder? On the Ubuntu server? Other?

Who or what edits the dataset? That is, is it always yourself? Some one
in your group? Some other human? Some automated process?

Why can't you run the R script as you do now, then deploy the results to
the Ubuntu server? Since I don't know the environment that the Ubuntu
server runs in, I can't address how to deploy an updated file into it. I
assume you have some sort of deployment software. It could be as easy as
being able to ftp the results from your desktop to the proper places on the
Ubuntu server.

​===

Now, whatever the answers are to the above, you'll likely need some help
from your Ubuntu server people. My first approach, given my ignorance,
would be that I would have something set up so that you could edit this
dataset on your desktop (assuming that's what you do). I would then have
you ftp it ​to a special directory on the Ubuntu server set up especially
for this function. Now, what remains would be running the R script, likely
in a shell script (like a PowerShell command file), whenever you do the
ftp. There is a function in Ubuntu (any Linux) called icrond. This is a
daemon (Windows service equivalent) which can monitor a file or directory
for changes. When a change is detected it can take an action. In this case
it would be to schedule the execution of the previously mentioned shell
script. The shell script would then take the actions necessary to do the
R script (R CMD script-name parameters ... for instance) and then deploy
the results to the web server (however you normally do this).  Setting up
the icrond environment is going to take some work by your Ubuntu
administrator.

===

I hope this was at least the start of some help to you.




-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] Problem with path.expand(~)

2015-08-11 Thread John McKown
.




-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] Course: Introduction to zero inflated models

2015-08-04 Thread John McKown
On Tue, Aug 4, 2015 at 7:05 AM, Highland Statistics Ltd 
highs...@highstat.com wrote:

 Apologies for cross-posting


​Apologies for UCE does not make it any less objectionable.​ But I would
love a working vacation in the U.K.

-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] setwd() command on windows vs. linux/unix

2015-07-27 Thread John McKown
On Mon, Jul 27, 2015 at 2:38 PM, Chris chris.bar...@barkerstats.com wrote:


 I have a script that runs correctly (no errors) on Windows, the first
 command is a setwd(.windows directory)I installed the script on a
 Linux machine and changed the windows directory reference to the correct
 directory on the linux machine.when I ran the script I got a message that
 cannot change working directory. I confirmed I have read and write access
 to the directory.I mainly run R on windows infrequently use linux/unix and
 would appreciate suggestions.thanks in advance Chris Barker, Ph.D.
 Adjunct Associate Professor of Biostatistics - UIC-SPH


​I took a quick look at the source where I _think_ the message is coming
from: src/main/util.c . That message comes out when the chdir() function (C
library routine) returns any kind of error.​ Because you said that have
read  write access (you should also have execute in most cases), then the
only return which makes sense is ENAMETOOLONG (although it could also be
ENOMEM). How long is the path name? The usual limit is 255 bytes.



-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] Read .xlsx and convert date-column value into Dataframe

2015-07-22 Thread John McKown
Those numbers are a serial number of days. A value of 1 maps to Jan 1,
1900. ref:
https://support.office.com/en-za/article/DATE-function-e36c0c8c-4104-49da-ab83-82328b832349

A formula such as: as.Date('1900-01-01')+excel_date-1 should convert the
serial value to a date value.

On Wed, Jul 22, 2015 at 7:09 AM, R_Antony antony.akk...@ge.com wrote:

 Hi,

 Here i am having a .xlsx file and it contains various columns including
 date-column[mm/dd/yy]-but it is not in the date format. I have to read this
 excel[.xlsx] file and need to get in dataframe. So i used xlsx-liabrary
 and it was fine to read data. But the problem is, values in the date column
 is converting to some other value.

 for eg:-

 FF DATE
 ---
 3/31/2016
 2/26/2016
 --
 1/2/2016

 [Values like -- will come in the column to indicate that there is no date
 mentioned ]

 and i getting result like this,

 FF DATE
 ---
 42460
 42426

 42125

 this is the code i am using for it,

 theData-data.frame(read.xlsx2(InputFilePath, sheetIndex,
 sheetName=Workflow_Report, startRow=3,colIndex=NULL, endRow=NULL,
 as.data.frame=TRUE, header=TRUE))

 Aim :- I have to get actual date-column values in dataframe from xlsx
 file.

 I tried many ways, Could someone please help ?

 Thanks in advance,
 Antony.




 --
 View this message in context:
 http://r.789695.n4.nabble.com/Read-xlsx-and-convert-date-column-value-into-Dataframe-tp4710192.html
 Sent from the R help mailing list archive at Nabble.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.




-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] matching strings in a list

2015-07-16 Thread John McKown
On Thu, Jul 16, 2015 at 12:40 PM, tryingtolearn inshi...@ymail.com wrote:

 Say I have a list:
 [[1]] I like google
 [[2]] Hi Google google
 [[3]] what's up

 and they are tweets. And I want to find out how many tweets mention google
 (the answer should be 2).
 If I string split and unlist them, then I would get the answer of 3. How do
 I make sure I get just 2?


​NROW(grep(google,list,ignore.case=TRUE))​


-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] matching strings in a list

2015-07-16 Thread John McKown
On Thu, Jul 16, 2015 at 1:00 PM, John McKown john.archie.mck...@gmail.com
wrote:

 On Thu, Jul 16, 2015 at 12:40 PM, tryingtolearn inshi...@ymail.com
 wrote:

 Say I have a list:
 [[1]] I like google
 [[2]] Hi Google google
 [[3]] what's up

 and they are tweets. And I want to find out how many tweets mention google
 (the answer should be 2).
 If I string split and unlist them, then I would get the answer of 3. How
 do
 I make sure I get just 2?


 ​NROW(grep(google,list,ignore.case=TRUE))​


​Or

sum(grepl(google,x,ignore.case=TRUE))

-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] open connection to system

2015-07-14 Thread John McKown
On Tue, Jul 14, 2015 at 11:45 AM, Adrian Dușa dusa.adr...@unibuc.ro wrote:

 Dear list,

 Probably not the best subject line, but hopefully I can explain.
 I would like to use R and open a connection to a (system) command line base
 chess engine
 (for example, there is an open source one at stockfishchess.org)

 In the Terminal window (using MacOS), I can type two commands:

 $ ./stockfish-6-64 -- this is the first command
 Stockfish 6 64 by Tord Romstad, Marco Costalba and Joona Kiiski
 go movetime 3000 -- this is the second command

 (then lots of lines calculated by the engine, with a final answer after 3
 seconds)

 First command opens a connection to the chess engine, the seconds one tells
 it to search for a move.
 The question is, can I do this via R?

 I tried the system() command, which works with the first command:
  system(./stockfish-6-64, intern=TRUE)
 [1] Stockfish 6 64 by Tord Romstad, Marco Costalba and Joona Kiiski

 but it closes the connection and returns an error if I attempt the second
 command:

  system(./stockfish-6-64\ngo movetime 3000, intern=TRUE)
 Error in system(./stockfish-6-64\ngo movetime 3000, intern = TRUE) :
   error in running command
 sh: line 1: go: command not found


 Any hint would be really appreciated, thanks in advance,
 Adrian

 --
 Adrian Dusa
 University of Bucharest


What system() does is run a command  wait for it to end. ​I take it you
are running on a Mac. Do you want to send multiple command to stockfish,
or only one command? If the latter, you can do something like:

commands=c(go movetime 3000);
system(./stockfish-6-64,intern=TRUE,input=commands);

​If you want to send a number of commands, and not interact with the
stockfish command, you can:

commands=c(first command,second command); # and so on
system(./stockfish-6-64,intern=TRUE,input=commands);

But if you want to interact with stockfish, that's much more difficult
and I don't have any example available. I _think_ you'd need to look at
using mcparallel() and the parallel package. Or maybe the
socketConnection() function in some way. ​



-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] Can't post to the list

2015-07-09 Thread John McKown


 On Thu, Jul 9, 2015 at 6:04 AM, Maram Salem marammagdysa...@gmx.com
 wrote:
 
  Dear Rolf,
  I recieved this message exactly:
  The message's content type was not explicitly allowed


 I'm just guessing here! But this list is plain text only. I wonder if
 your email client sometimes uses unsupported MIME types. Again, I'm no
 expert, but this might be if it included screen pictures in JPG format
 (Windows loves these from the Print Screen button). Or maybe BASE64 or
 UUENCODEd somehow. If the listserv software detect this, and postings with
 that type of data are not in the setup as explicitly allowed, then maybe.

 Here's a similar discussion which may be of interest:


 https://mailman-1.sys.kth.se/pipermail/gromacs.org_gmx-developers/2012-August/006176.html

 quote
 ...

 
  If you have received rejected mails saying The
  message's content type was not
  explicitly allowed it means that you have used in
  your mail special styles or
  formatting (e.g. bold typeface, colors etc.).
 

 ...

 /quote



 
 
  Thanks for your concern,
 Maram

 Sent from my iPhone


-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] Common install of R on network disk

2015-07-07 Thread John McKown
On Tue, Jul 7, 2015 at 2:42 AM, Lionel SPINELLI spine...@ciml.univ-mrs.fr
wrote:

 Hello all,


 I am looking for information on how to install R on a network disk so that
 it can be used by several users mounting this network disk from different
 computers.

 We are using a cluster and shared computers in my lab. Those machines can
 mount network disks. On those disks we have installed several tools, like
 samtools that can be used from any user and from any machine since they
 have installs that do no required any system libraries.

 We would like to do the same thing with R: have a folder in the network
 disk that contains R (and its libraries) and that permits to execute it
 from any machine that mount the network disk. However, it seems R uses
 system libraries since, once the installation done we obtain the following
 message when trying to execute it from a different machine than the one
 from which R was installed:

  error while loading shared libraries: libicuuc.so.52: cannot open shared
 object file: No such file or directory

 This library seems present on the machine executing R but seems not found
 the same. We did not found any info on how to set a lib path in order to
 put that library with the R install.

 Do you know any reference that explain how to successfully achieved the R
 install as we would like to?


 Thanks a lot in advance


First, I am assuming that all the clients are running the same OS at the
same, or compatible, levels. I am also assuming Linux, but that may be
pushing it. What I _think_ will work (I can't test it where I am now) is to
set the LD_LIBRARY_PATH environment to include the directory which contains
the libicuuc.so file.

For a possible example, suppose libicucc.so is in the directory
/network/disk/R-installation/lib, then try the command (I am using BASH):

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}${LD_LIBRARY_PATH+:}/network/disk/R-installation/lib
R

Yes, the above is _ugly_. An easier way might be do to the following (as
root) on all the systems which want to run R (# is the command prompt for
root, not something you type in!)

# echo /netwrok/disk/R-installation/lib /etc/ld.so.conf.d/R-network.conf
# ldconfig

What the above does is add the directory /network/disk/R-installation/lib
(which contains the R shared libraries) to the directories automatically
searched for shared libraries. You can add more that one directory name,
each on a separate line, into the R-network.conf file. Oh, the name of the
file can be anything you like but must be in the directory
/etc/ld.so.conf.d and end in .conf. E.g. R-network.conf or
myIdiotBrother.conf would both work.

# echo /network/disk1/R-installation/lib
/etc/ld.so.conf.d/R-network.conf
# echo /network/disk2/R-2nd/lib /etc/ld.so.conf.d/R-network.conf
# echo /some/other/directory/entirely /etc/ld.so.conf.d/R-network.conf
# ldconfig

would add the three mentioned directories.


This stackoverflow discussion might be of some help as well:
http://stackoverflow.com/questions/13428910/how-to-set-the-environmental-variable-ld-library-path-in-linux






 [http://sesame.univ-amu.fr/Logos/logo_sciences.jpg]

 Lionel Spinelli - Ingénieur de recherche en bioinformatique
 UMR_S 1090 TAGC  et  UMR_S 1104 CIML

 Aix-Marseille Université - LUMINY - 163 Avenue de Luminy - 13009 Marseille

 Tél: +33(0)4 91 82 87 12 (TAGC) / +33(0)4 91 26 91 90 (CIML)

 Site : http://www.univ-amu.frhttp://www.univ-amu.fr/ - Email :
 lionel.spine...@univ-amu.frmailto:lionel.spine...@univ-amu.fr


-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] Invalid URL for R documentation

2015-07-06 Thread John McKown
I get a 404 on that page as well. Curiously, the R-patched and R-devel
links work. Looks like the webmaster has some work to do!

The pages are still available on the Revolution Analytics mirror site:
http://cran.revolutionanalytics.com/

On Mon, Jul 6, 2015 at 10:10 AM, Paul paul.domas...@gmail.com wrote:

 I tried accessing http://cran.r-project.org/doc/manuals/r-release/R-
 intro.html, which is linked to from http://cran.r-
 project.org/manuals.html.  I get the message that the URL could not be
 found by the server. Just wondering if I'm doing something stunningly un-
 smart (it would not be the first time).

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




-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] help for lay person assisting R user with disability

2015-06-18 Thread John McKown
On Thu, Jun 18, 2015 at 9:32 AM, Courtney Bryant cbry...@andrew.cmu.edu
wrote:

 Good Morning,
 I am currently working with a disabled R user who is a student here at
 CMU.  The student has both sight and mobility issues.  The student has
 asked for an assistant who is well versed in R to enter data for her, which
 we are having a hard time finding.  I would like information from R
 developers/users about how/how well R interfaces with Excel (an easier
 skill set to find!)   In your opinion, could it be as easy as uploading
 data from excel into R?

 Also, do you know of a way to enlarge the R interface or otherwise assist
 in making the program accessible to a low vision person?  My  limited
 understanding leads me to believe that screen magnifiers like zoom text
 don't work particularly well.  If you have information on that, I would
 very much appreciate it.

 Thanks for your help and for bearing with me!
 Courtney


I am a bit confused (a normal condition for me). Is the student writing R
code or is the student running a application written in R? Also, since you
mentioned Excel, I am assuming that the student is using a PC running
Windows as opposed to Linux or a Mac.

If the student is writing R code, then I'd suggest that your computer
support person install Rstudio. It is cost free and can be downloaded here:
http://www.rstudio.com/ . The installer can then customize Rstudio to use a
really large font, if that would be helpful. Please forgive my lack of
knowledge about accessibility issues. If the student has trouble typing
(mobility issue?), this likely won't help. Would a speech to text / text to
speech interface help instead of a screen magnifier? I know next to nothing
about these tools, other than that they exist.

===

If the student is running an R application (which is what enter data for
her implies to me), then any accessibility issues would need to be
addressed in the application itself. But I don't understand why a data
entry assistant would need any skills in R itself in order to enter data
into it. But without knowing more, that's about all that I can say. One
thought: CMU has a college teaching electrical and computer engineering.
Depending on what that means, perhaps someone from that college (professor,
TA, or grad student) could see what your student is doing and perhaps have
some insights on how to help. Or is there a computer club on campus where
some geeky student might be found? You might look here:
http://www.club.cc.cmu.edu/ If these are true geeks (and the web site
sounds promising), then a lure of beer  pizza would likely be irresistible
grin.

===

For interfacing R with Excel, you might want to look at RExcel here:
http://rcom.univie.ac.at/download.html#RExcel . It has a free student
version. But is this more for an Excel user who wants to use R for
analysis, not an R user wanting to use Excel for data entry.



-- 
Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

My sister opened a computer store in Hawaii. She sells C shells down by the
seashore.
If someone tell you that nothing is impossible:
Ask him to dribble a football.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] how to reach a txt file like this?

2015-06-09 Thread John McKown
On Tue, Jun 9, 2015 at 11:24 AM, Ye Lin ye...@lbl.gov wrote:

 ​Hey All, I have a txt data file that looks like this:

 ​[{“ID”:“A”,“Name:Tom, Age:18},{“ID”:“B”,“Name:Jim, Age:19}]


 ​How can I read this into R as a data frame? I have used readLines to read
 all the lines but dont know how to deal with column names and inputs.


​That looks like a JSON array of objects to me. I would look into
jsonlite, rjson, or RJSONIO on CRAN. You'll need to review them to
see which best meets your needs.​



 Thanks for your help!​

 [[alternative HTML version deleted]]


​ Please change to plain text. In many cases HTML displays poorly due to
the list trying to change it for you to plain text. And, in that case,
you'll likely be ignored.
​

-- 
Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

My sister opened a computer store in Hawaii. She sells C shells down by the
seashore.
If someone tell you that nothing is impossible:
Ask him to dribble a football.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] Passing strings with spaces to Python using system2 splits string at whitespace

2015-06-04 Thread John McKown
On Thu, Jun 4, 2015 at 8:47 AM, Wall, Wade A ERDC-RDE-CERL-IL 
wade.a.w...@usace.army.mil wrote:

 Hi all,

 I am trying to pass arguments to a python script using R, but am running
 into a problem with the string being split on the white spaces.
 Investigation on the python end suggests that it is happening upstream from
 python, because other shells such as bash have generated similar errors.

 Here is example code.

 R script:

 test = ./Example.py
 string1 = ThisWorks
 string2 = This doesn't

 system2('python',args = c(as.character(test),as.character(string1))) ##
 This works
 system2('python',args = c(as.character(test),as.character(string2))) ##
 This doesn't


​use shQuote, like:

system2('python',args=shQuote(c(as.character(test),as.character(string2​


 Python script:

 from sys import argv
 script, string = argv
 print script
 print string

 What happens is that string 2 is splits into This and doesn't. Does
 anyone know how to resolve this issue? Of course I can remove the white
 spaces, but that may be somewhat inconvenient.

 Thanks for any help.

 Wade

 [[alternative HTML version deleted]]


​Please don't use HTML email. It often causes messages to be unreadable​,
although not in this particular case.




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




-- 
My sister opened a computer store in Hawaii. She sells C shells down by the
seashore.

If someone tell you that nothing is impossible:
Ask him to dribble a football.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] How to pass a variable to a function which use variable name as a parameter

2015-05-26 Thread John McKown
On Tue, May 26, 2015 at 5:14 AM, wong jane jane.wong...@gmail.com wrote:

 There are functions which use variable names as parameters in some R
 packages. However, if the variable name is stored in another variable, how
 can I pass this variable to the function. Taking the rms package as an
 example:

 ​​
 library(rms)
 n - 1000
 age - rnorm(n, 50, 10)
 sex - factor(sample(c('female','male'), n,TRUE))

 y - rnorm(n, 200, 25)
 ddist - datadist(age, sex)
 options(datadist='ddist')
 fit - lrm(y ~ age)
 Predict(fit, age, np=4)
 options(datadist=NULL)

 Here age was a variable name passed to Predict() function, but if age
 was stored in variable var, that is, var - age, how can I pass var
 to Predict() function? The purpose is that I want to change the parameter
 of Predict()  in a loop.


​Please turn off HMTL email. The forum software doesn't really like it.

What you want is the get() function.


var-age

​
​
library(rms)
n - 1000
age - rnorm(n, 50, 10)
sex - factor(sample(c('female','male'), n,TRUE))

y - rnorm(n, 200, 25)
​#​
ddist - datadist(age, sex)
​ddist - datadist(get(var),sex)​
options(datadist='ddist')
fit - lrm(y ~ age)
​#​
Predict(fit, age, np=4)
​Predict(fit,get(var),np=4)​
options(datadist=NULL)

-- 
My sister opened a computer store in Hawaii. She sells C shells down by the
seashore.

If someone tell you that nothing is impossible:
Ask him to dribble a football.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] Vincentizing Reaction Time data in R

2015-05-20 Thread John McKown
On Wed, May 20, 2015 at 5:13 AM, Gabriel WEINDEL gabriel.wein...@gmail.com
wrote:

 Dear all,

 For my master thesis, I'm currently working in cognitive neuroscience on
 executive control through measurement of reaction time and I need to get my
 data 'vincentized' with an exclusive use of R set by my statistic teacher
 for a test purpose, for this reason I can't use the python code the lab
 team usually uses.
 Despite a dozen hours of research I couldn't find any package or R-code
 which would allow the use of vincentization, that's why I'm querying help
 on the R forum.

 So has anyone ever used vincentization in R ?


I haven't. And I failed statistics in school. But a Google search got me to
this page, which I hope might be of some help to you. If not, my apologies.

https://stat.ethz.ch/pipermail/r-help/2003-May/034272.html




 Best regards,

 --
 Gabriel Weindel
 Master student in Neuropsychology - Aix-Marseille University (France)



-- 
If someone tell you that nothing is impossible:
Ask him to dribble a football.He's about as useful as a wax frying pan.10
to the 12th power microphones = 1 MegaphoneMaranatha! John McKown

[[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] problem setting default timezone

2015-04-23 Thread John McKown
On Thu, Apr 23, 2015 at 8:01 AM, Bos, Roger roger@rothschild.com
wrote:

 Dear All,

 I would like to learn the proper way to set the default time zone so I get
 the correct date for my files.  The code below is non-reproducible (sorry)
 because it is based on a file on my system, but I hope someone will be able
 to help me anyway.

 I have a file that was last modified on 4/21/2015:

  file.info(E:/snap/q/snap_q_q1_ %+% endPeriod %+% .txt)$mtime
 [1] 2015-04-21 20:26:33 EDT

 When I convert that to a date, I gives me 2015-04-22.  I read about
 timezones and saw that there are two possible places to set the default
 values: One as a system variable and one as an option.  To be safe I set
 both:

  Sys.setenv(TZ='America/New_York')
  Sys.getenv(TZ)
 [1] America/New_York
  options(tz='America/New_York')
  getOption(tz)
 [1] America/New_York
  as.Date(file.info(E:/snap/q/snap_q_q1_ %+% endPeriod %+%
 .txt)$mtime)
 [1] 2015-04-22

 But as you can see R still gives me the wrong date.  I can get the correct
 date as follows:

  as.Date(file.info(E:/snap/q/snap_q_q1_ %+% endPeriod %+%
 .txt)$mtime, tz='America/New_York')
 [1] 2015-04-21

 But my question is why is the as.Date function not using the timezone I
 have set?

 Thank you in advance,
 Roger


​Doing a ?file.info told me that the mtime variable is a POSIXct value.
Doing a ?as.Date told me that when a POSIXct value is given to it, the time
zone defaults to GMT, _not_ to the local time. That is my interpretation of
the documentation.​


quote
The ‘as.Date’ methods accept character strings, factors, logical
 ‘NA’ and objects of classes ‘POSIXlt’ and ‘POSIXct’.  (The
 last is converted to days by ignoring the time after midnight in
 the representation of the time in specified time zone, default
 UTC.)  Also objects of class ‘date’ (from package ‘date’) and
 ‘dates’ (from package ‘chron’).  Character strings are processed
 as far as necessary for the format specified: any trailing
 characters are ignored.
/quote

​What I would do is:

as.Date(file.info(...),tz=getOption(tz))​

-- 
If you sent twitter messages while exploring, are you on a textpedition?

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] RODBC did not found

2015-04-20 Thread John McKown
On Mon, Apr 20, 2015 at 5:59 AM, CHIRIBOGA Xavier xavier.chirib...@unine.ch
 wrote:

 Dear members,

 What can I do if I get this message: ?

 library(RODBC)
 Error in library(RODBC) : aucun package nommé ‘RODBC’ n'est trouvé

 Thanks in advcance,

 Xavier


​If I understand the message correctly, it is saying that the RODBC package
is not found, just as you said in the subject. That either means that you
have not installed it, or it is not on the library path. Perhaps the
simplest thing to try is to reinstall the RODBC package with the R
statement:

install.packages('RODBC')

then try again. If you need more help, you might want to post the output
from the commands: Sys.info() and .libPaths() and the value of the .Library
variable​


-- 
If you sent twitter messages while exploring, are you on a textpedition?

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] Need online version of R help pages

2015-04-20 Thread John McKown
On Mon, Apr 20, 2015 at 9:43 AM, Paul paul.domas...@gmail.com wrote:

 Acknowledged, Michael.  I appreciate the pointer to the info.

 For at least a short while, however, this is my only access to R, so I
 am using this environment to ramp up on times series and R as much a
 possible.  I think it should suffice for that purpose, and the real
 analysis can occur in a more reliable installation R.  I've managed to
 work the ropes on a better installation, but the solution won't be
 immediate.


​I am not really familiar with the site referenced below. But maybe it
would be helpful to you? It allows you to edit and run R code through a
browser on the _their_ site. It appears to be absolutely free. And has
other languages available as well.

http://www.tutorialspoint.com/execute_r_online.php
​


-- 
If you sent twitter messages while exploring, are you on a textpedition?

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] regexpr - ignore all special characters and punctuation in a string

2015-04-20 Thread John McKown
On Mon, Apr 20, 2015 at 8:59 AM, Dimitri Liakhovitski 
dimitri.liakhovit...@gmail.com wrote:

 Hello!

 Please point me in the right direction.
 I need to match 2 strings, but focusing ONLY on characters, ignoring
 all special characters and punctuation signs, including (), , etc..

 For example:
 I want the following to return: TRUE

 What a nice day today! - Story of happiness: Part 2. ==
What a nice day today: Story of happiness (Part 2)


 --
 Thank you!
 Dimitri Liakhovitski



​Perhaps a variation on:

 str1-What a nice day today! - Story of happiness: Part 2.
 str2- What a nice day today: Story of happiness (Part 2)
 gsub('[^[:alpha:]]','',str1)==gsub('[^[:alpha:]]','',str2)
[1] TRUE


The gsub() removes all characters which are not alphabetic from each string
and then compares them.​


-- 
If you sent twitter messages while exploring, are you on a textpedition?

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] Running R Remotely on LINUX

2015-04-14 Thread John McKown
On Tue, Apr 14, 2015 at 11:57 AM, Michael Haenlein haenl...@escpeurope.eu
wrote:

 Dear all,

 ​snip



 (3) Can I open several instances of R in parallel? On my PC I sometimes
 have 2-3 windows open in parallel that work on different calculations to
 save time. Not sure to which extent this is possible on LINUX.


​In addition to my off-list reply, you might want to talk to your Linux
person to see if you can use VNC no NoMachine (https://www.nomachine.com/)
to get a Linux graphical desktop ​connection (similar in concept to Windows
Remote Desktop) going. If you can do this, and can get KDE as the desktop
environment, then you can have a very Windows-ish Linux desktop displayed
on your Windows machine. But it will still be nice even with Gnome, or
XFCE, or even one of the other desktops (Linux has a lot of them, but I
think KDE is most similar to Windows U.I.) This will allow you to use
RStudio on Linux or have multiple terminal sessions going for multiple R
sessions. But this will _not_ allow you to disconnect from Linux while
maintaining the graphical desktop. At least, I don't think you can do that.
I could be wrong.




 I assume that this questions are very naïve. But since I’m only used to
 working with Windows I’m quite stuck at the moment. Any help would be very
 appreciated!

 Thanks in advance,

 Michael

 Michael Haenlein
 Professor of Marketing
 ESCP Europe


-- 
If you sent twitter messages while exploring, are you on a textpedition?

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] Windows Installation Without Third-Party Packages

2015-04-09 Thread John McKown
On Thu, Apr 9, 2015 at 8:42 AM, Elliot Joel Bernstein e...@cornell.edu
wrote:

 I am trying to install R for Windows, but when I use the installer provided
 on CRAN, a number of third-party packages are installed by default (i.e.
 lattice, Matrix, codetools, etc.). If R is installed with administrator
 privileges, so it's available for all users, non-administrators can't
 update those packages. Is there any way to just install R without any
 third-party packages, and let individual users install the packages they
 want?

 Thanks.

 - Elliot

 [[alternative HTML version deleted]]


​Please try to not post in HTML, per forum standards.

I don't know if this will help, but I hope so. I think what I did will be
self explanatory

 install.packages('plyr',lib=.libPaths()[1])
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/plyr_1.8.1.zip'
Content type 'application/zip' length 1154715 bytes (1.1 Mb)
opened URL
downloaded 1.1 Mb

package ‘plyr’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\john.mckown\AppData\Local\Temp\RtmpWIjtdm\downloaded_packages
 .libPaths()
[1] C:/Users/john.mckown/Documents/R/win-library/3.1
[2] C:/Program Files/R/R-3.1.1/library
 .libPaths()
[1] C:/Users/john.mckown/Documents/R/win-library/3.1
[2] C:/Program Files/R/R-3.1.1/library
 list.dirs(.libPaths()[1])
  [1] C:/Users/john.mckown/Documents/R/win-library/3.1

...
[116] C:/Users/john.mckown/Documents/R/win-library/3.1/plyr

[117] C:/Users/john.mckown/Documents/R/win-library/3.1/plyr/data

[118] C:/Users/john.mckown/Documents/R/win-library/3.1/plyr/help

[119] C:/Users/john.mckown/Documents/R/win-library/3.1/plyr/html

[120] C:/Users/john.mckown/Documents/R/win-library/3.1/plyr/libs

[121] C:/Users/john.mckown/Documents/R/win-library/3.1/plyr/libs/i386

[122] C:/Users/john.mckown/Documents/R/win-library/3.1/plyr/libs/x64

[123] C:/Users/john.mckown/Documents/R/win-library/3.1/plyr/Meta

[124] C:/Users/john.mckown/Documents/R/win-library/3.1/plyr/R

[125] C:/Users/john.mckown/Documents/R/win-library/3.1/plyr/tests

[126] C:/Users/john.mckown/Documents/R/win-library/3.1/R6

...

As you can see, plyr got installed in my personal area. And it is still
on the system directory:

 list.dirs(.libPaths()[2])[seq(from=1050,to=1061)]
 [1] C:/Program Files/R/R-3.1.1/library/parallel/tests
 [2] C:/Program Files/R/R-3.1.1/library/plyr
 [3] C:/Program Files/R/R-3.1.1/library/plyr/data
 [4] C:/Program Files/R/R-3.1.1/library/plyr/help
 [5] C:/Program Files/R/R-3.1.1/library/plyr/html
 [6] C:/Program Files/R/R-3.1.1/library/plyr/libs
 [7] C:/Program Files/R/R-3.1.1/library/plyr/libs/i386
 [8] C:/Program Files/R/R-3.1.1/library/plyr/libs/x64
 [9] C:/Program Files/R/R-3.1.1/library/plyr/Meta
[10] C:/Program Files/R/R-3.1.1/library/plyr/R
[11] C:/Program Files/R/R-3.1.1/library/plyr/tests
[12] C:/Program Files/R/R-3.1.1/library/proto


Pardon the weird subscript, but the list was way to big to cut, paste, and
edit. So your users should be able to force any package, even a system
package, into their personal R directory using the lib= parameter of the
install.packages() function. This will allow them to update their copy of
any R package from CRAN.

I hope.​


-- 
If you sent twitter messages while exploring, are you on a textpedition?

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] reading in from xlsx files

2015-03-24 Thread John McKown
On Tue, Mar 24, 2015 at 7:40 AM, Robert Lyons rly...@m2s.com wrote:
 I'm sorry if this is well below the level of this forum.
 Using R Console v3.1.3 32-bit
 Both of our R Programming sources left the company and I'm in need of some 
 very basic help.
 The code is reading in column and row information from two xlsx files.
 I made what I thought were some basic changes to the contents of those files, 
 one was a correction to a typo for a row, the other was flipping two columns 
 that were in the wrong order.
 When I Source the R Code neither change shows up in the output.

Well, first of all, nobody can help you with code unless you actually
post the code in question. Hard to fix the car while you're driving
it. [grin]

Second, if you do post some code, you __REALLY__ need to disable
posting in HTML. HTML messages normally come across on this forum as
junk and most won't even try to read them.

I may be off base on the following and likely be corrected if I am.
But, unless the fix is simple, which from your post seems likely,
you might be better off hiring a contractor who is an R programmer.
Especially, as it appears in the case, that this is a for-profit
company. TANSTAAFL, although many will help if they are curious and
have time.


 Thank you for your time.

 Cordially,
 Bob Lyons




-- 
If you sent twitter messages while exploring, are you on a textpedition?

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

__
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] the making of _R_ eBooks

2015-03-23 Thread John McKown
On Mon, Mar 23, 2015 at 3:50 AM, Dr. Wolfgang Lindner
lindn...@t-online.de wrote:
 Dear list members,

 I like the look and feel of the eBook versions of the R manuals very much.
 So I would like to generate eBooks (teaching material etc) in that look.

I am not an expert. But I have looked at the source, so I can give you
some information.


 Q1: is there a description how the _R_ ebooks have been produced?

Looking at the source, it appears that the source manuals are in a
document markup language called GNU Texinfo.
https://www.gnu.org/software/texinfo/
You can think of this as something akin to, but different from, HTML
or markdown encoding. Texinfo is an evolution by the system first
designed by Richard Stallman of MIT. He is the driving force behind
the GPL and most of the GNU software which forms the basis of the user
space commands for Linux and the *BSD operating systems. Texinfo is
then converted to TeX. TeX is the typesetting language designed by Dr.
Donald Knuth. TeX, nominally, is converted into a DVI printer control
language (DeVice Independent). But in the case of creating a PDF file,
there is a processor called pdftex,
http://en.wikipedia.org/wiki/PdfTeX, which produces a PDF file as
output . A good site for TeX is https://tug.org/

Texinfo has the plus of also having processor which will convert it to
UNIX man (manual) pages and HTML web pages. So one source document
can generate three different types of output document file types.

Most people use a enhanced TeX called LaTeX instead of plain TeX
when using TeX. LaTeX can be read up on here:
http://www.latex-project.org/ A good TeX document processor is
TeXstudio at http://texstudio.sourceforge.net/ . I use this one myself
(which is not necessary a strong endorsement because I'm nobody
special).

I feel the need to warn you that TeX is very powerful and, at least to
me, quite difficult, with a fairly step learning curve. Which may be
why the R project uses Texinfo because it is quite a bit easier to
learn.


 Q2: which (free) software was used for them?

See the links above. On Fedora Linux, I get the TeX oriented software
from a bunch of packages which start with texlive. More information,
including the processors for Linux, Windows, and Mac are at
https://www.tug.org/texlive/

 Q3: any other recommendations?

You might consider LyX.
http://www.lyx.org/
LyX is a document processor. It would likely be easier to use than the
above if you are used to MS Word or other word processing system. It
is cross platform: Linux, Windows, and Mac. It stores files in its own
textual format, which is somewhat human readable. LyX, like Texinfo,
translates its format into TeX as an intermediate on its way to its
ultimate destination. I am still learning LyX, but I personally like
it.

Your mention of LibreOffice is also a fairly good one. I, personally,
use LibreOffice. But I don't use it for big documents. I have a
learned aversion for word processors because it is so easy for them to
be misused. In my opinion, a good document needs good metadata in it
as well as just looking pretty. Word processor users tend to focus
on the format and not the content. That's just my opinion, based on
what I've seen where I work.


 Seaching the internet gives me e.g.
 [1]
 https://sites.google.com/site/richardbyrnepdsite/ebooks-and-audiobooks/create-your-own-ebooks
 [2]  opensource.com/life/13/8/how-create-ebook-open-source-way
 [3] 
 http://scottnesbitt.net/ubuntublog/creating-a-ebook-with-libreoffice-writer/

 but I m not sure, if there are better possibilities..

 Thanks for any hint or link by expert R users.

Oh, well, that excludes me. I'm not an expert. But maybe it was helpful anyway.


 Wolfgang Lindner
 Leichlingen, Germany

-- 
If you sent twitter messages while exploring, are you on a textpedition?

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

__
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 Programmin-1 submission.

2015-03-14 Thread John McKown
Gary,

First off, I doubt anyone here will really be able to help you with a
question which is, basically, How do I submit the R code that I've
worked on to my college as an answer to a programming assignment.
Unless by chance someone else here happens to be taking that course
and knows how to. It's not really an R programming question.

What I can help you with is an apparent misunderstand by you of what
source() does. source() is simply a way to say: read the lines in the
named file (not always a disk file) and act as if I had typed it all
in myself on the R command prompt.

Well, I may be chided a bit by others. But I'm bored this morning. And
I don't feel that this is actually a homework problem. So I looked
at the R code at
http://d396qusza40orc.cloudfront.net/rprog/scripts/submitscript1.R and
at your transcript. Try the following commands:

source(http://d396qusza40orc.cloudfront.net/rprog/scripts/submitscript1.R;)

setwd('H:/RStudio-Projects/Project1/')

submit()

Note that I replaced the second source() with a setwd() command. The
first source() defines some R programs for you. The setwd() makes your
current working directory be H:/RStudio-Projects/Project1/ which I
guess is where pollutantmean.R resides. The submit() function looks
for a __FILE__ in the __current working directory__ for the code which
you want to submit to your instructor. From what I can see, the
submit() process itself does the required source() to run your R code,
but only from your __current working directory__ (yes, I'm emphasizing
that). The rest of what you did after the submit() command looks to
match what the submit() function was wanting.

Now, I will emphasize yet again that this question is totally outside
the purview of this forum. Your question should have been asked of
your teacher, or a TA, or (as we were called back when I was in
college) a user's ass (we weren't P.C,. or even polite, back in the
60s. I had to help people with key punch machines and card readers). I
only went into this because: (1) I'm bored and (2) you look like you
might be just a bit younger that me and I believe in helping kids
succeed grin.


On Fri, Mar 13, 2015 at 6:46 PM, Gary Baggett islegu...@gmail.com wrote:
 Help.



 First of all, I admit being a noob when it comes to dealing with R and
 Git-hub (but not new to programming[embedded mostly]).  That being said,
 this first programming submission with this course is giving me fits.



 I have the first part of the assignment done, loaded the submit source
 within my local RStudio and am trying to run submit ().  It tries to run,
 but then aborts.see below.



source(http://d396qusza40orc.cloudfront.net/rprog%2Fscripts%2Fsubmitscript
 1.R)

 source('H:/RStudio-Projects/Project1/pollutantmean.R')

 submit()



 Press Enter to continue...



 | Is the following information correct?



 Course ID: rprog-012

 Submission login (email): islegu...@gmail.com

 Submission password:



 1: Yes, go ahead!

 2: No, I need to change something.



 Selection: 1



 | Which part are you submitting?



 1: 'pollutantmean' part 1

 2: 'pollutantmean' part 2

 3: 'pollutantmean' part 3

 4: 'pollutantmean' part 4

 5: 'complete' part 1

 6: 'complete' part 2

 7: 'complete' part 3

 8: 'corr' part 1

 9: 'corr' part 2

 10: 'corr' part 3



 Selection: 1

 Error in file(filename, r, encoding = encoding) :

   cannot open the connection

 In addition: Warning message:

 In file(filename, r, encoding = encoding) :

   cannot open file 'pollutantmean.R': No such file or directory








 Any suggestions as to where to go?  It appears to be unable to find my
 pollutantmean.R file even though I just sourced it.  The function is in
 memory and is in the directory from which I am trying to execute the submit
 script.





 Thanks,

 Gary Baggett


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



-- 
He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

__
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] regex find anything which is not a number

2015-03-12 Thread John McKown
On Thu, Mar 12, 2015 at 2:43 PM, Steve Taylor steve.tay...@aut.ac.nz wrote:
 How about letting a standard function decide which are numbers:

 which(!is.na(suppressWarnings(as.numeric(myvector

 Also works with numbers in scientific notation and (presumably) different 
 decimal characters, e.g. comma if that's what the locale uses.

One problem is that Adrian wanted, for some reason, to exclude numbers
such as 2. but accept 2.0 . That is, no unnecessary trailing
decimal point. as.numeric() will not fail on 2. since that is a
number. The example grep() specifically excludes this by requiring at
least one digit after any decimal point.

-- 
He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

__
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] regex find anything which is not a number

2015-03-11 Thread John McKown
See if the following will work for you:

grep('^-?[0-9]+([.]?[0-9]+)?$',myvector,perl=TRUE,invert=TRUE)

 myvector - c(a3, N.A, 1.2, -3, 3-2, 2.)
 grep('^-?[0-9]+([.][0-9]+)?$',myvector,perl=TRUE,invert=TRUE)
[1] 1 2 5 6


The key is to match a number, and then invert the TRUE / FALSE (invert=TRUE).
^ == start of string
-? == 0 or 1 minus signs
[0-9]+ == one or more digits

optionally followed by the following via use of (...)?
[.] == an actual period. I tried to escape this, but it failed
[0-9]+ == followed by one or more digits

$ == followed by the end of the string.

so: optional minus, followed by one or more digits, optionally
followed by (a period with one or more ending digits).


On Wed, Mar 11, 2015 at 2:27 PM, Adrian Dușa dusa.adr...@unibuc.ro wrote:
 Hi everyone,

 I need a regular expression to find those positions in a character
 vector which contain something which is not a number (either positive
 or negative, having decimals or not).

 myvector - c(a3, N.A, 1.2, -3, 3-2, 2.)

 In this vector, only positions 3 and 4 are numbers, the rest should be 
 captured.
 So far I am able to detect anything which is not a number, excluding - and .

 grep([^-0-9.], myvector)
 [1] 1 2

 I still need to capture positions 5 and 6, which in human language
 would mean to detect anything which contains a - or a . anywhere
 else except at the beginning of a number.

 Thanks very much in advance,
 Adrian


 --
 Adrian Dusa
 University of Bucharest
 Romanian Social Data Archive
 Soseaua Panduri nr.90
 050663 Bucharest sector 5
 Romania

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



-- 
He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

__
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] vectorize data string analysis

2015-03-03 Thread John McKown
 __
 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.



-- 
He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

__
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] Reading in an XLS (really XML) file from website

2015-02-27 Thread John McKown
On Fri, Feb 27, 2015 at 10:01 AM, Bos, Roger roger@rothschild.com
wrote:

 All,

 I am trying to read the SP 500 constituents from the iShares website
 using the following code:

URL - http://www.ishares.com/us/239726/fund-download.dl;
setInternet2(TRUE)
download.file(url=URL, destfile=temp.xls)
out - readWorksheetFromFile(file=temp.xls, sheet=Holdings,
 header=TRUE, startRow=13)

 R returns the following error:

 out - readWorksheetFromFile(file=temp.xls, sheet=Holdings,
 header=TRUE, startRow=13)
 Error: IllegalArgumentException (Java): Your InputStream was neither an
 OLE2 stream, nor an OOXML stream
 In addition: Warning message:
 In download.file(url = URL, destfile = temp.xls) :
   downloaded length 1938303 != reported length 200

 Upon further examination this is because the format is really XML.  Is
 there any way to get XLConnect or any other excel reader to read in an XML
 file?  I thought XML was for new Excel format.

 Barring that, can we read in the file using the XML package? I tried the
 following code...

require(XML)
tmp - xmlParse(URL)

 ... but I get this error:

 Opening and ending tag mismatch: Style line 14 and Style
 Error: 1: Opening and ending tag mismatch: Style line 14 and Style

 Thanks in advance for any help or hints,

 Roger


​The problem is indeed on line 14 of the file. The contents of that line
are:

/style

but should be

/ss:style

That is, the file is malformed. I edited the file to make that change and
saved it. After I did this, I was able to open it as a spreadsheet using
LibreOffice. I did all of this on my home Linux system. I don't have
Windows, and thus no Excel either, available here, so I can't test with
Excel. ​You should be able to download this file as shown by Raghuraman. On
Windows (which I _assume_ you are using since most do), you can edit the
file using Notepad, or Wordpad. I would use Wordpad myself. Notepad is
iffy on some things. Save it back, then try readWorksheetFromFile() as
you originally did.


-- 
He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] extract file name from a path string

2015-02-26 Thread John McKown
Look at dirname() and basename(). The first would be what you call
the path. The second is the file.name without the path.

On Thu, Feb 26, 2015 at 10:58 AM, Luigi Marongiu
marongiu.lu...@gmail.com wrote:
 Dear all,
 what code should I write in order to extract the file name from a give
 path? Let's say that I want to get the file my file.xls which is in
 the directory/folder My documents; since I work both with Windows
 and Linux, the paths I am looking at are in the format:

 path.windows-\\home$\\lm667\\My Documents\\my file.xls
 path.linux-/home/My Documents/my file.xls

 I used two words for the file name because sometimes the file names
 have multiple words rather than a single one separated by capitals,
 . or _.
 The code should now get the file name, which is included between \\
 (or /) and .xls but I don't know what regular expression will do
 the trick.
 Once the file name has been assigned to a vector, it should be easy to
 remove it from the path.windows/.linux and obtain a vector with the
 path on its own.
 Essentially the output should be as follows:

 file.name
 [1] my file.xls
 path.w
 [1] \\home$\\lm667\\My Documents\\
 path.l
 [1] /home/My Documents/

 Thank you,
 Luigi

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



-- 
He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

__
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] Noob question re: writing while loops on one line

2015-02-15 Thread John McKown
On Sun, Feb 15, 2015 at 9:54 AM, Duncan Murdoch murdoch.dun...@gmail.com
wrote:

 On 15/02/2015 10:08 AM, Sun Shine wrote:
  Thanks John: understanding it as a line return makes sense!

 But it's not right.  This is one statement, and it returns the value 3:

 1 +
 2

 This is an error:

 1 + ; 2

 The semicolon is a statement separator, not a line return.


​Technically speaking a semicolon is a statement terminator, not a
statement separator. In the case of the R language, that is a nit. In the
case of Pascal, it is a big difference.



 Duncan Murdoch


​This is one reason why I _always_ use the semi-colon. It is _never_ really
wrong to do so. It may be _unnecessary_ in some case. It is also why I
always use - as the assignment operator (well, that and because I like it
from my APL background). If there are two ways to express something, and
one of them is _always_ correct whereas the other _might not_ be correct in
some cases, then I think doing the former is simply better form. But,
then, I'm anal about other things to. And that doesn't apply to interactive
use. I don't terminate my interactive statements with a semi-colon all the
time. Just most of the time. Of course, I'm a touch typist too and so it is
not really much of a problem for me.​



-- 
He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] Noob question re: writing while loops on one line

2015-02-15 Thread John McKown
I guess my C background has messed me up a bit for R. Well, recovering from
APL was worse. I lost all sense of hierarchy of operations.
On Feb 15, 2015 2:19 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote:

 On 15/02/2015 11:20 AM, John McKown wrote:
  On Sun, Feb 15, 2015 at 9:54 AM, Duncan Murdoch
  murdoch.dun...@gmail.com mailto:murdoch.dun...@gmail.comwrote:
 
  On 15/02/2015 10:08 AM, Sun Shine wrote:
   Thanks John: understanding it as a line return makes sense!
 
  But it's not right.  This is one statement, and it returns the value
 3:
 
  1 +
  2
 
  This is an error:
 
  1 + ; 2
 
  The semicolon is a statement separator, not a line return.
 
 
  ​Technically speaking a semicolon is a statement terminator, not a
  statement separator. In the case of the R language, that is a nit. In
  the case of Pascal, it is a big difference.
 
 
 
  Duncan Murdoch
 
 
  ​This is one reason why I _always_ use the semi-colon. It is _never_
  really wrong to do so. It may be _unnecessary_ in some case. It is also
  why I always use - as the assignment operator (well, that and because I
  like it from my APL background). If there are two ways to express
  something, and one of them is _always_ correct whereas the other _might
  not_ be correct in some cases, then I think doing the former is simply
  better form. But, then, I'm anal about other things to. And that
  doesn't apply to interactive use. I don't terminate my interactive
  statements with a semi-colon all the time. Just most of the time. Of
  course, I'm a touch typist too and so it is not really much of a problem
  for me.​

 I don't use semicolons unless they are necessary, and I don't like it
 when my students do.  For example, you could be misled by code like this:

 x = 1;
 y = 2;
 verylongname = x + y
 + 1;

 If this were C, verylongname would end up with the value 4.  If you read
 it and only see 3 terminators, you might think R is the same, but it's
 not.  R sees that as 7 different statements:  two on the 1st, 2nd and
 4th lines (in each case the second statement is empty), and one
 statement on line 3.  So verylongname ends up with the value 3, not 4.

 Cues to remind you what language you're using are a good thing.  That's
 one reason to use - (which I always do) instead of =, and not to use
 unnecessary semicolons.

 Duncan Murdoch

 
 
 
  --
  He's about as useful as a wax frying pan.
 
  10 to the 12th power microphones = 1 Megaphone
 
  Maranatha! 
  John McKown



[[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] Fixed Width EBCDIC Files in R

2015-02-05 Thread John McKown
On Thu, Feb 5, 2015 at 2:08 PM, Brian Trautman btrautma...@gmail.com
wrote:

 I'm trying to read some mainframe data encoded as EBCDIC into R, and am at
 a loss. I'd like to avoid using an external program to convert the files,
 since I'm operating in a corporate environment.

 You can find the example files at at the link below, with both ASCII and
 EBCDIC versions. Note that there are no linebreaks in the EBCDIC versions
 of the file -- instead, I'd be specifying the width of each line manually.
 R has the IBM500 encoding available in my environment, which should be the
 correct one for these files.

 However, when I run the following commands, R seems to fail entirely.  It
 loads a single record with garbage characters, regardless of the encoding I
 specified.


 layout - read.fwf(EBCDIC_LAYOUT, widths = c(80), fileEncoding='ibm500')

 data   - read.fwf(EBCDIC_ZIPCODE, widths = c(32), fileEncoding='ibm500')


 Where might I go from here?

 Related -- some of the files I expect to use will be fairly large (1 GB or
 so). Preferably, I'd like a solution that scales reasonably well. (I tried
 packages like LaF, but they don't have the option to select encoding.)

 Thank you very much!


 Example files --
 https://drive.google.com/open?id=0ByvX1v-WqaaASTdwV2ZYS0pBV00authuser=0


​
I gave this a short try. What killed me (see below) is that your file
EBCDIC_ZIPCODE has embedded NULL characters, \0. My transcript:

 file-file(EBCDIC_ZIPCODE,encoding=IBM500, raw=TRUE);
 data=read.fwf(file,widths=c(32));
Warning messages:
1: In readLines(file, n = thisblock) :
  line 1 appears to contain an embedded nul
2: In readLines(file, n = thisblock) :
  incomplete final line found on 'EBCDIC_ZIPCODE'
 View(data)

I don't know how to get past the embedded NULL. I'm a UNIX user, so my
thought (not applicable with your restriction of pure R), would be to use
tr to convert the \0 to spaces, then use the above.​


-- 
He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[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] error 1 in extracting from zip file

2015-01-14 Thread John McKown
On Wed, Jan 14, 2015 at 4:32 AM, Emilio Gianicolo egian...@uni-mainz.de
wrote:

 Hi,

 I've some troubles in running this program
 http://rpubs.com/adam_dennett/8955.

 I create this object:
 temp - tempfile(fileext = .zip)

 But, after downloading this file
 download.file(
 http://epp.eurostat.ec.europa.eu/cache/GISCO/geodatafiles/NUTS_2010_60M_SH.zip
 ,
 temp)

 when I try to unzip
 unzip(temp)

 I get this message:  /error 1/ in /extracting/ from /zip/ file

 Thanks for your help

 Emilio


 [[alternative HTML version deleted]]


​Please, not HTML, per forum standards. Thanks.

I downloaded that URL. And the result was _not_ a ZIP file but a web page.
From some looking around, the proper URL seems to be:

http://ec.europa.eu/eurostat/cache/GISCO/geodatafiles/NUTS_2010_60M_SH.zip

This is a 5,9 megabyte file. When unzipped, it has 62 different files in 5
different directories.

There was a note on the web page displayed with I clicked on the URL you
supplied which leads me to believe that they have reorganized the site
recently.
​
-- 
​
While a transcendent vocabulary is laudable, one must be eternally careful
so that the calculated objective of communication does not become ensconced
in obscurity.  In other words, eschew obfuscation.

111,111,111 x 111,111,111 = 12,345,678,987,654,321

Maranatha! 
John McKown

[[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] regular expression question

2015-01-14 Thread John McKown
On Wed, Jan 14, 2015 at 10:03 AM, MacQueen, Don macque...@llnl.gov wrote:

 I know you already have a couple of solutions, but I would like to mention
 that it can be done in two steps with very simple regular expressions. I
 would have done:

 s - c(lngimbintrhofixed,lngimbnointnorhofixed,test,
'rhofixedtest','norhofixedtest')
 res - gsub('norhofixed$', '',s)
 res - gsub('rhofixed$', '',res)
 res
 [1] lngimbint  lngimbnointtest
 rhofixedtest   norhofixedtest


 (this is for those of us who don't understand regular expressions very
 well!)


​There is one possible problem with your solution.​ Consider the string:
arhofixednorhofixed. It ends with norhofixed and, according to the original
specification, needs to result in arhofixed. (I will admit this is a
contrived case which is very unlikely to occur in reality). But since you
do TWO regular expressions, first removing the trailing norhofixed,
resulting in arhofixed (the correct answer?), but then reduces that to
simply a. The other regular expressions correctly remove either
norhofixed or rhofixed, if they are written _correctly_. That is, they
check first for norhofixed, with an alternate of rhofixed, or conditionally
match the no in front of the rhofixed at the very end of the string (my
example). To be even more explicit the regexp nohrofixed|rhofixed will
work properly but rhofixed|norhofixed will not because the norhofixed
won't be looked for if the rhofixed matches. Yes, regular expressions can
be complicated. Although I have a liking for them due to their
expressiveness and power, it is like an person using raw nitroglycerin
instead of dynamite. Dangerous.




 -Don

 --
 Don MacQueen

 Lawrence Livermore National Laboratory

-- 
​
While a transcendent vocabulary is laudable, one must be eternally careful
so that the calculated objective of communication does not become ensconced
in obscurity.  In other words, eschew obfuscation.

111,111,111 x 111,111,111 = 12,345,678,987,654,321

Maranatha! 
John McKown

[[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] regular expression question

2015-01-12 Thread John McKown
No HTML please. it makes me itchy! grin/

 s - c(lngimbintrhofixed,lngimbnointnorhofixed,test)
 sub('(no)?rhofixed$','',s)
[1] lngimbint   lngimbnoint test



On Mon, Jan 12, 2015 at 1:37 PM, Mark Leeds marklee...@gmail.com wrote:

 Hi All: I have a regular expression problem. If a character string ends
 with rhofixed or norhofixed, I want that part of the string to be
 removed. If it doesn't end with either of those two endings, then the
 result should be the same as the original. Below doesn't work for the
 second case. I know why but not how to fix it. I lookrd st friedl's book
 and I bet it's in there somewhere but I can't find it. Thanks.

 s - c(lngimbintrhofixed,lngimbnointnorhofixed,test)

 result - sub(^(.*)([n.*|r.*].*)$,\\1,s)

  print(result)
 [1] lngimbint lngimbnointno test

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




-- 
​
While a transcendent vocabulary is laudable, one must be eternally careful
so that the calculated objective of communication does not become ensconced
in obscurity.  In other words, eschew obfuscation.

111,111,111 x 111,111,111 = 12,345,678,987,654,321

Maranatha! 
John McKown

[[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] Matrix element-by-element multiplication

2015-01-07 Thread John McKown
On Wed, Jan 7, 2015 at 5:05 PM, Steven Yen sye...@gmail.com wrote:

 I like to multiple the first and second column of a 10 x 3 matrix by 100.
 The following did not work. I need this in an operation with a much larger
 scale. Any help?

 aa-matrix(1:30,nrow=10,ncol=3); aa
 bb-matrix(c(100,100,1),nrow=1,ncol=3); bb
 dim(aa)
 dim(bb)
 aa*bb

 Results:

  aa-matrix(1:30,nrow=10,ncol=3); aa
   [,1] [,2] [,3]
  [1,]1   11   21
  [2,]2   12   22
  [3,]3   13   23
  [4,]4   14   24
  [5,]5   15   25
  [6,]6   16   26
  [7,]7   17   27
  [8,]8   18   28
  [9,]9   19   29
 [10,]   10   20   30
  bb-matrix(c(100,100,1),nrow=1,ncol=3); bb
  [,1] [,2] [,3]
 [1,]  100  1001
  dim(aa)
 [1] 10  3
  dim(bb)
 [1] 1 3
  aa*bb
 Error in aa * bb : non-conformable arrays

 


​Assuming that this is exactly what you want to do, then

aa[,1:2]-aa[,1:2]*100;

transcript:

 aa-matrix(1:30,nrow=10,ncol=3);  aa  [,1] [,2] [,3]
 [1,]1   11   21
 [2,]2   12   22
 [3,]3   13   23
 [4,]4   14   24
 [5,]5   15   25
 [6,]6   16   26
 [7,]7   17   27
 [8,]8   18   28
 [9,]9   19   29
[10,]   10   20   30 aa[,1:2]-aa[,1:2]*100 aa  [,1] [,2] [,3]
 [1,]  100 1100   21
 [2,]  200 1200   22
 [3,]  300 1300   23
 [4,]  400 1400   24
 [5,]  500 1500   25
 [6,]  600 1600   26
 [7,]  700 1700   27
 [8,]  800 1800   28
 [9,]  900 1900   29
[10,] 1000 2000   30


​


-- 
​
While a transcendent vocabulary is laudable, one must be eternally careful
so that the calculated objective of communication does not become ensconced
in obscurity.  In other words, eschew obfuscation.

111,111,111 x 111,111,111 = 12,345,678,987,654,321

Maranatha! 
John McKown

[[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] Your pardon: An article possibly of interest to statisticians

2014-12-18 Thread John McKown
I do hope this doesn't upset anyone. But it appears rather interesting to
me, despite the fact that I'm not a statistician. So I thought that it
might be of interest to some others here.

https://medium.com/the-physics-arxiv-blog/cause-and-effect-the-revolutionary-new-statistical-test-that-can-tease-them-apart-ed84a988e

http://arxiv.org/abs/1412.3773

Title: Distinguishing cause from effect using observational data: methods
and benchmarks
quote
The discovery of causal relationships from purely observational data is a
fundamental problem in science. The most elementary form of such a causal
discovery problem is to decide whether X causes Y or, alternatively, Y
causes X, given joint observations of two variables X, Y . This was often
considered to be impossible. Nevertheless, several approaches for
addressing this bivariate causal discovery problem were proposed recently.
In this paper, we present the benchmark data set CauseEffectPairs that
consists of 88 different cause-effect pairs selected from 31 datasets
from various domains. We evaluated the performance of several bivariate
causal discovery methods on these real-world benchmark data and on
artificially simulated data. Our empirical results provide evidence that
additive-noise methods are indeed able to distinguish cause from effect
using only purely observational data. In addition, we prove consistency of
the additive-noise method proposed by Hoyer et al. (2009).
/quote

Returning to lurkerdom.

-- 
​
While a transcendent vocabulary is laudable, one must be eternally careful
so that the calculated objective of communication does not become ensconced
in obscurity.  In other words, eschew obfuscation.

111,111,111 x 111,111,111 = 12,345,678,987,654,321

Maranatha! 
John McKown

[[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] create matrices with constraint

2014-12-15 Thread John McKown
On Fri, Dec 12, 2014 at 11:00 AM, Kathryn Lord kathryn.lord2...@gmail.com
wrote:

 Dear all,

 Suppose that I have natural numbers 1 through 28.

 Based on these numbers, choose 4 numbers 7 times without replacement and
 make a 4 by 7 matrix, for example,


​After a relaxing weekend, it came to me that these 4x7 matrices are really
just a subset of all the possible permutations of the vector 1:28, recast
as  4x7 matrices. Of course, there are factorial(28) (about 3*10^29 ) such
4x7 matrices. But given your constraints, I think that these can be
subsetted to only those permutations in which the values in each row are
sorted in ascending (or descending) order. I am fairly certain that this
subset would be exhaustive for your purposes. I not really certain how big
that subset would be. I think it would be 1/168th ( 1 out of 7*factorial(4)
) of the 3*10^29 permutations, or about 1.8*10^27. Which is still way to
big to actually instantiate all at once. You might be able store such a
thing in a huge data base. If you're lucky, you have access to a massive
supercomputer so that you can get the results before the heat death of this
universe. (exaggeration?)

Two R libraries seems to address this. One is combinat. The other is
permute.​ The permute library seems, to me, to be the more likely
candidate. It contains a how() function which __appears to me__ to
perhaps be a way to subset the permutations as they are being generated.
But all that I get from reading the documentation is a bad headache. I
never studied combinatorics. And I got a milder headache trying to read the
Wikipedia article on it.

​I am curious about what you will do with such a set of matrices, once you
have them. If you are permitted to say.

-- 
​
While a transcendent vocabulary is laudable, one must be eternally careful
so that the calculated objective of communication does not become ensconced
in obscurity.  In other words, eschew obfuscation.

Maranatha! 
John McKown

[[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] create matrices with constraint

2014-12-15 Thread John McKown
On Mon, Dec 15, 2014 at 10:06 AM, David L Carlson dcarl...@tamu.edu wrote:

 Actually there are not so many matrices as you suggest.

  comb - combn(28, 4)
  dim(comb)
 [1] 4 20475
  sum(comb[1,]==1)
 [1] 2925
  comb[, 1]
 [1] 1 2 3 4

 There are 20,475 combinations, but you cannot choose any four to make a
 4x7 matrix since each value can be used only once. The combn() function
 returns the combinations sorted, so we can get the number of combinations
 that contain 1 with sum(comb[1,]==1) and that is 2,925. The set of 4x7
 matrices cannot use the same combination more than once, so 2,925 is the
 maximum possible number of matrices and there may be fewer. As a first
 approach to finding them, you could take the first combination comb[, 1]
 which is 1, 2, 3, 4. Now add a second combination that does not include 1:4
 and then a third combination that does not include any in the first two
 combinations and finally a fourth that does not include any in the first
 three combinations. Actually this is easy since we will just take 1:4, 5:8,
 9:12, 13:16, 17:20, 21:24, 24:18.

  cols - sapply(c(1, 5, 9, 13, 17, 21, 24), function(x)
 +  head(which(comb[1,]==x), 1))
  cols
 [1] 1  9850 15631 18656 19981 20406 20471
  comb[,cols]
  [,1] [,2] [,3] [,4] [,5] [,6] [,7]
 [1,]159   13   17   21   24
 [2,]26   10   14   18   22   25
 [3,]37   11   15   19   23   26
 [4,]48   12   16   20   24   27

 But now it gets more complicated. While building the second matrix, we
 have to make sure that it does not use any combinations that have already
 been used.  Combinations used on earlier matrices may be necessary to
 complete later matrices and that is why the number of sets may be less than
 2,925. This sequential approach would guarantee to obtain matrices meeting
 the OP's criteria, but would not necessarily produce the maximum number of
 matrices possible.


​Thanks. I was thinking that I was not on the right road, but just didn't
see what I was doing wrong. I appreciate the tutoring. And I'm bowing out
now because this is getting far beyond my expertise​ both in math and R.



 -
 David L Carlson
 Department of Anthropology
 Texas AM University
 College Station, TX 77840-4352


-- 
​
While a transcendent vocabulary is laudable, one must be eternally careful
so that the calculated objective of communication does not become ensconced
in obscurity.  In other words, eschew obfuscation.

Maranatha! 
John McKown

[[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] create matrices with constraint

2014-12-14 Thread John McKown
On Sun, Dec 14, 2014 at 9:30 AM, Gerrit Draisma gdrai...@xs4all.nl wrote:

 Ha John,
 Sorry I did not follow the discussion but what
 about
  combn(1:28,4)
 ?
 Gerrit.


​Very nice! Thanks.  The form needed by the OP would be t(combn(1:28,4)) to
swap rows  columns.

I'm cross posting this to the r-help so that the OP can get at it (to give
credit to the right person). This is just phase 1 of her real quest for a
set of 7x4 (rows x columns) matrices made from rows from that result which
are complete (each matrix contains all the values in 1:28, and disjunct.
 (Assuming I'm remembering the correct words. Which is not so easy at 62,
with college being a fading memory.)

As an aside, I am really curious what the OP wants with this set of
matrices. Another in the thread said something about incomplete block
designs, but that is something that I've never heard of before. I'm really
poor at statistics.


-- 
The temperature of the aqueous content of an unremittingly ogled
culinary vessel will not achieve 100 degrees on the Celsius scale.

Maranatha! 
John McKown

[[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] create matrices with constraint

2014-12-13 Thread John McKown
On Fri, Dec 12, 2014 at 1:45 PM, John McKown john.archie.mck...@gmail.com
wrote:

 ​

​snip​



 Hum. Consider the set of all possible unique 4 value vectors in which the
 values in the vectors are taken, without replacement, from the numbers 1
 through 28. This is a mathematical concept called combination. In this
 case, there are 35 such: 7!/(4!*3!).


​Ack. I'm an idiot. That is 28!/(4!*24!) or 20,475 possible combinations.
The R code to generate a single matrix which contains all of the possible
cominations (which is not what is really wanted) could be:

result-c(0,0,0,0); #initialize to something
for(i1 in 1:25) {
for (i2 in (i1+1):26) {
for (i3 in (i2+1):27) {
for (i4 in (i3+1):28) {
x-c(i1,i2,i3,i4);
result-rbind(result,x);
}
}
}
}
result-result[2:(nrow(result)-1),]; #strip off that first row​

​of c(0,0,0,0)​


​The problem now would be to assign those vectors to the proper matrix. My
first though is to have the result be a data.frame or a three dimensional
matrix. But actually _doing_ that I haven't figured out yet. Oh, and
obviously from the way that I generated the vectors, the data items within
each vector is sorted in ascending value. An even more difficult problem
would be if the OP needed every possible permutation of each possible
matrix.​


-- 
The temperature of the aqueous content of an unremittingly ogled
culinary vessel will not achieve 100 degrees on the Celsius scale.

Maranatha! 
John McKown

[[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] create matrices with constraint

2014-12-12 Thread John McKown
On Fri, Dec 12, 2014 at 12:17 PM, peter dalgaard pda...@gmail.com wrote:


  On 12 Dec 2014, at 18:00 , Kathryn Lord kathryn.lord2...@gmail.com
 wrote:
 
  Dear all,
 
  Suppose that I have natural numbers 1 through 28.
 
  Based on these numbers, choose 4 numbers 7 times without replacement and
  make a 4 by 7 matrix, for example,
 
  a1
 
 ​​
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
  [1,]159   13   17   21   25
  [2,]26   10   14   18   22   26
  [3,]37   11   15   19   23   27
  [4,]48   12   16   20   24   28
 
  and again create another 4 * 7 matrix, say a2, in the same way; however,
  every element of each column in a2 does not exist in any column of a1
 like
  this, e.g.
 
  a2
  [,1] [,2] [,3] [,4] [,5] [,6] [,7]
  [1,]1234567
  [2,]89   10   11   12   13   14
  [3,]   15   16   17   18   19   20   21
  [4,]   22   23   24   25   26   27   28
 
 

 No comprendo... In which sense does e.g. 1 in the first column of a2 not
 exist in any column of a1


​I was confused about that too. Perhaps what she means is that each column
in the every a matrix has at least one value​

​which does not exist in any column of any other a matrix. So that the
set of values in a[,?] for a given version does not exist as a set of
values in any other column (ignoring order) of any other version of a. So
a1[,1] is c(1,2,3,4) which means that no other a?[,?] contains _all_ of
those. It _may_ contain a proper subset, but at least one value in the set
must differ. But I'm not sure that I was any clearer.

Hum. Consider the set of all possible unique 4 value vectors in which the
values in the vectors are taken, without replacement, from the numbers 1
through 28. This is a mathematical concept called combination. In this
case, there are 35 such: 7!/(4!*3!).
Combine those vectors in groups of 7
​, each group being a separate column,​
in such a way that each resulting matrix contains no duplicate numbers,
which also ensure
​s​
that each resulting matrix does contain all of the values 1 through 28.
Note that the vector c(1,2,3,4) and c(2,1,4,3) are considered identical
​ because, in a combination, order does not matter​
. So a matrix which has a column with c(1,2,3,4) stops any other matrix
from having a column with the values c(2,1,4,3).
​You can also note that two matrices would be consider identical if the
only difference is the arrangement of the column. For example:

​

​ ​
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
​   ​
 [1,]159   13   17   21   25
​   ​
 [2,]26   10   14   18   22   26
​   ​
 [3,]37   11   15   19   23   27
​   ​
 [4,]48   12   16   20   24   28

​
is really the same as (exchanging [,4] and [,1]):

​
​​
​​

​​

​ ​
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
​   ​
 [1,]
​13
59
​ 1​
   17   21   25
​   ​
 [2,]
​14​
6   10
​ 2​
   18   22   26
​   ​
 [3,]
​15​
7   11
​ 3​
   19   23   27
​   ​
 [4,]
​16​
8   12
​ 4​
   20   24   28


as is
​ (exchanging [3,7] and [4,7])​

​  ​​  ​ ​[,1] [,2] [,3] [,4] [,5] [,6] [,7]
​   ​ [1,]   ​1359   ​ 1​   17   21   25
​   ​ [2,]   ​14​6   10   ​ 2​   18   22   26
​   ​ [3,]   ​15​7   11   ​ 3​   19   23   2
​8​
​   ​ [4,]   ​16​8   12   ​ 4​   20   24   2
​7​



I think this is what the OP was getting at.

I can't think of a way, off hand, to generate all such a matrices. I
might be able to do the first part: creating all unique 4 value vectors.
But then combining the vectors together to make the matrices is not clear
to me.
​



 --
 Peter Dalgaard, Professor,
 Center for Statistics, Copenhagen Business School
 Solbjerg Plads 3, 2000 Frederiksberg, Denmark
 Phone: (+45)38153501
 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.



-- 
​
While a transcendent vocabulary is laudable, one must be eternally careful
so that the calculated objective of communication does not become ensconced
in obscurity.  In other words, eschew obfuscation.

Maranatha! 
John McKown

[[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] if else for cumulative sum error

2014-12-02 Thread John McKown
On Tue, Dec 2, 2014 at 12:08 PM, Jefferson Ferreira-Ferreira 
jeco...@gmail.com wrote:

 Hello everybody;

 I'm writing a code where part of it is as follows:

 for (i in nrow(dadosmax)){
   dadosmax$enchday[i] - if (sum(dadosmax$above[i:(i+44)]) = 45) 1 else 0
 }


​Without some test data for any validation, I would try the following
formula

dadosmax$enchday[i] - if (sum(dadosmax$above[i:(min(i+44,nrow(dadosmax)))]
= 45) 1 else 0​




 That is for each row of my data frame, sum an specific column (0 or 1) of
 that row plus 44 rows. If It is =45 than enchday is 1 else 0.

 The following error is returned:

 Error in if (sum(dadosmax$above[i:(i + 44)]) = 45) 1 else 0 :
   missing value where TRUE/FALSE needed

 I've tested the ifelse statement assigning different values to i and it
 works. So I'm wondering if this error is due the fact that at the final of
 my data frame there aren't 45 rows to sum anymore. I tried to use try but
 It's simply hide the error.

 How can I deal with this? Any ideas?
 Thank you very much.

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




-- 
The temperature of the aqueous content of an unremittingly ogled
culinary vessel will not achieve 100 degrees on the Celsius scale.

Maranatha! 
John McKown

[[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] hierarchical model with heteroscedastic variances

2014-12-01 Thread John McKown
Please repost your message in plain text. On my gmail account, it was
totally unreadable due to the fact that the forum software strips out all
the HTML stuff.

On Mon, Dec 1, 2014 at 7:51 PM, Rafael Moral rafa_moral2...@yahoo.com.br
wrote:

 Dear useRs,I have been wondering whether it would be possible to fit a
 linear mixed model including heteroscedastic variances for a 2-level
 hierarchical study with subsampling.Suppose that I had three levels for the
 first hierarchical level and 4 for the second, with 2 subsamples, e.g.
 set.seed(2014)y - rnorm(24, 20, 2)level1 - gl(3, 8)level2 - gl(4,
 2)my.data - data.frame(y, level1, level2)
 Then, I can easily fit a model with nested random effects, i.e.
 y_{ijk} = \mu + \alpha_i + \beta_{ij} + \epsilon_{ijk}
 with \alpha_i ~ N(0, \sigma^2_1) the random effect for level 1, \beta_{ij}
 ~ N(0, \sigma^2_2) the random effect for level 2 and \epsilon_{ijk} ~ N(0,
 sigma^2) the error,
 using the following code
 require(nlme)fit1 - lme(y ~ 1, random=~1|level1/level2, my.data)
 # which is equivalent tofit1 - lme(y ~ 1, random=list(level1=pdDiag(~1),
 level2=pdDiag(~1)), my.data)
 However, I would like to have different variances per each level1 level
 (model i) and then a different model considering different variances per
 each level1 and per each level2 level within level1 (model ii).So we
 would have
 Model (i):\alpha_i ~ N(0, \sigma^2_1_i), \beta_{ij} ~ N(0, \sigma^2_2) and
 \epsilon_{ijk} ~ N(0, sigma^2),
 that is, different sigma^2_1 per level1 level
 Model (ii):\alpha_i ~ N(0, \sigma^2_1_i), \beta_{ij} ~ N(0,
 \sigma^2_2_{ij}) and \epsilon_{ijk} ~ N(0, sigma^2),
 that is, different sigma^2_1 per level1 level and different sigma^2_2
 per level1:level2 level combination
 I tried the following for model (i):
 fit2 - lme(y ~ 1, random=list(level1=pdDiag(~level1)), my.data)
 and this for model (ii):
 fit3 - lme(y ~ 1, random=list(level1=pdDiag(~level1),
 level2=pdDiag(~level1:level2)), my.data)
 This second fit also gives a warning, and I don't believe that these are
 doing what I intend to.I also tried using the weights argument, i.e., for
 model (i)
 fit2.2 - lme(y ~ 1, random=~1|level1/level2,
 weights=varIdent(form=~1|level1), my.data)
 Perhaps this is closer to what I'm trying to do, but when it comes to
 model (ii) I can't properly work the syntax, as the / creates an error,
 so I tried
 fit2.3 - lme(y ~ 1, random=~1|level1/level2,
 weights=varIdent(form=~1|level1*level2), my.data)

 but I'm still doubtful.
 Any suggestions on how I might be able to fit these models?
 Best wishes,Rafael.
 [[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.




-- 
The temperature of the aqueous content of an unremittingly ogled
culinary vessel will not achieve 100 degrees on the Celsius scale.

Maranatha! 
John McKown

[[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] 1. What function to use to read all the files in a directory to a vector in R code? 2. What function to use to coerce character string into numeric?

2014-11-10 Thread John McKown
On Mon, Nov 10, 2014 at 7:12 AM, Aditya Singh aps...@yahoo.com wrote:

 Hi,
 I have 2 queries:
 1. What function to use to read all the files in a directory to a vector
 in R code?
 2. What function to use to coerce character string into numeric?
 As a help to others, I figured out to use setwd(C:/) to set working
 directory!
 Aditya


​First, please don't post in HTML. It is contrary to forum policy. Thanks.

Answer 1: you can get a list of the names of all the files using the
list.files() function. Do a ?list.files for more information.

Answer 2: If I understand your question correctly, then I'd use
as.numeric() .

Suggestion 1: Get  read a good book on R programming. These were very
basic questions. I'd strongly suggest Advanced R by Hadley Wickham. You
can order if Amazon.com, or read it (for free!) here:
http://adv-r.had.co.nz/
​

​Another good one is The Art of R Programming by Norman Matloff. This
later one is what I used, but that's mainly because Hadley's book hadn't
been written (or maybe published) when I was first learning R. ​

​Suggestion 2: If you haven't already, I would strongly recommend getting 
installing RStudio. It is free (as in beer, which is a curious phrase
because beer isn't usually free). http://www.rstudio.com ​

-- 
The temperature of the aqueous content of an unremittingly ogled
culinary vessel will not achieve 100 degrees on the Celsius scale.

Maranatha! 
John McKown

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Split fixed width data in R

2014-10-22 Thread John McKown
On Wed, Oct 22, 2014 at 10:37 AM, Zilefac Elvis zilefacel...@yahoo.com
wrote:

 Hi,
 I have fixed width data that I would like to split into columns. Here is a
 sanpshot of the data (actual data is a list object):
 ​snip


 Thanks,
 AT.


​I see you already have an answer that you like. I will add that read.fwf
might also be a possibility. It's difficult for me to tell if that last
column is always 6 characters in length.

file - textConnection(list_object)
read.fwf(file=file,c(4,2,2,4,6))


-- 
The temperature of the aqueous content of an unremittingly ogled
culinary vessel will not achieve 100 degrees on the Celsius scale.

Maranatha! 
John McKown

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to clear R memory in a for loop

2014-10-20 Thread John McKown
On Mon, Oct 20, 2014 at 10:30 AM, Dimitri Liakhovitski 
dimitri.liakhovit...@gmail.com wrote:

 Dear Rers,

 I am trying to run a for-loop in R.
 During each iteration I read in an mp3 file and do some basic processing.
 If I do what I need to do for each file one by one - it works fine.
 But once I start running a loop, it soon runs out of memory and says: can't
 allocate a vector of size...
 In each iteration of my loop I always overwrite the previously created
 object and do gc().

 Any hints on how to fight this?

 Thanks a lot!



​Please don't use HTML for messages.

What occurs to me, from reading the other replies, is that perhaps within
the loop you are causing other objects to be allocated. And that can be
done just by doing a simple assignment, so it may not be obvious. What this
can do is cause what we called a sand bar in the old days. That's where
you allocate a big chunk of memory for an object. Say this take up 1/2 of
your available space. You now create a small object. This object is
_probably_ right next to the large object. You now release the large
object. Your apparent free space is now almost what it was at the
beginning. But when you try to allocate another large object which is, say,
2/3 of the maximum space, you can't because that small object is sitting
right in the middle of our memory space. So you _can_ allocate 2 large
objects which are 1/3 your free space size, but not 1 object which is 2/3
of the free space size. Which can lead to your type of situation.

This is just a SWAG based on some experience in other systems. Most
garbage collection do _not_ do memory consolidation. I don't know about
R.​


-- 
The temperature of the aqueous content of an unremittingly ogled
culinary vessel will not achieve 100 degrees on the Celsius scale.

Maranatha! 
John McKown

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] grep won't work finding one column

2014-10-14 Thread John McKown
On Tue, Oct 14, 2014 at 9:23 AM, Kate Ignatius kate.ignat...@gmail.com wrote:
 I'm having an issue with grep:

 I have numerous columns that end with .at... when I use grep like so:

 df[,grep(.at,colnames(df))]

 it works fine.  When I have one column that ends with .at, it does not
 work.  Why is that?  As this is loop with varying number of columns
 ending in .at I would like some code that would work with 1 to n
 number of columns.

 Is there something more optimal than grep?

 Thanks!

I can't answer your direct question. But do you realize that your code
does not match your words? The grep show does not _only_ match columns
who name end with the characters '.at'. It matches all column names
which contain any character followed by the characters at. To do the
match with only columns whose names end with the characters .at, you
need: grep(\.at$,colnames(df)).

You might want to post an example which fails. Just to be complete, be
sure to use the dput() function so that it is easy for members of the
group to cut'n'paste to get your data into our own R workspace.

-- 
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! 
John McKown

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] grep won't work finding one column

2014-10-14 Thread John McKown
AT and at are not the same. If you want an case insensitive compare
for the characters at you need the ignore.case=TRUE added. E.g.:

df[,grep(.at,colnames(df),ignore.case=TRUE)

That should match the column name you gave. Which does not match your
initial description which said ending with .at. That has an embedded
AT. So I am still a bit confused about your needs.

On Tue, Oct 14, 2014 at 9:55 AM, Kate Ignatius kate.ignat...@gmail.com wrote:
 For example,

 DF will usually have numerous columns with sample1.at sample1.dp
 sample1.fg sample2.at sample2.dp sample2.fg and so on

 I'm running this code in R as part of a shell script which runs over
 several different file sizes so sometimes it will come across a file
 with one sample in it: i.e. sample1: when the R code runs through this
 file... trying to grep out  the sample1.at column does not work and
 it will halt and stop.

 Here is some sample data... say I want to get out the AT_ only column


 Sample_1 AT_1
 A/A RR
 G/G AA
 T/T AA
 G/A RA
 G/G RR
 C/C AA
 C/C AA
 C/T RA
 A/A AA
 T/G RA

 it will have a problem grepping out this single column.

 On Tue, Oct 14, 2014 at 10:38 AM, John McKown
 john.archie.mck...@gmail.com wrote:
 On Tue, Oct 14, 2014 at 9:23 AM, Kate Ignatius kate.ignat...@gmail.com 
 wrote:
 I'm having an issue with grep:

 I have numerous columns that end with .at... when I use grep like so:

 df[,grep(.at,colnames(df))]

 it works fine.  When I have one column that ends with .at, it does not
 work.  Why is that?  As this is loop with varying number of columns
 ending in .at I would like some code that would work with 1 to n
 number of columns.

 Is there something more optimal than grep?

 Thanks!

 I can't answer your direct question. But do you realize that your code
 does not match your words? The grep show does not _only_ match columns
 who name end with the characters '.at'. It matches all column names
 which contain any character followed by the characters at. To do the
 match with only columns whose names end with the characters .at, you
 need: grep(\.at$,colnames(df)).

 You might want to post an example which fails. Just to be complete, be
 sure to use the dput() function so that it is easy for members of the
 group to cut'n'paste to get your data into our own R workspace.

 --
 There is nothing more pleasant than traveling and meeting new people!
 Genghis Khan

 Maranatha! 
 John McKown



-- 
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! 
John McKown

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] grep won't work finding one column

2014-10-14 Thread John McKown
You're right. I don't use regexps in R very much. In most other
languages, a single \ is needed. The R parser is different and I
forgot. Thanks for the heads up.

On Tue, Oct 14, 2014 at 10:01 AM, Ivan Calandra
ivan.calan...@univ-reims.fr wrote:
 Shouldn't it be
 grep(\\.at$,colnames(df))
 with double back slash?

 Ivan

 --
 Ivan Calandra
 University of Reims Champagne-Ardenne
 GEGENA² - EA 3795
 CREA - 2 esplanade Roland Garros
 51100 Reims, France
 +33(0)3 26 77 36 89
 ivan.calan...@univ-reims.fr
 https://www.researchgate.net/profile/Ivan_Calandra

 Le 14/10/14 16:38, John McKown a écrit :

 On Tue, Oct 14, 2014 at 9:23 AM, Kate Ignatius kate.ignat...@gmail.com
 wrote:

 I'm having an issue with grep:

 I have numerous columns that end with .at... when I use grep like so:

 df[,grep(.at,colnames(df))]

 it works fine.  When I have one column that ends with .at, it does not
 work.  Why is that?  As this is loop with varying number of columns
 ending in .at I would like some code that would work with 1 to n
 number of columns.

 Is there something more optimal than grep?

 Thanks!

 I can't answer your direct question. But do you realize that your code
 does not match your words? The grep show does not _only_ match columns
 who name end with the characters '.at'. It matches all column names
 which contain any character followed by the characters at. To do the
 match with only columns whose names end with the characters .at, you
 need: grep(\.at$,colnames(df)).

 You might want to post an example which fails. Just to be complete, be
 sure to use the dput() function so that it is easy for members of the
 group to cut'n'paste to get your data into our own R workspace.


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



-- 
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! 
John McKown

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] xts array in minutes ?

2014-10-11 Thread John McKown
On Sat, Oct 11, 2014 at 11:03 AM, ce zadi...@excite.com wrote:

 Dear all,

 I want to convert to character arrays  2014-10:10 00:00:00 and 
 2014-10-10:23:59:00 to an array of minutes :

 2014-10:10 00:00:00
 2014-10:10 00:01:00
 2014-10:10 00:02:00

 What is the best way to do it ?
 thanks


Best? I don't know. My way:

minutes-as.xts(as.POSIXct(seq(as.POSIXlt('2014-10-10
00:00:00'),as.POSIXlt('2014-10-10 23:59:00'),'min')));


-- 
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! 
John McKown

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Changing date format

2014-10-10 Thread John McKown
On Fri, Oct 10, 2014 at 1:32 AM, Frederic Ntirenganya ntfr...@gmail.com wrote:

Please try to not post in HTML. It is one of the forum rules.

 Dear All,

 The following function gives me what I wanted.
 The input of function is one value and this push me to use sapply function
 to call it.

 Is there a better way of doing this?

 #
 day - function(x){

  if(x== 60) {
y = 29 Feb
  }

  if(x  60){
 y =  format(strptime(x, format = %j), format =%d-%b)
 }

 if(x  60){
 y =  format(strptime(x - 1, format = %j), format =%d-%b)
}
 y
 }

 sapply(Samaru$Start,day)

  [1] 17-Apr 27-Apr 24-Apr 04-Jun 25-Apr 13-May 22-Apr
 05-May 27-Apr 13-May 27-Apr
 #===

I make no comment about whether the above is correct or you, because
I don't know. There is much that I don't know. There is a way to
reformulate the function in a way that I personally think is better.
You might want to look at:

day - function(x) { ifelse(x==60,29
Feb,format(strptime(x-(x60),format=%j),format=%d-%b)); }

The trick is that x-(x60) will subtract 1 from x when x is greater
than 60, but 0 if it is less than or equal to 60. And the ifelse takes
care of the case where x is equal to 60. As I said, I don't know that
this really gives you want, but it is functionally equivalent to the
code you posted. However, it is not as obvious. As we say about the
lottery: You pay your money, you take your chance.


-- 
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! 
John McKown

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reading in hexadecimal data - not working with data ending in E

2014-10-08 Thread John McKown
On Wed, Oct 8, 2014 at 6:02 AM, mark.ho...@srs.gov wrote:

 I am trying to read in data from an instrument that is recorded in
 hexadecimal format. Using either:

 y.hex - read.table(file=hex.data, as.is=TRUE)

 or

 y.hex - read.table(file=hex.data, text=TRUE)

 gets all the data in just fine except points like `055E` or `020E`. In
 these cases, the E is stripped so I get just 055 or 020.

 The question is how should this data be imported to avoid the E-ending
 problem?

 (By the way, my follow-up is to convert this data using, `y -
 strtoi(y.hex, 16L)`)

 Thanks for any suggestions,


​Please don't post in HTML, it is against forum policy. And it often
results in poorly formatted messages, which many ignore.​

​Try:

y.hex - read.table(file=hex.data,as.is=TRUE,colClasses=character);​




 Mark Hogue



-- 
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! 
John McKown

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] hadley's book

2014-09-29 Thread John McKown
Thanks for the heads up. I just ordered it. Curiously, I can't read it
using the Cloud Reader in my browser, so I'll wait until I get home
to look at it on my Nexus 10.

On Mon, Sep 29, 2014 at 10:59 AM, Mark Leeds marklee...@gmail.com wrote:
 Just a heads up to list: I don't know about other book sites but,  on U.S
 Amazon, Hadley's Advanced R book is no longer in pre-order mode. You can
 purchase the book now without pre-ordering it.

Mark

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



-- 
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! 
John McKown

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Optometrists and Ophthalmologists dataset

2014-09-24 Thread John McKown
CAUTION: SARCASM FOLLOWS!

I'd like to thank Mr Tony Parker of elided for informing the entire
R-HELP community that his company is a strong believer in UCE and
hires marketing people who are completely clueless. The list of
companies which I know to avoid has increased by one. Good on ya,
mate!

===

Oh, did I mention that the email address from the original post is now
in my autodelete list?

On Tue, Sep 23, 2014 at 4:50 PM, Tony Parker elided wrote:
elided

-- 
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! 
John McKown

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Writing .csv file

2014-09-24 Thread John McKown
On Wed, Sep 24, 2014 at 4:00 PM, Steven Yen sye...@gmail.com wrote:
 I use the following command to write data to a .csv file:

 write.csv(yxz,file=foo.csv)

 And I get the following in the file, with one column appended to the file:

 ,fsp,fsec,cincome,
 1,0,3,2.25,...
 2,0,1,2.75,...
 3,1,1,0.625,...

 Question: is there a way to avoid the first column? Thanks.


I'm fairly sure you need:

write.csv(yxz,file=foo.csv,row.names=FALSE);

If you don't want the header row at the top, you might want to try:

write.table(yxz,file=foo.csv,row.names=FALSE,col.names=FALSE,sep=',',qmethod=double);


-- 
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! 
John McKown

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R Inter Process Communication tools/packages ?

2014-09-23 Thread John McKown
On Tue, Sep 23, 2014 at 10:50 AM, ce zadi...@excite.com wrote:

 Hello All,

 Is there any IPC tools like in UNIX/Linux systems in R ?
 I know there is mmap package but I am looking something more like sockets .
 Any example appreciated .

 Thx .


Try looking at the documentation for socketConnection()
?socketConnection

addresses TCPIP sockets, UNIX pipes, and FIFOs.

-- 
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! 
John McKown

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] X11/Intrinsic.h preventing build on rhel

2014-09-19 Thread John McKown
On Fri, Sep 19, 2014 at 1:28 PM, Gaurav Chakravorty
gc...@circulumvite.com wrote:
 I am trying to build R-3.1.0 on RHEL
 But configure returns with an error due to X11/Intrinsic.h missing

 Is there a workaround ?


yum install libXt-devel

This from my Fedora 20 x86_64 installation.

-- 
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! 
John McKown

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How can I create colors correspond to the number of a variable?

2014-09-17 Thread John McKown
First off, please post in plain text not HTML. It is a forum
requirement. HTML posts are often ignored, especially if they look
messy in plain text, which is all that the mailing list software
distributes. It strips off the HTML portion entirely.

Your question is vague in that you didn't indicate what you wanted in
the way of colors and what you were going to do with them. For
plotting? For visually distinguishing one out of 4,000 possible beds
by color on a screen display? If you want plotting, then use ggplot2
and the scale_color_brewer() function:
http://docs.ggplot2.org/current/scale_brewer.html . My personal
opinion is that it is unlikely that an average person will be able to
memorize 4,000 different colors, be able to see one of them, and say
definitively that is bed number ---. Especially if the person is
even mildly color blind. Depending on use, the U.S. ADA (American with
Disabilities Act) may become a factor. Companies need to remember
this. Individuals, not so much.

But rather than give any real opinion about this question, I will just
point out some archive messages which might be of some help.

https://groups.google.com/forum/#!searchin/r-help-archive/$2Br-help$20$2Bcolor/r-help-archive/yOXrLIU-S8M/jc0yRQ6tNZgJ
https://groups.google.com/forum/#!searchin/r-help-archive/$2Br-help$20$2Bcolor/r-help-archive/duLEBjtqzTU/J45x_EB2BAIJ

This doesn't address R, but does address the use of color, and gives a
reference to the R color brewer (http://colorbrewer2.org/)
http://ux.stackexchange.com/questions/17964/how-many-visually-distinct-colors-can-accurately-be-associated-with-a-separate

Pantone, an industry standard in color, has 2,058 colors in their Goe inventory:
http://pantone.custhelp.com/app/answers/detail/a_id/1671/related/1

This site might help you select the colors:
http://www.colorsontheweb.com/

And I do know that I did not directly answer your question with a
piece of code.

On Tue, Sep 16, 2014 at 11:34 PM, wszsdmjj wszsd...@163.com wrote:
 I need to create a color vector with 4000 colors, and I have another
 variable, it contains 4000 element. If my variable is number of bed, and I
 want the color corresponds to the number of bed in this variable. How should
 I do?



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/How-can-I-create-colors-correspond-to-the-number-of-a-variable-tp4697052.html
 Sent from the R help mailing list archive at Nabble.com.
 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



-- 
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! 
John McKown

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   >