Re: [R] change the colour line in gamm4 plotting

2016-07-26 Thread Jim Lemon
Hi Maria,
The "plot.gam" function doesn't use the "col" argument for lines, but
does change the color of points in the second example on the help
page. There doesn't seem to be an easy way to change the function to
get what you want.

Jim


On Tue, Jul 26, 2016 at 11:47 PM, Maria Lathouri via R-help
 wrote:
> Dear all
>
> I am stuck probably in a simple plotting question
>
> My model is:model.1<-gamm4(y~s(x1, by=end.group)+Year+K1+k2+k3, data=.., 
> random=~(1|WB_ID/Site_ID))
> where y is my dependent variable, x1 is the smooth covariate and I use the by 
> argument for the smooth term based on six different groups, and then the 
> Year, k1, k2, k3 are explanatory fixed variables
>
> I use the plot command to plot the model and I get six different 
> plots:plot(model.1$gam, pages=1, xlab=" ", ylab=" ")
> I would like to change the colour of the fitted and the standard error lines, 
> from black which is the default to another colour; I tried to use the col=" " 
> function, at least for the main line, in the plot command but it is not 
> working.
>
> Any advice/suggestion is welcome.
> Many thanks.Maria
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] lm() silently drops NAs

2016-07-26 Thread Andrew Robinson
Agh.  I've argued elsewhere that the default behaviour should be to
fail, and the user should take the responsibility to explicitly handle
the missing values, even if that simply be by changing the argument.
Probably Peter and I have different experiences with the completeness
of datasets, but anything that encourages me not to think about what
I'm doing in that realm seems like a bad idea.

Best wishes,

Andrew

On 27 July 2016 at 07:30, peter dalgaard  wrote:
>
>> On 26 Jul 2016, at 22:26 , Hadley Wickham  wrote:
>>
>> On Tue, Jul 26, 2016 at 3:24 AM, Martin Maechler
>>  wrote:
>>>
> ...
>> To me, this would be the most sensible default behaviour, but I
>> realise it's too late to change without breaking many existing
>> expectations.
>
> Probably.
>
> Re. the default choice, my recollection is that at the time the only choices 
> available were na.omit and na.fail. S-PLUS was using na.fail for all the 
> usual good reasons, but from a practical perspective, the consequence was 
> that, since almost every data set has NA values,  you got an error unless you 
> added na.action=na.omit to every single lm() call. And habitually typing 
> na.action=na.omit doesn't really solve any of the issues with different 
> models being fit to different subsets and all that. So the rationale for 
> doing it differently in R was that it was better to get some probably 
> meaningful output rather than to be certain of getting nothing. And, that was 
> what the mainstream packages of the time were doing.
>
>> On a related note, I've never really understood why it's called
>> na.exclude - from my perspective it causes the _inclusion_ of missing
>> values in the predictions/residuals.
>
> I think the notion is that you exclude them from the analysis, but keep them 
> around for the other purposes.
>
> -pd
>
>>
>> Thanks for the (as always!) informative response, Martin.
>>
>> Hadley
>>
>> --
>> http://hadley.nz
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Andrew Robinson
Deputy Director, CEBRA, School of Biosciences
Reader & Associate Professor in Applied Statistics  Tel: (+61) 0403 138 955
School of Mathematics and StatisticsFax: +61-3-8344 4599
University of Melbourne, VIC 3010 Australia
Email: a.robin...@ms.unimelb.edu.au
Website: http://www.ms.unimelb.edu.au/~andrewpr

MSME: http://www.crcpress.com/product/isbn/9781439858028
FAwR: http://www.ms.unimelb.edu.au/~andrewpr/FAwR/
SPuR: http://www.ms.unimelb.edu.au/spuRs/

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Ocr

2016-07-26 Thread boB Rudis
https://cran.rstudio.com/web/packages/abbyyR/index.html

https://github.com/greenore/ocR

https://electricarchaeology.ca/2014/07/15/doing-ocr-within-r/

that was from a Google "r ocr" search. So, yes, there are options.

On Tue, Jul 26, 2016 at 6:43 PM, Achim Zeileis  wrote:
> On Wed, 27 Jul 2016, Shane Carey wrote:
>
>> Cool, thanks Jim!!
>> I would love to be able to write my own script for this as I have many
>> images/ pdf's in a folder and would like to batch process them using an R
>> script!!
>
>
> The underlying engine is "tesseract" which is also available as a
> command-line tool and on other OSs. In principle, it is not hard to call it
> with a system() command and then readLines() the resulting text. However, it
> might be useful to play with the available options in the GUI first to see
> what works best for your images.
>
>
>> Thanks
>>
>> On Tuesday, July 26, 2016, Jim Lemon  wrote:
>>
>>> Hi Shane,
>>> FreeOCR is a really good place to start.
>>>
>>> http://www.paperfile.net/
>>>
>>> Jim
>>>
>>>
>>> On Wed, Jul 27, 2016 at 6:11 AM, Shane Carey >> > wrote:

 Hi,

 Has anyone ever done any ocr in R?? I have some scanned images that I
>>>
>>> would

 like to convert to text!!
 Thanks


 --
 Le gach dea ghui,
 Shane

 [[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.
>>>
>>>
>>
>>
>> --
>> Le gach dea ghui,
>> Shane
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Windows 10 Application Compatibility Check | FreeWare R Statistical Environment v3.2.2

2016-07-26 Thread Robert Baer

Runs fine on Windows 10 for me.


On 7/25/2016 7:18 AM, Ramar, Rohini wrote:

Hello Team,

We are, Citi Application Readiness Team, need your assistance in order to gather info 
about below application compatibility and support for Win 10 as part of Window 10 
Readiness initiative. CITI Bank has been using below "FreeWare R Statistical 
Environment v3.2.2"  software products currently on Win 7 operating system.

We would like to know whether the below listed application is compatible and 
supported even for Win 10 (64 Bit) or is there any other higher version of 
application which would be compatible for Win10. If you have not tested for Win 
10, could you please provide us with a tentative date by when we can reach you.

Application Name : FreeWare R Statistical Environment v3.2.2


Note: Kindly re-direct this email to appropriate team if we reached you wrongly.


Regards,
Rohini R
Citi Architecture & Technology Engineering
Client Computing
Direct Phone #:+91 22 3346 1497
Email ID: rohini.ra...@citi.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.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Ocr

2016-07-26 Thread Achim Zeileis

On Wed, 27 Jul 2016, Shane Carey wrote:


Cool, thanks Jim!!
I would love to be able to write my own script for this as I have many
images/ pdf's in a folder and would like to batch process them using an R
script!!


The underlying engine is "tesseract" which is also available as a 
command-line tool and on other OSs. In principle, it is not hard to call 
it with a system() command and then readLines() the resulting text. 
However, it might be useful to play with the available options in the GUI 
first to see what works best for your images.



Thanks

On Tuesday, July 26, 2016, Jim Lemon  wrote:


Hi Shane,
FreeOCR is a really good place to start.

http://www.paperfile.net/

Jim


On Wed, Jul 27, 2016 at 6:11 AM, Shane Carey > wrote:

Hi,

Has anyone ever done any ocr in R?? I have some scanned images that I

would

like to convert to text!!
Thanks


--
Le gach dea ghui,
Shane

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





--
Le gach dea ghui,
Shane

[[alternative HTML version deleted]]

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



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


Re: [R] Ocr

2016-07-26 Thread Jim Lemon
Hi Shane,
If you want to run OCR on the command line, the Tessaract engine is
probably the way to go. Harder to build and install, but you can call
it from an R session.

Jim


On Wed, Jul 27, 2016 at 8:24 AM, Shane Carey  wrote:
> Cool, thanks Jim!!
> I would love to be able to write my own script for this as I have many
> images/ pdf's in a folder and would like to batch process them using an R
> script!!
> Thanks
>
>
> On Tuesday, July 26, 2016, Jim Lemon  wrote:
>>
>> Hi Shane,
>> FreeOCR is a really good place to start.
>>
>> http://www.paperfile.net/
>>
>> Jim
>>
>>
>> On Wed, Jul 27, 2016 at 6:11 AM, Shane Carey  wrote:
>> > Hi,
>> >
>> > Has anyone ever done any ocr in R?? I have some scanned images that I
>> > would
>> > like to convert to text!!
>> > Thanks
>> >
>> >
>> > --
>> > Le gach dea ghui,
>> > Shane
>> >
>> > [[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.
>
>
>
> --
> Le gach dea ghui,
> Shane
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Ocr

2016-07-26 Thread Shane Carey
Cool, thanks Jim!!
I would love to be able to write my own script for this as I have many
images/ pdf's in a folder and would like to batch process them using an R
script!!
Thanks

On Tuesday, July 26, 2016, Jim Lemon  wrote:

> Hi Shane,
> FreeOCR is a really good place to start.
>
> http://www.paperfile.net/
>
> Jim
>
>
> On Wed, Jul 27, 2016 at 6:11 AM, Shane Carey  > wrote:
> > Hi,
> >
> > Has anyone ever done any ocr in R?? I have some scanned images that I
> would
> > like to convert to text!!
> > Thanks
> >
> >
> > --
> > Le gach dea ghui,
> > Shane
> >
> > [[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.
>


-- 
Le gach dea ghui,
Shane

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

2016-07-26 Thread Jim Lemon
Hi Shane,
FreeOCR is a really good place to start.

http://www.paperfile.net/

Jim


On Wed, Jul 27, 2016 at 6:11 AM, Shane Carey  wrote:
> Hi,
>
> Has anyone ever done any ocr in R?? I have some scanned images that I would
> like to convert to text!!
> Thanks
>
>
> --
> Le gach dea ghui,
> Shane
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] removing all non-numeric characters from a string, but not "."

2016-07-26 Thread Dimitri Liakhovitski
Thank you very much, gentlemen!

On Tue, Jul 26, 2016 at 5:48 PM, peter dalgaard  wrote:
>
>> On 26 Jul 2016, at 23:28 , Dimitri Liakhovitski 
>>  wrote:
>>
>> Hello!
>>
>> I have a string x:
>> x <- c("x - 84", "y - 293.04", "z = 12.5")
>>
>> I want to remove all the non-numeric stuff from it. The following works:
>> gsub("[^0-9]", "", x)
>>
>> However, it strips my numbers of "."
>>
>> Help - how could I do the same but leave the "." in?
>
> How about this?
>
>> gsub("[^0-9.]", "", x)
> [1] "84" "293.04" "12.5"
>
> -pd
>
>>
>> Thanks a lot!
>>
>> --
>> Dimitri Liakhovitski
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
>
>
>
>
>
>
>
>
>



-- 
Dimitri Liakhovitski

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] removing all non-numeric characters from a string, but not "."

2016-07-26 Thread peter dalgaard

> On 26 Jul 2016, at 23:28 , Dimitri Liakhovitski 
>  wrote:
> 
> Hello!
> 
> I have a string x:
> x <- c("x - 84", "y - 293.04", "z = 12.5")
> 
> I want to remove all the non-numeric stuff from it. The following works:
> gsub("[^0-9]", "", x)
> 
> However, it strips my numbers of "."
> 
> Help - how could I do the same but leave the "." in?

How about this?

> gsub("[^0-9.]", "", x)
[1] "84" "293.04" "12.5"  

-pd

> 
> Thanks a lot!
> 
> -- 
> Dimitri Liakhovitski
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] removing all non-numeric characters from a string, but not "."

2016-07-26 Thread Marc Schwartz

> On Jul 26, 2016, at 4:39 PM, Marc Schwartz  wrote:
> 
> 
>> On Jul 26, 2016, at 4:28 PM, Dimitri Liakhovitski 
>>  wrote:
>> 
>> Hello!
>> 
>> I have a string x:
>> x <- c("x - 84", "y - 293.04", "z = 12.5")
>> 
>> I want to remove all the non-numeric stuff from it. The following works:
>> gsub("[^0-9]", "", x)
>> 
>> However, it strips my numbers of "."
>> 
>> Help - how could I do the same but leave the "." in?
>> 
>> Thanks a lot!
>> 
>> -- 
>> Dimitri Liakhovitski
> 
> 
>> gsub("[^0-9\\.]", "", x)
> [1] "84" "293.04" "12.5"  
> 
> The period needs to be escaped since it otherwise has special meaning in the 
> regex.
> 
> Regards,
> 
> Marc Schwartz


Actually, let me correct my reply.

When in a character group, as is the case here, the period does not need to be 
escaped:

> gsub("[^0-9.]", "", x)
[1] "84" "293.04" "12.5"  


Regards,

Marc

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] removing all non-numeric characters from a string, but not "."

2016-07-26 Thread David Winsemius

> On Jul 26, 2016, at 2:28 PM, Dimitri Liakhovitski 
>  wrote:
> 
> gsub("[^0-9]", "", x)


?regex

I think you might be bit embarrassed because it seems pretty obvious once you 
know that character class elements like "." don't need to be escaped so it's 
just this:

> gsub("[^0-9.]", "", x)
[1] "84" "293.04" "12.5"  

You might want to add in some separator if you are processing expression this 
way.

> gsub("[^0-9., ]", "", gsub( "[-+*/]", " , ", x) )
[1] "  ,  84"  "  ,  293.04  ,  1200" "  12.5"  

-- 
David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] removing all non-numeric characters from a string, but not "."

2016-07-26 Thread Marc Schwartz

> On Jul 26, 2016, at 4:28 PM, Dimitri Liakhovitski 
>  wrote:
> 
> Hello!
> 
> I have a string x:
> x <- c("x - 84", "y - 293.04", "z = 12.5")
> 
> I want to remove all the non-numeric stuff from it. The following works:
> gsub("[^0-9]", "", x)
> 
> However, it strips my numbers of "."
> 
> Help - how could I do the same but leave the "." in?
> 
> Thanks a lot!
> 
> -- 
> Dimitri Liakhovitski


> gsub("[^0-9\\.]", "", x)
[1] "84" "293.04" "12.5"  

The period needs to be escaped since it otherwise has special meaning in the 
regex.

Regards,

Marc Schwartz

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


Re: [R] lm() silently drops NAs

2016-07-26 Thread peter dalgaard

> On 26 Jul 2016, at 22:26 , Hadley Wickham  wrote:
> 
> On Tue, Jul 26, 2016 at 3:24 AM, Martin Maechler
>  wrote:
>> 
...
> To me, this would be the most sensible default behaviour, but I
> realise it's too late to change without breaking many existing
> expectations.

Probably. 

Re. the default choice, my recollection is that at the time the only choices 
available were na.omit and na.fail. S-PLUS was using na.fail for all the usual 
good reasons, but from a practical perspective, the consequence was that, since 
almost every data set has NA values,  you got an error unless you added 
na.action=na.omit to every single lm() call. And habitually typing 
na.action=na.omit doesn't really solve any of the issues with different models 
being fit to different subsets and all that. So the rationale for doing it 
differently in R was that it was better to get some probably meaningful output 
rather than to be certain of getting nothing. And, that was what the mainstream 
packages of the time were doing.

> On a related note, I've never really understood why it's called
> na.exclude - from my perspective it causes the _inclusion_ of missing
> values in the predictions/residuals.

I think the notion is that you exclude them from the analysis, but keep them 
around for the other purposes.

-pd

> 
> Thanks for the (as always!) informative response, Martin.
> 
> Hadley
> 
> -- 
> http://hadley.nz
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Time format issue

2016-07-26 Thread David Winsemius

> On Jul 26, 2016, at 11:24 AM, kolkata kolkata  wrote:
> 
> Hello Everyone,
> 
> I have a file with time in the following format:
> 
> Time
> 
> 27DEC11:00:30
> 
> 27DEC11:01:30
> 
> 27DEC11:02:00
> 
> …….
> 
> The time column is factor. I want to convert each time to the following
> format:
> 
> 20111211003000
> 
> 20111211013000
> 
> 2011121102
> 
> (Year)(month)(date)(hr)(min)(sec)

> newTimeDt <- strptime(Time, format="%d%b%y:%H:%M")
> newTimeDt
[1] "2011-12-27 00:30:00 PST" "2011-12-27 01:30:00 PST" "2011-12-27 02:00:00 
PST"
> newTimeDt <- as.POSIXct(Time, format="%d%b%y:%H:%M")
> newTimeDt
[1] "2011-12-27 00:30:00 PST" "2011-12-27 01:30:00 PST" "2011-12-27 02:00:00 
PST"
> newOut <- format(newTimeDt, "%Y%m%d%H%M")
> newOut
[1] "201112270030" "201112270130" "201112270200"
> newOut <- format(newTimeDt, "%Y%m%d%H%M%S")
> newOut
[1] "20111227003000" "20111227013000" "2011122702"

> 

> 
> Any suggestions in this regard
> 
> regards,
> 
> manik mitra
> 
>   [[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.

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] removing all non-numeric characters from a string, but not "."

2016-07-26 Thread Dimitri Liakhovitski
Hello!

I have a string x:
x <- c("x - 84", "y - 293.04", "z = 12.5")

I want to remove all the non-numeric stuff from it. The following works:
gsub("[^0-9]", "", x)

However, it strips my numbers of "."

Help - how could I do the same but leave the "." in?

Thanks a lot!

-- 
Dimitri Liakhovitski

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] about netcdf files

2016-07-26 Thread Roy Mendelssohn - NOAA Federal
Hi Lily:

> On Jul 26, 2016, at 2:00 PM, lily li  wrote:
> 
> Here are the results. Yes, I tried to read netcdf files, but cannot grasp the 
> contents. Thanks for helping out.
> 
> > str(pre1)

A guide to netcdf files and R can be found at 
https://www.image.ucar.edu/GSP/Software/Netcdf/, it would be worth your time to 
read through it.  Not certain why you want .csv files,  but I can give you a 
rough idea of how to read a slice into a variable in R,  it is then up to you 
to save the result as a .csv.

netcdf files have parameters, precipitation in this case, defined on a grid, in 
your case (lon, lat, time).  The file contains dimensions,  which gives the 
number of points in each dimension of the grid, and coordinate variables,  
which give the values of that coordinate variable at each grid point.  So if I 
wanted to to subset at a certain lat, lon - I would first need to get those 
values

> lat <- ncvar_get(pre1, "lat")
> lon <- ncvar_get(pre1, "lon")
> 

I have no idea of contents of your file, but let's say you know there is a lat 
of 30, and a lon of 120, so I would have to find where they occur:

> myLat <- which(lat == 30)
> myLon <- which(lon == 120)

then you get the slice at that lat-lon for all time by telling ncvar_get where 
to start on the grid, and how many steps to take:

> myPrecip <- ncvar_get(pre1,"precipitation", start = c(myLat, myLon,1), count 
> = c(1, 1, -1))

where the -1 value tells it to get all the values along the time dimension.  
You now have that slice of the data stored in myPrecip.  I hope this gets you 
started, but i strongly urge you to read through the link above.

-Roy

> 
> On Tue, Jul 26, 2016 at 2:52 PM, Roy Mendelssohn - NOAA Federal 
>  wrote:
> Hi Lily:
> 
> I doubt the mail-list would pass through the netcdf file. Instead, could you 
> do the following, and post the results:
> 
> library(ncdf4
> pre1 = nc_open('sample_precip_daily.nc')
> str(pre1)
> nc_close(pre1)
> 
> I have a feeling you haven't worked much with netcdf files. I will try to 
> find a tutorial also to help you along.
> 
> Thanks,
> 
> -Roy
> 
> > On Jul 26, 2016, at 12:07 PM, lily li  wrote:
> >
> > Thanks for your reply. But it says "Error in (function (classes, fdef,
> > mtable)):
> > unable to find an inherited method for function 'brick' for signature
> > 'ncdf4' "
> >
> > The dataset is attached. It contains daily precipitation data for 20 years,
> > within a rectangle, so that there are several grid points. I use the code
> > to open it, but don't know how to get csv files, while each file contains
> > continuous daily precipitation data for each grid cell.
> > pre1 = nc_open('sample_precip_daily.nc')
> > pre1
> > pre1_rd = ncvar_get(pre1, 'precipitation')
> > nc_close(pre1)
> >
> > Thanks for your help.
> >
> > On Tue, Jul 26, 2016 at 4:08 AM, Jon Skoien 
> > wrote:
> >
> >> You could try with the brick function from the raster package.
> >>
> >> bvar = brick(netcdfName)
> >>
> >> This uses the ncdf4 functions for opening and reading the netcdf, but
> >> makes it easier to extract data for each day:
> >>
> >> p1 = rasterToPoints(bvar[[1]])
> >> and write p1 to csv.
> >>
> >> Best,
> >> Jon
> >>
> >>
> >>
> >> On 7/26/2016 6:54 AM, lily li wrote:
> >>
> >>> Hi all,
> >>>
> >>> I have a problem in opening netcdf files. If one netcdf file contains
> >>> longitude, latitude, and daily precipitation. How to relate each
> >>> precipitation record to its associated location, and export them as csv
> >>> files? Thanks.
> >>>
> >>> I just use nc_open(), ncvar_get(), but it is not very helpful. Thanks for
> >>> any ideas.
> >>>
> >>>[[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.
> >>>
> >>>
> >> --
> >> Jon Olav Skøien
> >> Joint Research Centre - European Commission
> >> Institute for Space, Security & Migration
> >> Disaster Risk Management Unit
> >>
> >> Via E. Fermi 2749, TP 122,  I-21027 Ispra (VA), ITALY
> >>
> >> jon.sko...@jrc.ec.europa.eu
> >> Tel:  +39 0332 789205
> >>
> >> Disclaimer: Views expressed in this email are those of the individual and
> >> do not necessarily represent official views of the European Commission.
> >>
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/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 contents of this message do not reflect any position of the U.S. 
> 

Re: [R] about netcdf files

2016-07-26 Thread lily li
How to read continuous daily precipitation at each grid cell, and then
export to a csv file? Later, there should be several csv files, each
represents daily precipitation data for one grid cell. Thanks a lot.

On Tue, Jul 26, 2016 at 2:52 PM, Roy Mendelssohn - NOAA Federal <
roy.mendelss...@noaa.gov> wrote:

> Hi Lily:
>
> I doubt the mail-list would pass through the netcdf file. Instead, could
> you do the following, and post the results:
>
> library(ncdf4
> pre1 = nc_open('sample_precip_daily.nc')
> str(pre1)
> nc_close(pre1)
>
> I have a feeling you haven't worked much with netcdf files. I will try to
> find a tutorial also to help you along.
>
> Thanks,
>
> -Roy
>
> > On Jul 26, 2016, at 12:07 PM, lily li  wrote:
> >
> > Thanks for your reply. But it says "Error in (function (classes, fdef,
> > mtable)):
> > unable to find an inherited method for function 'brick' for signature
> > 'ncdf4' "
> >
> > The dataset is attached. It contains daily precipitation data for 20
> years,
> > within a rectangle, so that there are several grid points. I use the code
> > to open it, but don't know how to get csv files, while each file contains
> > continuous daily precipitation data for each grid cell.
> > pre1 = nc_open('sample_precip_daily.nc')
> > pre1
> > pre1_rd = ncvar_get(pre1, 'precipitation')
> > nc_close(pre1)
> >
> > Thanks for your help.
> >
> > On Tue, Jul 26, 2016 at 4:08 AM, Jon Skoien  >
> > wrote:
> >
> >> You could try with the brick function from the raster package.
> >>
> >> bvar = brick(netcdfName)
> >>
> >> This uses the ncdf4 functions for opening and reading the netcdf, but
> >> makes it easier to extract data for each day:
> >>
> >> p1 = rasterToPoints(bvar[[1]])
> >> and write p1 to csv.
> >>
> >> Best,
> >> Jon
> >>
> >>
> >>
> >> On 7/26/2016 6:54 AM, lily li wrote:
> >>
> >>> Hi all,
> >>>
> >>> I have a problem in opening netcdf files. If one netcdf file contains
> >>> longitude, latitude, and daily precipitation. How to relate each
> >>> precipitation record to its associated location, and export them as csv
> >>> files? Thanks.
> >>>
> >>> I just use nc_open(), ncvar_get(), but it is not very helpful. Thanks
> for
> >>> any ideas.
> >>>
> >>>[[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.
> >>>
> >>>
> >> --
> >> Jon Olav Skøien
> >> Joint Research Centre - European Commission
> >> Institute for Space, Security & Migration
> >> Disaster Risk Management Unit
> >>
> >> Via E. Fermi 2749, TP 122,  I-21027 Ispra (VA), ITALY
> >>
> >> jon.sko...@jrc.ec.europa.eu
> >> Tel:  +39 0332 789205
> >>
> >> Disclaimer: Views expressed in this email are those of the individual
> and
> >> do not necessarily represent official views of the European Commission.
> >>
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/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 contents of this message do not reflect any position of the U.S.
> Government or NOAA."
> **
> Roy Mendelssohn
> Supervisory Operations Research Analyst
> NOAA/NMFS
> Environmental Research Division
> Southwest Fisheries Science Center
> ***Note new address and phone***
> 110 Shaffer Road
> Santa Cruz, CA 95060
> Phone: (831)-420-3666
> Fax: (831) 420-3980
> e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/
>
> "Old age and treachery will overcome youth and skill."
> "From those who have been given much, much will be expected"
> "the arc of the moral universe is long, but it bends toward justice" -MLK
> Jr.
>
>

[[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] about netcdf files

2016-07-26 Thread lily li
Here are the results. Yes, I tried to read netcdf files, but cannot grasp
the contents. Thanks for helping out.

> str(pre1)
List of 14
 $ filename   : chr "~/Downloads/sample_precip_daily.nc"
 $ writable   : logi FALSE
 $ id : int 262144
 $ safemode   : logi FALSE
 $ format : chr "NC_FORMAT_CLASSIC"
 $ is_GMT : logi FALSE
 $ groups :List of 1
  ..$ :List of 7
  .. ..$ id   : int 262144
  .. ..$ name : chr ""
  .. ..$ ndims: int 3
  .. ..$ nvars: int 4
  .. ..$ natts: int 48
  .. ..$ dimid: int [1:3(1d)] 0 1 2
  .. ..$ fqgn : chr ""
  .. ..- attr(*, "class")= chr "ncgroup4"
 $ fqgn2Rindex:List of 1
  ..$ : int 1
 $ ndims  : num 3
 $ natts  : num 48
 $ dim:List of 3
  ..$ time:List of 11
  .. ..$ name : chr "time"
  .. ..$ len  : int 7305
  .. ..$ unlim: logi FALSE
  .. ..$ group_index  : int 1
  .. ..$ group_id : int 262144
  .. ..$ id   : int 0
  .. ..$ dimvarid :List of 5
  .. .. ..$ id : int 1
  .. .. ..$ group_index: int 1
  .. .. ..$ group_id   : int 262144
  .. .. ..$ list_index : num -1
  .. .. ..$ isdimvar   : logi TRUE
  .. .. ..- attr(*, "class")= chr "ncid4"
  .. ..$ units: chr "days since 1900-01-01 00:00:00"
  .. ..$ calendar : chr "gregorian"
  .. ..$ vals : num [1:7305(1d)] 38716 38717 38718 38719 38720 ...
  .. ..$ create_dimvar: logi TRUE
  .. ..- attr(*, "class")= chr "ncdim4"
  ..$ lat :List of 10
  .. ..$ name : chr "lat"
  .. ..$ len  : int 5
  .. ..$ unlim: logi FALSE
  .. ..$ group_index  : int 1
  .. ..$ group_id : int 262144
  .. ..$ id   : int 1
  .. ..$ dimvarid :List of 5
  .. .. ..$ id : int 2
  .. .. ..$ group_index: int 1
  .. .. ..$ group_id   : int 262144
  .. .. ..$ list_index : num -1
  .. .. ..$ isdimvar   : logi TRUE
  .. .. ..- attr(*, "class")= chr "ncid4"
  .. ..$ units: chr "degrees_north"
  .. ..$ vals : num [1:5(1d)] 39.8 39.9 40 40 40.1
  .. ..$ create_dimvar: logi TRUE
  .. ..- attr(*, "class")= chr "ncdim4"
  ..$ lon :List of 10
  .. ..$ name : chr "lon"
  .. ..$ len  : int 9
  .. ..$ unlim: logi FALSE
  .. ..$ group_index  : int 1
  .. ..$ group_id : int 262144
  .. ..$ id   : int 2
  .. ..$ dimvarid :List of 5
  .. .. ..$ id : int 3
  .. .. ..$ group_index: int 1
  .. .. ..$ group_id   : int 262144
  .. .. ..$ list_index : num -1
  .. .. ..$ isdimvar   : logi TRUE
  .. .. ..- attr(*, "class")= chr "ncid4"
  .. ..$ units: chr "degrees_east"
  .. ..$ vals : num [1:9(1d)] 254 254 254 254 255 ...
  .. ..$ create_dimvar: logi TRUE
  .. ..- attr(*, "class")= chr "ncdim4"
 $ unlimdimid : num -1
 $ nvars  : num 1
 $ var:List of 1
  ..$ precipitation:List of 22
  .. ..$ id:List of 5
  .. .. ..$ id : num 0
  .. .. ..$ group_index: num -1
  .. .. ..$ group_id   : int 262144
  .. .. ..$ list_index : num 1
  .. .. ..$ isdimvar   : logi FALSE
  .. .. ..- attr(*, "class")= chr "ncid4"
  .. ..$ name  : chr "precipitation"
  .. ..$ ndims : int 3
  .. ..$ natts : int 9
  .. ..$ size  : int [1:3] 9 5 7305
  .. ..$ dimids: int [1:3] 2 1 0
  .. ..$ prec  : chr "float"
  .. ..$ units : chr "mm"
  .. ..$ longname  : chr "Precipitation"
  .. ..$ group_index   : int 1
  .. ..$ chunksizes: logi NA
  .. ..$ storage   : num 1
  .. ..$ shuffle   : logi FALSE
  .. ..$ compression   : logi NA
  .. ..$ dims  : list()
  .. ..$ dim   :List of 3
  .. .. ..$ :List of 10
  .. .. .. ..$ name : chr "lon"
  .. .. .. ..$ len  : int 9
  .. .. .. ..$ unlim: logi FALSE
  .. .. .. ..$ group_index  : int 1
  .. .. .. ..$ group_id : int 262144
  .. .. .. ..$ id   : int 2
  .. .. .. ..$ dimvarid :List of 5
  .. .. .. .. ..$ id : int 3
  .. .. .. .. ..$ group_index: int 1
  .. .. .. .. ..$ group_id   : int 262144
  .. .. .. .. ..$ list_index : num -1
  .. .. .. .. ..$ isdimvar   : logi TRUE
  .. .. .. .. ..- attr(*, "class")= chr "ncid4"
  .. .. .. ..$ units: chr "degrees_east"
  .. .. .. ..$ vals : num [1:9(1d)] 254 254 254 254 255 ...
  .. .. .. ..$ create_dimvar: logi TRUE
  .. .. .. ..- attr(*, "class")= chr "ncdim4"
  .. .. ..$ :List of 10
  .. .. .. ..$ name : chr "lat"
  .. .. .. ..$ len  : int 5
  .. .. .. ..$ unlim: logi FALSE
  .. .. .. ..$ group_index  : int 1
  .. .. .. ..$ group_id : int 262144
  .. .. .. ..$ id   : int 1
  .. .. .. ..$ dimvarid :List of 5
  .. .. .. .. ..$ id : int 2
  .. .. .. .. ..$ group_index: int 1
  .. .. .. .. ..$ group_id   : int 262144
  .. .. .. .. ..$ list_index : num -1
  .. .. .. .. ..$ isdimvar   : logi TRUE
  .. .. .. .. ..- attr(*, "class")= chr "ncid4"
  .. .. .. ..$ units: chr "degrees_north"
  .. .. .. ..$ vals : num 

Re: [R] about netcdf files

2016-07-26 Thread Roy Mendelssohn - NOAA Federal
Hi Lily:

I doubt the mail-list would pass through the netcdf file. Instead, could you do 
the following, and post the results:

library(ncdf4
pre1 = nc_open('sample_precip_daily.nc')
str(pre1)
nc_close(pre1)

I have a feeling you haven't worked much with netcdf files. I will try to find 
a tutorial also to help you along.

Thanks,

-Roy

> On Jul 26, 2016, at 12:07 PM, lily li  wrote:
> 
> Thanks for your reply. But it says "Error in (function (classes, fdef,
> mtable)):
> unable to find an inherited method for function 'brick' for signature
> 'ncdf4' "
> 
> The dataset is attached. It contains daily precipitation data for 20 years,
> within a rectangle, so that there are several grid points. I use the code
> to open it, but don't know how to get csv files, while each file contains
> continuous daily precipitation data for each grid cell.
> pre1 = nc_open('sample_precip_daily.nc')
> pre1
> pre1_rd = ncvar_get(pre1, 'precipitation')
> nc_close(pre1)
> 
> Thanks for your help.
> 
> On Tue, Jul 26, 2016 at 4:08 AM, Jon Skoien 
> wrote:
> 
>> You could try with the brick function from the raster package.
>> 
>> bvar = brick(netcdfName)
>> 
>> This uses the ncdf4 functions for opening and reading the netcdf, but
>> makes it easier to extract data for each day:
>> 
>> p1 = rasterToPoints(bvar[[1]])
>> and write p1 to csv.
>> 
>> Best,
>> Jon
>> 
>> 
>> 
>> On 7/26/2016 6:54 AM, lily li wrote:
>> 
>>> Hi all,
>>> 
>>> I have a problem in opening netcdf files. If one netcdf file contains
>>> longitude, latitude, and daily precipitation. How to relate each
>>> precipitation record to its associated location, and export them as csv
>>> files? Thanks.
>>> 
>>> I just use nc_open(), ncvar_get(), but it is not very helpful. Thanks for
>>> any ideas.
>>> 
>>>[[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.
>>> 
>>> 
>> --
>> Jon Olav Skøien
>> Joint Research Centre - European Commission
>> Institute for Space, Security & Migration
>> Disaster Risk Management Unit
>> 
>> Via E. Fermi 2749, TP 122,  I-21027 Ispra (VA), ITALY
>> 
>> jon.sko...@jrc.ec.europa.eu
>> Tel:  +39 0332 789205
>> 
>> Disclaimer: Views expressed in this email are those of the individual and
>> do not necessarily represent official views of the European Commission.
>> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 contents of this message do not reflect any position of the U.S. 
Government or NOAA."
**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
***Note new address and phone***
110 Shaffer Road
Santa Cruz, CA 95060
Phone: (831)-420-3666
Fax: (831) 420-3980
e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected" 
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] about netcdf files

2016-07-26 Thread lily li
Thanks for your reply. But it says "Error in (function (classes, fdef,
mtable)):
unable to find an inherited method for function 'brick' for signature
'ncdf4' "

The dataset is attached. It contains daily precipitation data for 20 years,
within a rectangle, so that there are several grid points. I use the code
to open it, but don't know how to get csv files, while each file contains
continuous daily precipitation data for each grid cell.
pre1 = nc_open('sample_precip_daily.nc')
pre1
pre1_rd = ncvar_get(pre1, 'precipitation')
nc_close(pre1)

Thanks for your help.

On Tue, Jul 26, 2016 at 4:08 AM, Jon Skoien 
wrote:

> You could try with the brick function from the raster package.
>
> bvar = brick(netcdfName)
>
> This uses the ncdf4 functions for opening and reading the netcdf, but
> makes it easier to extract data for each day:
>
> p1 = rasterToPoints(bvar[[1]])
> and write p1 to csv.
>
> Best,
> Jon
>
>
>
> On 7/26/2016 6:54 AM, lily li wrote:
>
>> Hi all,
>>
>> I have a problem in opening netcdf files. If one netcdf file contains
>> longitude, latitude, and daily precipitation. How to relate each
>> precipitation record to its associated location, and export them as csv
>> files? Thanks.
>>
>> I just use nc_open(), ncvar_get(), but it is not very helpful. Thanks for
>> any ideas.
>>
>> [[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.
>>
>>
> --
> Jon Olav Skøien
> Joint Research Centre - European Commission
> Institute for Space, Security & Migration
> Disaster Risk Management Unit
>
> Via E. Fermi 2749, TP 122,  I-21027 Ispra (VA), ITALY
>
> jon.sko...@jrc.ec.europa.eu
> Tel:  +39 0332 789205
>
> Disclaimer: Views expressed in this email are those of the individual and
> do not necessarily represent official views of the European Commission.
>
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] lm() silently drops NAs

2016-07-26 Thread Hadley Wickham
> I think that's a bit too strict for me, so I wrote my own:
>
> na.warn <- function(object, ...) {
>   missing <- complete.cases(object)
>   if (any(missing)) {
> warning("Dropping ", sum(missing), " rows with missing values",
> call. = FALSE)
>   }
>
>   na.exclude(object, ...)
> }

That should, of course, have been:

missing <- !complete.cases(object)

:-/

Hadley

-- 
http://hadley.nz

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Time format issue

2016-07-26 Thread kolkata kolkata
Hello Everyone,

I have a file with time in the following format:

Time

27DEC11:00:30

27DEC11:01:30

27DEC11:02:00

…….

The time column is factor. I want to convert each time to the following
format:

20111211003000

20111211013000

2011121102

(Year)(month)(date)(hr)(min)(sec)


Any suggestions in this regard

regards,

manik mitra

[[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] Visualization of a Convex Hull in R (Possibly with RGL)

2016-07-26 Thread Duncan Murdoch

On 26/07/2016 10:34 AM, Lorenzo Isella wrote:

On Tue, Jul 26, 2016 at 10:48:22AM +, Michael Sumner wrote:

On Tue, 26 Jul 2016 at 20:29 Lorenzo Isella 
wrote:


Dear All,
I am not an expert about the calculation and visualization of convex
hulls, but I am trying to do something relatively simple.
Please consider the snippet at the end of the email.
The array pts  represents the position of (the centres of) a set of
spheres in 3D (whose radius is 0.5).
I found the geometry package which provides bindings to the qhull
(http://www.qhull.org/) library and allows me to calculate the convex
hull of pts and some interesting properties, like the area and the
volume of the convex hull.
That is all fine, but I would like to represent the results in 3D.
I would like to see a set of spheres with the given position in pts
and the radius R=0.5 and the convex hull going based on the
coordinates of pts.
Does anybody know how to achieve that?
Many thanks

Lorenzo






library(geometry)



pts <- read.table("test-agg.dat")

## names(pts) <- c("x", "y", "z")


pts <- structure(list(x = c(0.145138112090815, 0.880429452229448,
-1.66682740805663,
-0.955356943224252, 1.09396798448412, -2.63620653885452,
0.190270563436841,
2.77638842095489, -0.0914977922901252, -0.484087722062158,
0.674992784754569,
1.02571108118502, 2.78789154912298, -0.146882388586427,
-1.71507089246001,
-1.87886026272455, 6.61540228778138, 7.46818822627362,
4.80777628045963,
6.35487269602107, 4.70026626314108, 3.44366671298125,
2.92460648354883,
5.07053866161192, 7.2164343710271, 6.93292242981006, 7.84238243682145,
7.4321237311656, 9.59692827237335, 8.3454086671306, 6.574251622581,
6.93340304175759), y = c(-0.189309482569001, 1.67057595730283,
-0.995542605143325, 2.31599069771684, 1.79876139786291,
0.165886909346058,
2.70740725397259, 1.70535678189514, -0.819087329147786,
0.967935667739331,
-2.53860079551206, -1.60932884056828, -1.42050583991613,
-2.36883245674979,
0.191848867151458, -1.58255618338079, 1.98324724741419,
3.0095048680572,
1.97159273200079, 2.26459561200295, 0.4461804374566, 1.87939977307282,
1.98510457359889, -0.103495422088799, -1.32050185858493,
0.584580736435273,
-2.97562362406436, 0.10620417814, -2.0843758994948,
-1.1492729389287,
-2.13797391772643, -4.45916649729404), z = c(-1.44428170702261,
-1.45742688370091, -1.70267889327056, -1.93637881287001,
-3.4452409532781,
-3.02436538816822, 0.114790290814684, -2.10208878117278,
2.07425243689128,
1.26652602551291, 1.39914827137784, -0.345006925422662,
0.596828021941431,
3.351773622867, 2.68408561840144, 3.97006405709929, 0.82767367646934,
-0.662142231346811, 1.68344957582882, 2.92819854377685,
0.386683699222387,
-0.220305098209874, 2.37510769001993, -1.51041233970289,
-0.707073219742548,
-1.24585080403725, -1.63914669343685, 0.683153891726357,
-1.26623658129696,
1.95073173465968, -2.94804638502708, -0.635785458903106)), .Names =
c("x",
"y", "z"), class = "data.frame", row.names = c(NA, -32L))

res<-convhulln(pts, options = "FA")



In short

library(rgl)
bg3d("grey")
spheres3d(pts, radius = 0.5, col = "white")
## triangle functions generally expect triplets of points, one after another
## and hull/triangulation functions generally return arrays of indexes
## so transpose index of hull is the right order to draw triangles
triangles3d(pts[t(res$hull), ], col = "firebrick", alpha = 0.3)

(But, I wonder if you mean to find the convex hull based on the outer shell
of those spheres? )

Cheers, Mike.





Dear Mike,
Thanks a lot, this is spot on.
Yep, if possible I would even prefer to have the convex hull based on
the outer shell of the spheres, but I wonder if that is easy to
achieve with a few lines of code.
Any ideas would be welcome.


The convex hull of a set of spheres isn't a polyhedron (parts of the 
spheres will appear in it, and it will have curved edges).  Shapes like 
that are hard to draw in rgl.


Duncan Murdoch

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


Re: [R] lm() silently drops NAs

2016-07-26 Thread Hadley Wickham
On Tue, Jul 26, 2016 at 3:24 AM, Martin Maechler
 wrote:
> I have been asked (in private)

Martin was very polite to not share my name, but it was me :)

> > Hi Martin,
>
> y <- c(1, 2, 3, NA, 4)
> x <- c(1, 2, 2, 1, 1)
>
> t.test(y ~ x)
> lm(y ~ x)
>
> > Normally, most R functions follow the principle that
> > "missings should never silently go missing". Do you have
> > any background on why these functions (and most model/test
> > function in stats, I presume) silently drop missing values?
>
> And I think, the issue and an answer are important enough to be
> public, hence this posting to R-help :
>
> First note that in some sense it is not true that lm(y ~ x) silently drops
> NAs: Everybody who is taught about lm() is taught to look at
>summary( fm )  where  fm <- lm(y ~ x)

Good point - unfortunately the message was a bit subtle for me, and
don't remember being taught to look for it :(

> and that (for the above case)  "says"
>
>  ' (1 observation deleted due to missingness) '
>
> and so is not entirely silent.
>
>
> This goes all back to the idea of having an 'na.action' argument
> which may be a function (a very good idea, "functional
> programming" in a double sense!)... which Chambers et al
> introduced in The White Book (*1) and which I think to remember
> was quite a revolutionary idea; at least I had liked that very much
> once I understood the beauty of passing functions as arguments
> to other functions.
> One problem already back then has been that we already had the
> ---much more primitive but often sufficient--- standard of an
> 'na.rm = FALSE' (i.e. default FALSE) argument.
>
> This has been tought in all good classes/course about statistical
> modeling with S and R ever since ... I had hoped 
> (but it seems I was too optimistic, .. or many students have too
>  quickly forgotten what they were taught ..)
> Notably the white book itself, and the MASS (*2) book do teach
> this.. though possibly not loudly enough.
>
> Two more decisions about this were made back then, as well:
>
>   1) The default for na.action to be na.omit  (==> "silently dropping")
>
>   2) na.action being governed by  options(na.action = ..)
>
> '1)' may have been mostly "historical": I think it had been the behavior of
> other "main stream" statistical packages back then (and now?) *and*
> possibly more importantly, notably with the later (than white book = "S3")
> advent of na.replace, you did want to keep the missing in your
> data frame, for later analysis; e.g. drawing (-> "gaps" in
> plots) so the NA *were* carried along and would not be
> forgotten, something very important in most case.s.
>
> and '2)' is something I personally no longer like very
> much, as it is "killing" the functional paradigm.
> OTOH, it has to be said in favor of that "session wide" / "global" setting
>   options(na.action = *)
> that indeed it depends on the specific data analysis, or even
> the specific *phase* of a data analysis, *what* behavior of NA
> treatment is desired and at the time it was thought smart
> that all methods (also functions "deep down" called by
> user-called functtions) would automatically use the "currently
> desired" NA handling.
>
> There have been recommendations (I don't know exactly where and
> by whom) to always set
>
>options(na.action = na.fail)
>
> in your global .First() or nowadays rather your  Rprofile, and
> I assume that some of the CRAN packages and some of the "teaching
> setups" would do that (and if you do that, the lm() and t.test()
> calls above give an error).

I think that's a bit too strict for me, so I wrote my own:

na.warn <- function(object, ...) {
  missing <- complete.cases(object)
  if (any(missing)) {
warning("Dropping ", sum(missing), " rows with missing values",
call. = FALSE)
  }

  na.exclude(object, ...)
}

That gives me the behaviour I want:

options(na.action = na.warn)

y <- c(1, 2, 3, NA, 4)
x <- c(1, 2, 2, 1, 1)
mod <- lm(y ~ x)
#> Warning: Dropping 4 rows with missing values

predict(mod)
#>   1   2   3   4   5
#> 2.5 2.5 2.5  NA 2.5
resid(mod)
#>12345
#> -1.5 -0.5  0.5   NA  1.5

To me, this would be the most sensible default behaviour, but I
realise it's too late to change without breaking many existing
expectations.

On a related note, I've never really understood why it's called
na.exclude - from my perspective it causes the _inclusion_ of missing
values in the predictions/residuals.

Thanks for the (as always!) informative response, Martin.

Hadley

-- 
http://hadley.nz

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Ocr

2016-07-26 Thread Shane Carey
Hi,

Has anyone ever done any ocr in R?? I have some scanned images that I would
like to convert to text!!
Thanks


-- 
Le gach dea ghui,
Shane

[[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] Date Time in R

2016-07-26 Thread Shivi Bhatia
Thank you for all your tips. Will keep these checked.

Have a great day

On Wed, Jul 27, 2016 at 1:26 AM, William Dunlap  wrote:

> Your original mail said
>Example of date - 05-30-16
>
>To change this i have used eir$date<- as.Date(eir$date, "%m-%d-%y")
>
> but by showing us the actual code I see you reversed the m and d and
> capitalized the Y in your first attempt, causing NA's since your data was
> not in that format.
>
> The big mistake was overwriting the raw data with this mistakenly
> processed data so subsequent attempts at processing it failed.
>
> I recommend never overwriting the raw data - read the data into a
> data.frame called, say, 'raw' and make a new data.frame called, say,
> 'cleaned' with all the transformations based on the raw data.  Iterate the
> cleaning step until you have it right but don't alter the raw data.  Use
> functions like head(), str(), plot(), and summary() to see if things look
> basically ok.   The transform() function may help with that.  E.g.,
>
> raw <- read.table(text="date\n05-30-16\n06-01-16\n06-27-16",
> header=TRUE)
> str(raw)
> #'data.frame':   3 obs. of  1 variable:
> #$ date: Factor w/ 3 levels "05-30-16","06-01-16",..: 1 2 3
> cleaned <- transform(raw, date=as.Date(date, format="%d-%m-%Y"))
> head(cleaned)
> #date
> #1   
> #2 0016-01-06
> #3   
> cleaned <- transform(raw, date=as.Date(date, format="%d-%m-%y"))
> head(cleaned)
> #date
> #1   
> #2 2016-01-06
> #3   
> cleaned <- transform(raw, date=as.Date(date, format="%m-%d-%y"))
> head(cleaned)
> #date
> #1 2016-05-30
> #2 2016-06-01
> #3 2016-06-27
> That last one looks ok, so move on to your next tranformation step.
>
>
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Tue, Jul 26, 2016 at 9:59 AM, Shivi Bhatia 
> wrote:
>
>> These are some of the codes will i have
>> eir$date<- as.Date(eir$date, "%d-%m-%Y")
>> class(eir$date)
>> eir$week<- (eir$date)
>> eir$week<- weekdays(as.Date(eir$week))
>> eir$week<- as.factor(eir$week)
>>
>> On Tue, Jul 26, 2016 at 10:24 PM, Shivi Bhatia 
>> wrote:
>>
>>> Hi Bill,
>>>
>>> I have mentioned the transformation all on the email above.
>>>
>>> Regards, Shivi
>>>
>>> On Tue, Jul 26, 2016 at 10:19 PM, William Dunlap 
>>> wrote:
>>>
 Can you show us what transformations you tried when
 you saw the column called 'date' was a factor?

 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com

 On Tue, Jul 26, 2016 at 9:33 AM, Shivi Bhatia 
 wrote:

> Thanks Tom for the recommendation. This is now working.
>
> Apologies if this sounds like a juvenile but i am not very good with
> dates
> in R. What i initially did when i saw date as factor and then tried
> converting with lot many transformation that is where it went bad.
>
> But thanks to all this is really what i wanted.
>
> On Tue, Jul 26, 2016 at 9:58 PM, Tom Wright  wrote:
>
> > So this looks correct so far.
> >
> >
> >
> > # convert strings (or factors) to a date object
> >
> > a1$date <- as.Date(a1$date, “%m-%d-%y”)
> >
> >
> >
> > # Note the date object is now displayed in the format %Y-%m-%d by
> default
> >
> > # so no need for the mdy() or ymd() function
> >
> >
> >
> > # extract the weekdays as number
> >
> > weekdays <- wday(a1$date)
> >
> >
> >
> > # note can’t have spaces in variable names
> >
> > week_names <- wday(a1$date, label=TRUE)
> >
> >
> >
> >
> >
> > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
> > *Sent:* July 26, 2016 12:16 PM
> > *To:* Tom Wright 
> > *Cc:* David L Carlson ; r-help <
> r-help@r-project.org>
>
> >
> > *Subject:* Re: [R] Date Time in R
> >
> >
> >
> > Hello Tom,
> >
> >
> >
> > Please find the details: (i have changed name from eir to a1, rest
> all is
> > same)
> >
> >
> >
> > str(a1$date)
> >
> >  Factor w/ 32 levels "05-30-16","05-31-16",..: 1 1 1
> >
> >
> >
> > head(a1$date)
> >
> > 05-30-16 05-30-16 05-30-16 05-30-16 05-30-16 05-30-16
> >
> > 32 Levels: 05-30-16 05-31-16 06-01-16 06-02-16 06-03-16 06-04-16
> 06-05-16
> > 06-06-16 06-07-16 06-08-16
> >
> >
> >
> > Thanks again!!!
> >
> >
> >
> > On Tue, Jul 26, 2016 at 9:38 PM, Tom Wright 
> wrote:
> >
> > Hi again Shiva,
> > I think what we need to see is the output from:
> >
> > str(eid$date)
> >
> > and perhaps
> > head(eid$date)
> >
> > If you can send this information before doing any 

Re: [R] Date Time in R

2016-07-26 Thread William Dunlap via R-help
Your original mail said
   Example of date - 05-30-16

   To change this i have used eir$date<- as.Date(eir$date, "%m-%d-%y")

but by showing us the actual code I see you reversed the m and d and
capitalized the Y in your first attempt, causing NA's since your data was
not in that format.

The big mistake was overwriting the raw data with this mistakenly processed
data so subsequent attempts at processing it failed.

I recommend never overwriting the raw data - read the data into a
data.frame called, say, 'raw' and make a new data.frame called, say,
'cleaned' with all the transformations based on the raw data.  Iterate the
cleaning step until you have it right but don't alter the raw data.  Use
functions like head(), str(), plot(), and summary() to see if things look
basically ok.   The transform() function may help with that.  E.g.,

raw <- read.table(text="date\n05-30-16\n06-01-16\n06-27-16",
header=TRUE)
str(raw)
#'data.frame':   3 obs. of  1 variable:
#$ date: Factor w/ 3 levels "05-30-16","06-01-16",..: 1 2 3
cleaned <- transform(raw, date=as.Date(date, format="%d-%m-%Y"))
head(cleaned)
#date
#1   
#2 0016-01-06
#3   
cleaned <- transform(raw, date=as.Date(date, format="%d-%m-%y"))
head(cleaned)
#date
#1   
#2 2016-01-06
#3   
cleaned <- transform(raw, date=as.Date(date, format="%m-%d-%y"))
head(cleaned)
#date
#1 2016-05-30
#2 2016-06-01
#3 2016-06-27
That last one looks ok, so move on to your next tranformation step.




Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Jul 26, 2016 at 9:59 AM, Shivi Bhatia  wrote:

> These are some of the codes will i have
> eir$date<- as.Date(eir$date, "%d-%m-%Y")
> class(eir$date)
> eir$week<- (eir$date)
> eir$week<- weekdays(as.Date(eir$week))
> eir$week<- as.factor(eir$week)
>
> On Tue, Jul 26, 2016 at 10:24 PM, Shivi Bhatia 
> wrote:
>
>> Hi Bill,
>>
>> I have mentioned the transformation all on the email above.
>>
>> Regards, Shivi
>>
>> On Tue, Jul 26, 2016 at 10:19 PM, William Dunlap 
>> wrote:
>>
>>> Can you show us what transformations you tried when
>>> you saw the column called 'date' was a factor?
>>>
>>> Bill Dunlap
>>> TIBCO Software
>>> wdunlap tibco.com
>>>
>>> On Tue, Jul 26, 2016 at 9:33 AM, Shivi Bhatia 
>>> wrote:
>>>
 Thanks Tom for the recommendation. This is now working.

 Apologies if this sounds like a juvenile but i am not very good with
 dates
 in R. What i initially did when i saw date as factor and then tried
 converting with lot many transformation that is where it went bad.

 But thanks to all this is really what i wanted.

 On Tue, Jul 26, 2016 at 9:58 PM, Tom Wright  wrote:

 > So this looks correct so far.
 >
 >
 >
 > # convert strings (or factors) to a date object
 >
 > a1$date <- as.Date(a1$date, “%m-%d-%y”)
 >
 >
 >
 > # Note the date object is now displayed in the format %Y-%m-%d by
 default
 >
 > # so no need for the mdy() or ymd() function
 >
 >
 >
 > # extract the weekdays as number
 >
 > weekdays <- wday(a1$date)
 >
 >
 >
 > # note can’t have spaces in variable names
 >
 > week_names <- wday(a1$date, label=TRUE)
 >
 >
 >
 >
 >
 > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
 > *Sent:* July 26, 2016 12:16 PM
 > *To:* Tom Wright 
 > *Cc:* David L Carlson ; r-help <
 r-help@r-project.org>

 >
 > *Subject:* Re: [R] Date Time in R
 >
 >
 >
 > Hello Tom,
 >
 >
 >
 > Please find the details: (i have changed name from eir to a1, rest
 all is
 > same)
 >
 >
 >
 > str(a1$date)
 >
 >  Factor w/ 32 levels "05-30-16","05-31-16",..: 1 1 1
 >
 >
 >
 > head(a1$date)
 >
 > 05-30-16 05-30-16 05-30-16 05-30-16 05-30-16 05-30-16
 >
 > 32 Levels: 05-30-16 05-31-16 06-01-16 06-02-16 06-03-16 06-04-16
 06-05-16
 > 06-06-16 06-07-16 06-08-16
 >
 >
 >
 > Thanks again!!!
 >
 >
 >
 > On Tue, Jul 26, 2016 at 9:38 PM, Tom Wright  wrote:
 >
 > Hi again Shiva,
 > I think what we need to see is the output from:
 >
 > str(eid$date)
 >
 > and perhaps
 > head(eid$date)
 >
 > If you can send this information before doing any processing on the
 date
 > (i.e. before the as.Date() function) we may be able to help.
 >
 >
 >
 > -Original Message-
 > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi
 > Bhatia
 > Sent: July 26, 2016 11:46 AM
 > To: David L Carlson 
 > Cc: r-help 
 > 

Re: [R] R3.3.1 - Windows10 OS - Overriding default Legend title with user specified title

2016-07-26 Thread Tom Wright
A quick google for "ggplot2 change legend text" turns up several hits.
This stackexchange question has several recipes.
http://stats.stackexchange.com/questions/5007/how-can-i-change-the-title-o
f-a-legend-in-ggplot2

including the correct use of the labs() function;
labs(aesthetic='BrandValue in Billions')

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
udhayakanth reddy
Sent: July 26, 2016 12:02 PM
To: r-help@r-project.org
Subject: [R] R3.3.1 - Windows10 OS - Overriding default Legend title with
user specified title

Team - Could you please do the needful.

I have a below code using ggplot2() package. I am trying to plot between
the variables - 'Company Advertising' and 'Brand Revenue' of my data frame
'htmltable' , when the another variable 'Industry' is 'Luxury'; using
ggplot() function. I am using another variable of my data frame 'Brand
Value' as colour variable.

p<-
ggplot(htmltable[htmltable$Industry='Luxury',],aes(x='CompanyAdvertising',
y='BrandRevenue')

q <- p+geom_point(aes(color='BrandValue',size='BrandValue') +
geom_text(label='Brand')

r <- q+xlab("Company Advertisiment in Billions")+ylab("Brand Revenue in
Billions") +ggtitle("Luxury")

r+theme(plot.title=element_text(size=10,face='bold'),legend.key=element_
r+rect(fill='light
blue'))

Here, I want to change my legend title from "BrandValue" to "BrandValue in
Billions". Please suggest.

I tried using labs parameter in the below statement. But it is resulting
in 2 legends.

r <- q+xlab("Company Advertisiment in Billions")+ylab("Brand Revenue in
Billions") +ggtitle("Luxury")+labs(colour="BrandValue in Billions")


Thanks,

Udhay

[[alternative HTML version deleted]]

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

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


Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
These are some of the codes will i have
eir$date<- as.Date(eir$date, "%d-%m-%Y")
class(eir$date)
eir$week<- (eir$date)
eir$week<- weekdays(as.Date(eir$week))
eir$week<- as.factor(eir$week)

On Tue, Jul 26, 2016 at 10:24 PM, Shivi Bhatia  wrote:

> Hi Bill,
>
> I have mentioned the transformation all on the email above.
>
> Regards, Shivi
>
> On Tue, Jul 26, 2016 at 10:19 PM, William Dunlap 
> wrote:
>
>> Can you show us what transformations you tried when
>> you saw the column called 'date' was a factor?
>>
>> Bill Dunlap
>> TIBCO Software
>> wdunlap tibco.com
>>
>> On Tue, Jul 26, 2016 at 9:33 AM, Shivi Bhatia 
>> wrote:
>>
>>> Thanks Tom for the recommendation. This is now working.
>>>
>>> Apologies if this sounds like a juvenile but i am not very good with
>>> dates
>>> in R. What i initially did when i saw date as factor and then tried
>>> converting with lot many transformation that is where it went bad.
>>>
>>> But thanks to all this is really what i wanted.
>>>
>>> On Tue, Jul 26, 2016 at 9:58 PM, Tom Wright  wrote:
>>>
>>> > So this looks correct so far.
>>> >
>>> >
>>> >
>>> > # convert strings (or factors) to a date object
>>> >
>>> > a1$date <- as.Date(a1$date, “%m-%d-%y”)
>>> >
>>> >
>>> >
>>> > # Note the date object is now displayed in the format %Y-%m-%d by
>>> default
>>> >
>>> > # so no need for the mdy() or ymd() function
>>> >
>>> >
>>> >
>>> > # extract the weekdays as number
>>> >
>>> > weekdays <- wday(a1$date)
>>> >
>>> >
>>> >
>>> > # note can’t have spaces in variable names
>>> >
>>> > week_names <- wday(a1$date, label=TRUE)
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
>>> > *Sent:* July 26, 2016 12:16 PM
>>> > *To:* Tom Wright 
>>> > *Cc:* David L Carlson ; r-help <
>>> r-help@r-project.org>
>>>
>>> >
>>> > *Subject:* Re: [R] Date Time in R
>>> >
>>> >
>>> >
>>> > Hello Tom,
>>> >
>>> >
>>> >
>>> > Please find the details: (i have changed name from eir to a1, rest all
>>> is
>>> > same)
>>> >
>>> >
>>> >
>>> > str(a1$date)
>>> >
>>> >  Factor w/ 32 levels "05-30-16","05-31-16",..: 1 1 1
>>> >
>>> >
>>> >
>>> > head(a1$date)
>>> >
>>> > 05-30-16 05-30-16 05-30-16 05-30-16 05-30-16 05-30-16
>>> >
>>> > 32 Levels: 05-30-16 05-31-16 06-01-16 06-02-16 06-03-16 06-04-16
>>> 06-05-16
>>> > 06-06-16 06-07-16 06-08-16
>>> >
>>> >
>>> >
>>> > Thanks again!!!
>>> >
>>> >
>>> >
>>> > On Tue, Jul 26, 2016 at 9:38 PM, Tom Wright  wrote:
>>> >
>>> > Hi again Shiva,
>>> > I think what we need to see is the output from:
>>> >
>>> > str(eid$date)
>>> >
>>> > and perhaps
>>> > head(eid$date)
>>> >
>>> > If you can send this information before doing any processing on the
>>> date
>>> > (i.e. before the as.Date() function) we may be able to help.
>>> >
>>> >
>>> >
>>> > -Original Message-
>>> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi
>>> > Bhatia
>>> > Sent: July 26, 2016 11:46 AM
>>> > To: David L Carlson 
>>> > Cc: r-help 
>>> > Subject: Re: [R] Date Time in R
>>> >
>>> > Hi David please see the code and some reproducible data:
>>> > eir$date<- as.Date(eir$date,format = "%m-%d-%y")  then i had used the
>>> > lubridate library to help with the dates:
>>> > install.packages("lubridate")
>>> > library(lubridate)
>>> > eir$date <- mdy(eir$date)
>>> > weekdays <- wdy(eir$date)
>>> > week names <- wdy(eir$date, label = TRUE)
>>> >
>>> > This the output from the file:
>>> >
>>> > structure(list(date = structure(c(NA_real_, NA_real_, NA_real_), class
>>> =
>>> > "Date"),
>>> >
>>> > month = structure(c(2L, 2L, 2L), .Label = c("Jun","May"), class =
>>> > "factor"),
>>> >
>>> > day = c(30L, 30L, 30L),
>>> >
>>> > weekday = structure(c(2L,2L, 2L), .Label = c("Fri", "Mon", "Sat",
>>> "Sun",
>>> > "Thu", "Tue","Wed"), class = "factor"),
>>> >
>>> > survey_rating = c(3L, 2L, 3L), query_status = c("Yes", "Don't
>>> know","No"),
>>> >
>>> >  a = c("05-30-16", "05-30-16", "05-30-16")), .Names = c("date","month",
>>> > "day", "weekday", "survey_rating"), row.names = c(NA, 3L), class =
>>> > "data.frame")
>>> >
>>> > There are several other variables that i have removed which are not
>>> > relevant
>>> > in this context.
>>> >
>>> > On Tue, Jul 26, 2016 at 8:55 PM, David L Carlson 
>>> > wrote:
>>> >
>>> > > Show us the output, don’t just tell us what you are seeing. If the
>>> > > dates are correct in the csv file, show us the structure of the data
>>> > > frame you created with read.csv() and show the command(s) you used to
>>> > > convert the character data to date format. The solution is likely to
>>> > > be simple if you will cut/paste the R console and not just describe
>>> what
>>> > > is happening.
>>> > >
>>> > >
>>> > >
>>> > > David C
>>> > >
>>> > >
>>> > >
>>> >
>>> > > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
>>> > > 

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Hi Bill,

I have mentioned the transformation all on the email above.

Regards, Shivi

On Tue, Jul 26, 2016 at 10:19 PM, William Dunlap  wrote:

> Can you show us what transformations you tried when
> you saw the column called 'date' was a factor?
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Tue, Jul 26, 2016 at 9:33 AM, Shivi Bhatia 
> wrote:
>
>> Thanks Tom for the recommendation. This is now working.
>>
>> Apologies if this sounds like a juvenile but i am not very good with dates
>> in R. What i initially did when i saw date as factor and then tried
>> converting with lot many transformation that is where it went bad.
>>
>> But thanks to all this is really what i wanted.
>>
>> On Tue, Jul 26, 2016 at 9:58 PM, Tom Wright  wrote:
>>
>> > So this looks correct so far.
>> >
>> >
>> >
>> > # convert strings (or factors) to a date object
>> >
>> > a1$date <- as.Date(a1$date, “%m-%d-%y”)
>> >
>> >
>> >
>> > # Note the date object is now displayed in the format %Y-%m-%d by
>> default
>> >
>> > # so no need for the mdy() or ymd() function
>> >
>> >
>> >
>> > # extract the weekdays as number
>> >
>> > weekdays <- wday(a1$date)
>> >
>> >
>> >
>> > # note can’t have spaces in variable names
>> >
>> > week_names <- wday(a1$date, label=TRUE)
>> >
>> >
>> >
>> >
>> >
>> > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
>> > *Sent:* July 26, 2016 12:16 PM
>> > *To:* Tom Wright 
>> > *Cc:* David L Carlson ; r-help > >
>>
>> >
>> > *Subject:* Re: [R] Date Time in R
>> >
>> >
>> >
>> > Hello Tom,
>> >
>> >
>> >
>> > Please find the details: (i have changed name from eir to a1, rest all
>> is
>> > same)
>> >
>> >
>> >
>> > str(a1$date)
>> >
>> >  Factor w/ 32 levels "05-30-16","05-31-16",..: 1 1 1
>> >
>> >
>> >
>> > head(a1$date)
>> >
>> > 05-30-16 05-30-16 05-30-16 05-30-16 05-30-16 05-30-16
>> >
>> > 32 Levels: 05-30-16 05-31-16 06-01-16 06-02-16 06-03-16 06-04-16
>> 06-05-16
>> > 06-06-16 06-07-16 06-08-16
>> >
>> >
>> >
>> > Thanks again!!!
>> >
>> >
>> >
>> > On Tue, Jul 26, 2016 at 9:38 PM, Tom Wright  wrote:
>> >
>> > Hi again Shiva,
>> > I think what we need to see is the output from:
>> >
>> > str(eid$date)
>> >
>> > and perhaps
>> > head(eid$date)
>> >
>> > If you can send this information before doing any processing on the date
>> > (i.e. before the as.Date() function) we may be able to help.
>> >
>> >
>> >
>> > -Original Message-
>> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi
>> > Bhatia
>> > Sent: July 26, 2016 11:46 AM
>> > To: David L Carlson 
>> > Cc: r-help 
>> > Subject: Re: [R] Date Time in R
>> >
>> > Hi David please see the code and some reproducible data:
>> > eir$date<- as.Date(eir$date,format = "%m-%d-%y")  then i had used the
>> > lubridate library to help with the dates:
>> > install.packages("lubridate")
>> > library(lubridate)
>> > eir$date <- mdy(eir$date)
>> > weekdays <- wdy(eir$date)
>> > week names <- wdy(eir$date, label = TRUE)
>> >
>> > This the output from the file:
>> >
>> > structure(list(date = structure(c(NA_real_, NA_real_, NA_real_), class =
>> > "Date"),
>> >
>> > month = structure(c(2L, 2L, 2L), .Label = c("Jun","May"), class =
>> > "factor"),
>> >
>> > day = c(30L, 30L, 30L),
>> >
>> > weekday = structure(c(2L,2L, 2L), .Label = c("Fri", "Mon", "Sat", "Sun",
>> > "Thu", "Tue","Wed"), class = "factor"),
>> >
>> > survey_rating = c(3L, 2L, 3L), query_status = c("Yes", "Don't
>> know","No"),
>> >
>> >  a = c("05-30-16", "05-30-16", "05-30-16")), .Names = c("date","month",
>> > "day", "weekday", "survey_rating"), row.names = c(NA, 3L), class =
>> > "data.frame")
>> >
>> > There are several other variables that i have removed which are not
>> > relevant
>> > in this context.
>> >
>> > On Tue, Jul 26, 2016 at 8:55 PM, David L Carlson 
>> > wrote:
>> >
>> > > Show us the output, don’t just tell us what you are seeing. If the
>> > > dates are correct in the csv file, show us the structure of the data
>> > > frame you created with read.csv() and show the command(s) you used to
>> > > convert the character data to date format. The solution is likely to
>> > > be simple if you will cut/paste the R console and not just describe
>> what
>> > > is happening.
>> > >
>> > >
>> > >
>> > > David C
>> > >
>> > >
>> > >
>> >
>> > > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
>> > > *Sent:* Tuesday, July 26, 2016 10:08 AM
>> > > *To:* David L Carlson
>> > >
>> > > *Subject:* Re: [R] Date Time in R
>> >
>> > >
>> > >
>> > >
>> > > Hi David,
>> > >
>> > > This gives the results accurately. The first line shows all the
>> > > variable names and the rest shows all values stored for each of the
>> > > variable. Here date is appearing as correct.
>> > >
>> > >
>> > >
>> > > Thanks, Shivi
>> > >
>> > >
>> > >
>> > > On Tue, Jul 26, 2016 at 7:39 PM, 

Re: [R] Date Time in R

2016-07-26 Thread William Dunlap via R-help
Can you show us what transformations you tried when
you saw the column called 'date' was a factor?

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Jul 26, 2016 at 9:33 AM, Shivi Bhatia  wrote:

> Thanks Tom for the recommendation. This is now working.
>
> Apologies if this sounds like a juvenile but i am not very good with dates
> in R. What i initially did when i saw date as factor and then tried
> converting with lot many transformation that is where it went bad.
>
> But thanks to all this is really what i wanted.
>
> On Tue, Jul 26, 2016 at 9:58 PM, Tom Wright  wrote:
>
> > So this looks correct so far.
> >
> >
> >
> > # convert strings (or factors) to a date object
> >
> > a1$date <- as.Date(a1$date, “%m-%d-%y”)
> >
> >
> >
> > # Note the date object is now displayed in the format %Y-%m-%d by default
> >
> > # so no need for the mdy() or ymd() function
> >
> >
> >
> > # extract the weekdays as number
> >
> > weekdays <- wday(a1$date)
> >
> >
> >
> > # note can’t have spaces in variable names
> >
> > week_names <- wday(a1$date, label=TRUE)
> >
> >
> >
> >
> >
> > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
> > *Sent:* July 26, 2016 12:16 PM
> > *To:* Tom Wright 
> > *Cc:* David L Carlson ; r-help 
> >
> > *Subject:* Re: [R] Date Time in R
> >
> >
> >
> > Hello Tom,
> >
> >
> >
> > Please find the details: (i have changed name from eir to a1, rest all is
> > same)
> >
> >
> >
> > str(a1$date)
> >
> >  Factor w/ 32 levels "05-30-16","05-31-16",..: 1 1 1
> >
> >
> >
> > head(a1$date)
> >
> > 05-30-16 05-30-16 05-30-16 05-30-16 05-30-16 05-30-16
> >
> > 32 Levels: 05-30-16 05-31-16 06-01-16 06-02-16 06-03-16 06-04-16 06-05-16
> > 06-06-16 06-07-16 06-08-16
> >
> >
> >
> > Thanks again!!!
> >
> >
> >
> > On Tue, Jul 26, 2016 at 9:38 PM, Tom Wright  wrote:
> >
> > Hi again Shiva,
> > I think what we need to see is the output from:
> >
> > str(eid$date)
> >
> > and perhaps
> > head(eid$date)
> >
> > If you can send this information before doing any processing on the date
> > (i.e. before the as.Date() function) we may be able to help.
> >
> >
> >
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi
> > Bhatia
> > Sent: July 26, 2016 11:46 AM
> > To: David L Carlson 
> > Cc: r-help 
> > Subject: Re: [R] Date Time in R
> >
> > Hi David please see the code and some reproducible data:
> > eir$date<- as.Date(eir$date,format = "%m-%d-%y")  then i had used the
> > lubridate library to help with the dates:
> > install.packages("lubridate")
> > library(lubridate)
> > eir$date <- mdy(eir$date)
> > weekdays <- wdy(eir$date)
> > week names <- wdy(eir$date, label = TRUE)
> >
> > This the output from the file:
> >
> > structure(list(date = structure(c(NA_real_, NA_real_, NA_real_), class =
> > "Date"),
> >
> > month = structure(c(2L, 2L, 2L), .Label = c("Jun","May"), class =
> > "factor"),
> >
> > day = c(30L, 30L, 30L),
> >
> > weekday = structure(c(2L,2L, 2L), .Label = c("Fri", "Mon", "Sat", "Sun",
> > "Thu", "Tue","Wed"), class = "factor"),
> >
> > survey_rating = c(3L, 2L, 3L), query_status = c("Yes", "Don't
> know","No"),
> >
> >  a = c("05-30-16", "05-30-16", "05-30-16")), .Names = c("date","month",
> > "day", "weekday", "survey_rating"), row.names = c(NA, 3L), class =
> > "data.frame")
> >
> > There are several other variables that i have removed which are not
> > relevant
> > in this context.
> >
> > On Tue, Jul 26, 2016 at 8:55 PM, David L Carlson 
> > wrote:
> >
> > > Show us the output, don’t just tell us what you are seeing. If the
> > > dates are correct in the csv file, show us the structure of the data
> > > frame you created with read.csv() and show the command(s) you used to
> > > convert the character data to date format. The solution is likely to
> > > be simple if you will cut/paste the R console and not just describe
> what
> > > is happening.
> > >
> > >
> > >
> > > David C
> > >
> > >
> > >
> >
> > > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
> > > *Sent:* Tuesday, July 26, 2016 10:08 AM
> > > *To:* David L Carlson
> > >
> > > *Subject:* Re: [R] Date Time in R
> >
> > >
> > >
> > >
> > > Hi David,
> > >
> > > This gives the results accurately. The first line shows all the
> > > variable names and the rest shows all values stored for each of the
> > > variable. Here date is appearing as correct.
> > >
> > >
> > >
> > > Thanks, Shivi
> > >
> > >
> > >
> > > On Tue, Jul 26, 2016 at 7:39 PM, David L Carlson 
> > > wrote:
> > >
> > > What does this produce?
> > >
> > > > readLines("YourCSVfilename.csv", n=5)
> > >
> > > If the data are in Excel, the date format used in .csv files is not
> > > always in the same as the format used when viewing dates in the
> > > spreadsheet.
> > >
> > > -
> > > David L 

[R] R3.3.1 - Windows10 OS - Overriding default Legend title with user specified title

2016-07-26 Thread udhayakanth reddy
Team - Could you please do the needful.

I have a below code using ggplot2() package. I am trying to plot between
the variables - 'Company Advertising' and 'Brand Revenue' of my data frame
'htmltable' , when the another variable 'Industry' is 'Luxury'; using
ggplot() function. I am using another variable of my data frame 'Brand
Value' as colour variable.

p<- 
ggplot(htmltable[htmltable$Industry='Luxury',],aes(x='CompanyAdvertising',y='BrandRevenue')

q <- p+geom_point(aes(color='BrandValue',size='BrandValue') +
geom_text(label='Brand')

r <- q+xlab("Company Advertisiment in Billions")+ylab("Brand Revenue
in Billions") +ggtitle("Luxury")

r+theme(plot.title=element_text(size=10,face='bold'),legend.key=element_rect(fill='light
blue'))

Here, I want to change my legend title from "BrandValue" to
"BrandValue in Billions". Please suggest.

I tried using labs parameter in the below statement. But it is
resulting in 2 legends.

r <- q+xlab("Company Advertisiment in Billions")+ylab("Brand Revenue
in Billions") +ggtitle("Luxury")+labs(colour="BrandValue in Billions")


Thanks,

Udhay

[[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] Date Time in R

2016-07-26 Thread Shivi Bhatia
Thanks Tom for the recommendation. This is now working.

Apologies if this sounds like a juvenile but i am not very good with dates
in R. What i initially did when i saw date as factor and then tried
converting with lot many transformation that is where it went bad.

But thanks to all this is really what i wanted.

On Tue, Jul 26, 2016 at 9:58 PM, Tom Wright  wrote:

> So this looks correct so far.
>
>
>
> # convert strings (or factors) to a date object
>
> a1$date <- as.Date(a1$date, “%m-%d-%y”)
>
>
>
> # Note the date object is now displayed in the format %Y-%m-%d by default
>
> # so no need for the mdy() or ymd() function
>
>
>
> # extract the weekdays as number
>
> weekdays <- wday(a1$date)
>
>
>
> # note can’t have spaces in variable names
>
> week_names <- wday(a1$date, label=TRUE)
>
>
>
>
>
> *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
> *Sent:* July 26, 2016 12:16 PM
> *To:* Tom Wright 
> *Cc:* David L Carlson ; r-help 
>
> *Subject:* Re: [R] Date Time in R
>
>
>
> Hello Tom,
>
>
>
> Please find the details: (i have changed name from eir to a1, rest all is
> same)
>
>
>
> str(a1$date)
>
>  Factor w/ 32 levels "05-30-16","05-31-16",..: 1 1 1
>
>
>
> head(a1$date)
>
> 05-30-16 05-30-16 05-30-16 05-30-16 05-30-16 05-30-16
>
> 32 Levels: 05-30-16 05-31-16 06-01-16 06-02-16 06-03-16 06-04-16 06-05-16
> 06-06-16 06-07-16 06-08-16
>
>
>
> Thanks again!!!
>
>
>
> On Tue, Jul 26, 2016 at 9:38 PM, Tom Wright  wrote:
>
> Hi again Shiva,
> I think what we need to see is the output from:
>
> str(eid$date)
>
> and perhaps
> head(eid$date)
>
> If you can send this information before doing any processing on the date
> (i.e. before the as.Date() function) we may be able to help.
>
>
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi
> Bhatia
> Sent: July 26, 2016 11:46 AM
> To: David L Carlson 
> Cc: r-help 
> Subject: Re: [R] Date Time in R
>
> Hi David please see the code and some reproducible data:
> eir$date<- as.Date(eir$date,format = "%m-%d-%y")  then i had used the
> lubridate library to help with the dates:
> install.packages("lubridate")
> library(lubridate)
> eir$date <- mdy(eir$date)
> weekdays <- wdy(eir$date)
> week names <- wdy(eir$date, label = TRUE)
>
> This the output from the file:
>
> structure(list(date = structure(c(NA_real_, NA_real_, NA_real_), class =
> "Date"),
>
> month = structure(c(2L, 2L, 2L), .Label = c("Jun","May"), class =
> "factor"),
>
> day = c(30L, 30L, 30L),
>
> weekday = structure(c(2L,2L, 2L), .Label = c("Fri", "Mon", "Sat", "Sun",
> "Thu", "Tue","Wed"), class = "factor"),
>
> survey_rating = c(3L, 2L, 3L), query_status = c("Yes", "Don't know","No"),
>
>  a = c("05-30-16", "05-30-16", "05-30-16")), .Names = c("date","month",
> "day", "weekday", "survey_rating"), row.names = c(NA, 3L), class =
> "data.frame")
>
> There are several other variables that i have removed which are not
> relevant
> in this context.
>
> On Tue, Jul 26, 2016 at 8:55 PM, David L Carlson 
> wrote:
>
> > Show us the output, don’t just tell us what you are seeing. If the
> > dates are correct in the csv file, show us the structure of the data
> > frame you created with read.csv() and show the command(s) you used to
> > convert the character data to date format. The solution is likely to
> > be simple if you will cut/paste the R console and not just describe what
> > is happening.
> >
> >
> >
> > David C
> >
> >
> >
>
> > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
> > *Sent:* Tuesday, July 26, 2016 10:08 AM
> > *To:* David L Carlson
> >
> > *Subject:* Re: [R] Date Time in R
>
> >
> >
> >
> > Hi David,
> >
> > This gives the results accurately. The first line shows all the
> > variable names and the rest shows all values stored for each of the
> > variable. Here date is appearing as correct.
> >
> >
> >
> > Thanks, Shivi
> >
> >
> >
> > On Tue, Jul 26, 2016 at 7:39 PM, David L Carlson 
> > wrote:
> >
> > What does this produce?
> >
> > > readLines("YourCSVfilename.csv", n=5)
> >
> > If the data are in Excel, the date format used in .csv files is not
> > always in the same as the format used when viewing dates in the
> > spreadsheet.
> >
> > -
> > David L Carlson
> > Department of Anthropology
> > Texas A University
> > College Station, TX 77840-4352
> >
> >
> >
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi
> > Bhatia
> > Sent: Tuesday, July 26, 2016 7:42 AM
> > To: Marc Schwartz
> > Cc: R-help
> > Subject: Re: [R] Date Time in R
> >
> > Thanks Marc for the help. this really helps.
> > I think there is some issue with the data saved in csv format for this
> > variable as when i checked:
> > str(eir$date)- this results in :-
> > Date[1:5327], format: NA NA NA NA NA.
> >
> > 

Re: [R] Date Time in R

2016-07-26 Thread Tom Wright
So this looks correct so far.



# convert strings (or factors) to a date object

a1$date <- as.Date(a1$date, “%m-%d-%y”)



# Note the date object is now displayed in the format %Y-%m-%d by default

# so no need for the mdy() or ymd() function



# extract the weekdays as number

weekdays <- wday(a1$date)



# note can’t have spaces in variable names

week_names <- wday(a1$date, label=TRUE)





*From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
*Sent:* July 26, 2016 12:16 PM
*To:* Tom Wright 
*Cc:* David L Carlson ; r-help 
*Subject:* Re: [R] Date Time in R



Hello Tom,



Please find the details: (i have changed name from eir to a1, rest all is
same)



str(a1$date)

 Factor w/ 32 levels "05-30-16","05-31-16",..: 1 1 1



head(a1$date)

05-30-16 05-30-16 05-30-16 05-30-16 05-30-16 05-30-16

32 Levels: 05-30-16 05-31-16 06-01-16 06-02-16 06-03-16 06-04-16 06-05-16
06-06-16 06-07-16 06-08-16



Thanks again!!!



On Tue, Jul 26, 2016 at 9:38 PM, Tom Wright  wrote:

Hi again Shiva,
I think what we need to see is the output from:

str(eid$date)

and perhaps
head(eid$date)

If you can send this information before doing any processing on the date
(i.e. before the as.Date() function) we may be able to help.



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi Bhatia
Sent: July 26, 2016 11:46 AM
To: David L Carlson 
Cc: r-help 
Subject: Re: [R] Date Time in R

Hi David please see the code and some reproducible data:
eir$date<- as.Date(eir$date,format = "%m-%d-%y")  then i had used the
lubridate library to help with the dates:
install.packages("lubridate")
library(lubridate)
eir$date <- mdy(eir$date)
weekdays <- wdy(eir$date)
week names <- wdy(eir$date, label = TRUE)

This the output from the file:

structure(list(date = structure(c(NA_real_, NA_real_, NA_real_), class =
"Date"),

month = structure(c(2L, 2L, 2L), .Label = c("Jun","May"), class = "factor"),

day = c(30L, 30L, 30L),

weekday = structure(c(2L,2L, 2L), .Label = c("Fri", "Mon", "Sat", "Sun",
"Thu", "Tue","Wed"), class = "factor"),

survey_rating = c(3L, 2L, 3L), query_status = c("Yes", "Don't know","No"),

 a = c("05-30-16", "05-30-16", "05-30-16")), .Names = c("date","month",
"day", "weekday", "survey_rating"), row.names = c(NA, 3L), class =
"data.frame")

There are several other variables that i have removed which are not relevant
in this context.

On Tue, Jul 26, 2016 at 8:55 PM, David L Carlson  wrote:

> Show us the output, don’t just tell us what you are seeing. If the
> dates are correct in the csv file, show us the structure of the data
> frame you created with read.csv() and show the command(s) you used to
> convert the character data to date format. The solution is likely to
> be simple if you will cut/paste the R console and not just describe what
> is happening.
>
>
>
> David C
>
>
>

> *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
> *Sent:* Tuesday, July 26, 2016 10:08 AM
> *To:* David L Carlson
>
> *Subject:* Re: [R] Date Time in R

>
>
>
> Hi David,
>
> This gives the results accurately. The first line shows all the
> variable names and the rest shows all values stored for each of the
> variable. Here date is appearing as correct.
>
>
>
> Thanks, Shivi
>
>
>
> On Tue, Jul 26, 2016 at 7:39 PM, David L Carlson 
> wrote:
>
> What does this produce?
>
> > readLines("YourCSVfilename.csv", n=5)
>
> If the data are in Excel, the date format used in .csv files is not
> always in the same as the format used when viewing dates in the
> spreadsheet.
>
> -
> David L Carlson
> Department of Anthropology
> Texas A University
> College Station, TX 77840-4352
>
>
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi
> Bhatia
> Sent: Tuesday, July 26, 2016 7:42 AM
> To: Marc Schwartz
> Cc: R-help
> Subject: Re: [R] Date Time in R
>
> Thanks Marc for the help. this really helps.
> I think there is some issue with the data saved in csv format for this
> variable as when i checked:
> str(eir$date)- this results in :-
> Date[1:5327], format: NA NA NA NA NA.
>
> Thanks again.
>
> On Tue, Jul 26, 2016 at 5:58 PM, Marc Schwartz 
> wrote:
>
> > Hi,
> >
> > That eir$date might be a factor is irrelevant. There is an as.Date()
> > method for factors, which does the factor to character coercion
> internally
> > and then calls as.Date.character() on the result.
> >
> > Using the example data below:
> >
> > eir <- data.frame(date = c("05-30-16", "05-30-16", "05-30-16",
> >"05-30-16", "05-30-16", "05-30-16"))
> >
> > > str(eir)
> > 'data.frame':   6 obs. of  1 variable:
> >  $ date: Factor w/ 1 level "05-30-16": 1 1 1 1 1 1
> >
> > > eir
> >   date
> > 1 05-30-16
> > 2 05-30-16
> > 3 05-30-16
> > 4 05-30-16
> > 5 05-30-16

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Hello Tom,

Please find the details: (i have changed name from eir to a1, rest all is
same)

str(a1$date)
 Factor w/ 32 levels "05-30-16","05-31-16",..: 1 1 1

head(a1$date)
05-30-16 05-30-16 05-30-16 05-30-16 05-30-16 05-30-16
32 Levels: 05-30-16 05-31-16 06-01-16 06-02-16 06-03-16 06-04-16 06-05-16
06-06-16 06-07-16 06-08-16

Thanks again!!!

On Tue, Jul 26, 2016 at 9:38 PM, Tom Wright  wrote:

> Hi again Shiva,
> I think what we need to see is the output from:
>
> str(eid$date)
>
> and perhaps
> head(eid$date)
>
> If you can send this information before doing any processing on the date
> (i.e. before the as.Date() function) we may be able to help.
>
>
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi
> Bhatia
> Sent: July 26, 2016 11:46 AM
> To: David L Carlson 
> Cc: r-help 
> Subject: Re: [R] Date Time in R
>
> Hi David please see the code and some reproducible data:
> eir$date<- as.Date(eir$date,format = "%m-%d-%y")  then i had used the
> lubridate library to help with the dates:
> install.packages("lubridate")
> library(lubridate)
> eir$date <- mdy(eir$date)
> weekdays <- wdy(eir$date)
> week names <- wdy(eir$date, label = TRUE)
>
> This the output from the file:
>
> structure(list(date = structure(c(NA_real_, NA_real_, NA_real_), class =
> "Date"),
>
> month = structure(c(2L, 2L, 2L), .Label = c("Jun","May"), class =
> "factor"),
>
> day = c(30L, 30L, 30L),
>
> weekday = structure(c(2L,2L, 2L), .Label = c("Fri", "Mon", "Sat", "Sun",
> "Thu", "Tue","Wed"), class = "factor"),
>
> survey_rating = c(3L, 2L, 3L), query_status = c("Yes", "Don't know","No"),
>
>  a = c("05-30-16", "05-30-16", "05-30-16")), .Names = c("date","month",
> "day", "weekday", "survey_rating"), row.names = c(NA, 3L), class =
> "data.frame")
>
> There are several other variables that i have removed which are not
> relevant
> in this context.
>
> On Tue, Jul 26, 2016 at 8:55 PM, David L Carlson 
> wrote:
>
> > Show us the output, don’t just tell us what you are seeing. If the
> > dates are correct in the csv file, show us the structure of the data
> > frame you created with read.csv() and show the command(s) you used to
> > convert the character data to date format. The solution is likely to
> > be simple if you will cut/paste the R console and not just describe what
> > is happening.
> >
> >
> >
> > David C
> >
> >
> >
> > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
> > *Sent:* Tuesday, July 26, 2016 10:08 AM
> > *To:* David L Carlson
> >
> > *Subject:* Re: [R] Date Time in R
> >
> >
> >
> > Hi David,
> >
> > This gives the results accurately. The first line shows all the
> > variable names and the rest shows all values stored for each of the
> > variable. Here date is appearing as correct.
> >
> >
> >
> > Thanks, Shivi
> >
> >
> >
> > On Tue, Jul 26, 2016 at 7:39 PM, David L Carlson 
> > wrote:
> >
> > What does this produce?
> >
> > > readLines("YourCSVfilename.csv", n=5)
> >
> > If the data are in Excel, the date format used in .csv files is not
> > always in the same as the format used when viewing dates in the
> > spreadsheet.
> >
> > -
> > David L Carlson
> > Department of Anthropology
> > Texas A University
> > College Station, TX 77840-4352
> >
> >
> >
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi
> > Bhatia
> > Sent: Tuesday, July 26, 2016 7:42 AM
> > To: Marc Schwartz
> > Cc: R-help
> > Subject: Re: [R] Date Time in R
> >
> > Thanks Marc for the help. this really helps.
> > I think there is some issue with the data saved in csv format for this
> > variable as when i checked:
> > str(eir$date)- this results in :-
> > Date[1:5327], format: NA NA NA NA NA.
> >
> > Thanks again.
> >
> > On Tue, Jul 26, 2016 at 5:58 PM, Marc Schwartz 
> > wrote:
> >
> > > Hi,
> > >
> > > That eir$date might be a factor is irrelevant. There is an as.Date()
> > > method for factors, which does the factor to character coercion
> > internally
> > > and then calls as.Date.character() on the result.
> > >
> > > Using the example data below:
> > >
> > > eir <- data.frame(date = c("05-30-16", "05-30-16", "05-30-16",
> > >"05-30-16", "05-30-16", "05-30-16"))
> > >
> > > > str(eir)
> > > 'data.frame':   6 obs. of  1 variable:
> > >  $ date: Factor w/ 1 level "05-30-16": 1 1 1 1 1 1
> > >
> > > > eir
> > >   date
> > > 1 05-30-16
> > > 2 05-30-16
> > > 3 05-30-16
> > > 4 05-30-16
> > > 5 05-30-16
> > > 6 05-30-16
> > >
> > > eir$date <- as.Date(eir$date, format = "%m-%d-%y")
> > >
> > > > str(eir)
> > > 'data.frame':   6 obs. of  1 variable:
> > >  $ date: Date, format: "2016-05-30" ...
> > >
> > > > eir
> > > date
> > > 1 2016-05-30
> > > 2 2016-05-30
> > > 3 2016-05-30
> > > 4 2016-05-30
> > > 5 2016-05-30
> > > 6 2016-05-30
> > >
> > > 

Re: [R] Date Time in R

2016-07-26 Thread Hadley Wickham
I'd recommend reading up on how to create a minimal reproducible
example (e.g. http://r4ds.had.co.nz/exploratory-data-analysis.html).
It is unlikely anyone will be able to help you unless you can reliably
communicate _exactly_ what you're doing. Unlike human languages,
computer languages are extremely strict, and just one wrong character
can make a big difference.

Hadley

On Tue, Jul 26, 2016 at 10:45 AM, Shivi Bhatia  wrote:
> Hi David please see the code and some reproducible data:
> eir$date<- as.Date(eir$date,format = "%m-%d-%y")  then i had used the
> lubridate library to help with the dates:
> install.packages("lubridate")
> library(lubridate)
> eir$date <- mdy(eir$date)
> weekdays <- wdy(eir$date)
> week names <- wdy(eir$date, label = TRUE)
>
> This the output from the file:
>
> structure(list(date = structure(c(NA_real_, NA_real_, NA_real_), class =
> "Date"),
>
> month = structure(c(2L, 2L, 2L), .Label = c("Jun","May"), class = "factor"),
>
> day = c(30L, 30L, 30L),
>
> weekday = structure(c(2L,2L, 2L), .Label = c("Fri", "Mon", "Sat", "Sun",
> "Thu", "Tue","Wed"), class = "factor"),
>
> survey_rating = c(3L, 2L, 3L), query_status = c("Yes", "Don't know","No"),
>
>  a = c("05-30-16", "05-30-16", "05-30-16")), .Names = c("date","month",
> "day", "weekday", "survey_rating"), row.names = c(NA, 3L), class =
> "data.frame")
>
> There are several other variables that i have removed which are not
> relevant in this context.
>
> On Tue, Jul 26, 2016 at 8:55 PM, David L Carlson  wrote:
>
>> Show us the output, don’t just tell us what you are seeing. If the dates
>> are correct in the csv file, show us the structure of the data frame you
>> created with read.csv() and show the command(s) you used to convert the
>> character data to date format. The solution is likely to be simple if you
>> will cut/paste the R console and not just describe what is happening.
>>
>>
>>
>> David C
>>
>>
>>
>> *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
>> *Sent:* Tuesday, July 26, 2016 10:08 AM
>> *To:* David L Carlson
>>
>> *Subject:* Re: [R] Date Time in R
>>
>>
>>
>> Hi David,
>>
>> This gives the results accurately. The first line shows all the variable
>> names and the rest shows all values stored for each of the variable. Here
>> date is appearing as correct.
>>
>>
>>
>> Thanks, Shivi
>>
>>
>>
>> On Tue, Jul 26, 2016 at 7:39 PM, David L Carlson 
>> wrote:
>>
>> What does this produce?
>>
>> > readLines("YourCSVfilename.csv", n=5)
>>
>> If the data are in Excel, the date format used in .csv files is not always
>> in the same as the format used when viewing dates in the spreadsheet.
>>
>> -
>> David L Carlson
>> Department of Anthropology
>> Texas A University
>> College Station, TX 77840-4352
>>
>>
>>
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi
>> Bhatia
>> Sent: Tuesday, July 26, 2016 7:42 AM
>> To: Marc Schwartz
>> Cc: R-help
>> Subject: Re: [R] Date Time in R
>>
>> Thanks Marc for the help. this really helps.
>> I think there is some issue with the data saved in csv format for this
>> variable as when i checked:
>> str(eir$date)- this results in :-
>> Date[1:5327], format: NA NA NA NA NA.
>>
>> Thanks again.
>>
>> On Tue, Jul 26, 2016 at 5:58 PM, Marc Schwartz 
>> wrote:
>>
>> > Hi,
>> >
>> > That eir$date might be a factor is irrelevant. There is an as.Date()
>> > method for factors, which does the factor to character coercion
>> internally
>> > and then calls as.Date.character() on the result.
>> >
>> > Using the example data below:
>> >
>> > eir <- data.frame(date = c("05-30-16", "05-30-16", "05-30-16",
>> >"05-30-16", "05-30-16", "05-30-16"))
>> >
>> > > str(eir)
>> > 'data.frame':   6 obs. of  1 variable:
>> >  $ date: Factor w/ 1 level "05-30-16": 1 1 1 1 1 1
>> >
>> > > eir
>> >   date
>> > 1 05-30-16
>> > 2 05-30-16
>> > 3 05-30-16
>> > 4 05-30-16
>> > 5 05-30-16
>> > 6 05-30-16
>> >
>> > eir$date <- as.Date(eir$date, format = "%m-%d-%y")
>> >
>> > > str(eir)
>> > 'data.frame':   6 obs. of  1 variable:
>> >  $ date: Date, format: "2016-05-30" ...
>> >
>> > > eir
>> > date
>> > 1 2016-05-30
>> > 2 2016-05-30
>> > 3 2016-05-30
>> > 4 2016-05-30
>> > 5 2016-05-30
>> > 6 2016-05-30
>> >
>> > eir$days <- weekdays(eir$date)
>> >
>> > > str(eir)
>> > 'data.frame':   6 obs. of  2 variables:
>> >  $ date: Date, format: "2016-05-30" ...
>> >  $ days: chr  "Monday" "Monday" "Monday" "Monday" ...
>> >
>> > > eir
>> > date   days
>> > 1 2016-05-30 Monday
>> > 2 2016-05-30 Monday
>> > 3 2016-05-30 Monday
>> > 4 2016-05-30 Monday
>> > 5 2016-05-30 Monday
>> > 6 2016-05-30 Monday
>> >
>> >
>> > I would check to be sure that you do not have any typos in your code.
>> >
>> > Regards,
>> >
>> > Marc Schwartz
>> >
>> >
>> > > On Jul 26, 2016, at 6:58 AM, Shivi Bhatia 
>> wrote:
>> 

Re: [R] Date Time in R

2016-07-26 Thread Tom Wright
Hi again Shiva,
I think what we need to see is the output from:

str(eid$date)

and perhaps
head(eid$date)

If you can send this information before doing any processing on the date
(i.e. before the as.Date() function) we may be able to help.



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi Bhatia
Sent: July 26, 2016 11:46 AM
To: David L Carlson 
Cc: r-help 
Subject: Re: [R] Date Time in R

Hi David please see the code and some reproducible data:
eir$date<- as.Date(eir$date,format = "%m-%d-%y")  then i had used the
lubridate library to help with the dates:
install.packages("lubridate")
library(lubridate)
eir$date <- mdy(eir$date)
weekdays <- wdy(eir$date)
week names <- wdy(eir$date, label = TRUE)

This the output from the file:

structure(list(date = structure(c(NA_real_, NA_real_, NA_real_), class =
"Date"),

month = structure(c(2L, 2L, 2L), .Label = c("Jun","May"), class = "factor"),

day = c(30L, 30L, 30L),

weekday = structure(c(2L,2L, 2L), .Label = c("Fri", "Mon", "Sat", "Sun",
"Thu", "Tue","Wed"), class = "factor"),

survey_rating = c(3L, 2L, 3L), query_status = c("Yes", "Don't know","No"),

 a = c("05-30-16", "05-30-16", "05-30-16")), .Names = c("date","month",
"day", "weekday", "survey_rating"), row.names = c(NA, 3L), class =
"data.frame")

There are several other variables that i have removed which are not relevant
in this context.

On Tue, Jul 26, 2016 at 8:55 PM, David L Carlson  wrote:

> Show us the output, don’t just tell us what you are seeing. If the
> dates are correct in the csv file, show us the structure of the data
> frame you created with read.csv() and show the command(s) you used to
> convert the character data to date format. The solution is likely to
> be simple if you will cut/paste the R console and not just describe what
> is happening.
>
>
>
> David C
>
>
>
> *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
> *Sent:* Tuesday, July 26, 2016 10:08 AM
> *To:* David L Carlson
>
> *Subject:* Re: [R] Date Time in R
>
>
>
> Hi David,
>
> This gives the results accurately. The first line shows all the
> variable names and the rest shows all values stored for each of the
> variable. Here date is appearing as correct.
>
>
>
> Thanks, Shivi
>
>
>
> On Tue, Jul 26, 2016 at 7:39 PM, David L Carlson 
> wrote:
>
> What does this produce?
>
> > readLines("YourCSVfilename.csv", n=5)
>
> If the data are in Excel, the date format used in .csv files is not
> always in the same as the format used when viewing dates in the
> spreadsheet.
>
> -
> David L Carlson
> Department of Anthropology
> Texas A University
> College Station, TX 77840-4352
>
>
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi
> Bhatia
> Sent: Tuesday, July 26, 2016 7:42 AM
> To: Marc Schwartz
> Cc: R-help
> Subject: Re: [R] Date Time in R
>
> Thanks Marc for the help. this really helps.
> I think there is some issue with the data saved in csv format for this
> variable as when i checked:
> str(eir$date)- this results in :-
> Date[1:5327], format: NA NA NA NA NA.
>
> Thanks again.
>
> On Tue, Jul 26, 2016 at 5:58 PM, Marc Schwartz 
> wrote:
>
> > Hi,
> >
> > That eir$date might be a factor is irrelevant. There is an as.Date()
> > method for factors, which does the factor to character coercion
> internally
> > and then calls as.Date.character() on the result.
> >
> > Using the example data below:
> >
> > eir <- data.frame(date = c("05-30-16", "05-30-16", "05-30-16",
> >"05-30-16", "05-30-16", "05-30-16"))
> >
> > > str(eir)
> > 'data.frame':   6 obs. of  1 variable:
> >  $ date: Factor w/ 1 level "05-30-16": 1 1 1 1 1 1
> >
> > > eir
> >   date
> > 1 05-30-16
> > 2 05-30-16
> > 3 05-30-16
> > 4 05-30-16
> > 5 05-30-16
> > 6 05-30-16
> >
> > eir$date <- as.Date(eir$date, format = "%m-%d-%y")
> >
> > > str(eir)
> > 'data.frame':   6 obs. of  1 variable:
> >  $ date: Date, format: "2016-05-30" ...
> >
> > > eir
> > date
> > 1 2016-05-30
> > 2 2016-05-30
> > 3 2016-05-30
> > 4 2016-05-30
> > 5 2016-05-30
> > 6 2016-05-30
> >
> > eir$days <- weekdays(eir$date)
> >
> > > str(eir)
> > 'data.frame':   6 obs. of  2 variables:
> >  $ date: Date, format: "2016-05-30" ...
> >  $ days: chr  "Monday" "Monday" "Monday" "Monday" ...
> >
> > > eir
> > date   days
> > 1 2016-05-30 Monday
> > 2 2016-05-30 Monday
> > 3 2016-05-30 Monday
> > 4 2016-05-30 Monday
> > 5 2016-05-30 Monday
> > 6 2016-05-30 Monday
> >
> >
> > I would check to be sure that you do not have any typos in your code.
> >
> > Regards,
> >
> > Marc Schwartz
> >
> >
> > > On Jul 26, 2016, at 6:58 AM, Shivi Bhatia 
> wrote:
> > >
> > > Hello Again,
> > >
> > > While i tried your solution as you suggested above it seems to be
> > working.
> > > Here is the output
> > > temp<- 

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Hi Team,

Please read wdy as wday it was mistakenly copied.


On Tue, Jul 26, 2016 at 9:15 PM, Shivi Bhatia  wrote:

> Hi David please see the code and some reproducible data:
> eir$date<- as.Date(eir$date,format = "%m-%d-%y")  then i had used the
> lubridate library to help with the dates:
> install.packages("lubridate")
> library(lubridate)
> eir$date <- mdy(eir$date)
> weekdays <- wdy(eir$date)
> week names <- wdy(eir$date, label = TRUE)
>
> This the output from the file:
>
> structure(list(date = structure(c(NA_real_, NA_real_, NA_real_), class =
> "Date"),
>
> month = structure(c(2L, 2L, 2L), .Label = c("Jun","May"), class =
> "factor"),
>
> day = c(30L, 30L, 30L),
>
> weekday = structure(c(2L,2L, 2L), .Label = c("Fri", "Mon", "Sat", "Sun",
> "Thu", "Tue","Wed"), class = "factor"),
>
> survey_rating = c(3L, 2L, 3L), query_status = c("Yes", "Don't know",
> "No"),
>
>  a = c("05-30-16", "05-30-16", "05-30-16")), .Names = c("date","month",
> "day", "weekday", "survey_rating"), row.names = c(NA, 3L), class =
> "data.frame")
>
> There are several other variables that i have removed which are not
> relevant in this context.
>
> On Tue, Jul 26, 2016 at 8:55 PM, David L Carlson 
> wrote:
>
>> Show us the output, don’t just tell us what you are seeing. If the dates
>> are correct in the csv file, show us the structure of the data frame you
>> created with read.csv() and show the command(s) you used to convert the
>> character data to date format. The solution is likely to be simple if you
>> will cut/paste the R console and not just describe what is happening.
>>
>>
>>
>> David C
>>
>>
>>
>> *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
>> *Sent:* Tuesday, July 26, 2016 10:08 AM
>> *To:* David L Carlson
>>
>> *Subject:* Re: [R] Date Time in R
>>
>>
>>
>> Hi David,
>>
>> This gives the results accurately. The first line shows all the variable
>> names and the rest shows all values stored for each of the variable. Here
>> date is appearing as correct.
>>
>>
>>
>> Thanks, Shivi
>>
>>
>>
>> On Tue, Jul 26, 2016 at 7:39 PM, David L Carlson 
>> wrote:
>>
>> What does this produce?
>>
>> > readLines("YourCSVfilename.csv", n=5)
>>
>> If the data are in Excel, the date format used in .csv files is not
>> always in the same as the format used when viewing dates in the spreadsheet.
>>
>> -
>> David L Carlson
>> Department of Anthropology
>> Texas A University
>> College Station, TX 77840-4352
>>
>>
>>
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi
>> Bhatia
>> Sent: Tuesday, July 26, 2016 7:42 AM
>> To: Marc Schwartz
>> Cc: R-help
>> Subject: Re: [R] Date Time in R
>>
>> Thanks Marc for the help. this really helps.
>> I think there is some issue with the data saved in csv format for this
>> variable as when i checked:
>> str(eir$date)- this results in :-
>> Date[1:5327], format: NA NA NA NA NA.
>>
>> Thanks again.
>>
>> On Tue, Jul 26, 2016 at 5:58 PM, Marc Schwartz 
>> wrote:
>>
>> > Hi,
>> >
>> > That eir$date might be a factor is irrelevant. There is an as.Date()
>> > method for factors, which does the factor to character coercion
>> internally
>> > and then calls as.Date.character() on the result.
>> >
>> > Using the example data below:
>> >
>> > eir <- data.frame(date = c("05-30-16", "05-30-16", "05-30-16",
>> >"05-30-16", "05-30-16", "05-30-16"))
>> >
>> > > str(eir)
>> > 'data.frame':   6 obs. of  1 variable:
>> >  $ date: Factor w/ 1 level "05-30-16": 1 1 1 1 1 1
>> >
>> > > eir
>> >   date
>> > 1 05-30-16
>> > 2 05-30-16
>> > 3 05-30-16
>> > 4 05-30-16
>> > 5 05-30-16
>> > 6 05-30-16
>> >
>> > eir$date <- as.Date(eir$date, format = "%m-%d-%y")
>> >
>> > > str(eir)
>> > 'data.frame':   6 obs. of  1 variable:
>> >  $ date: Date, format: "2016-05-30" ...
>> >
>> > > eir
>> > date
>> > 1 2016-05-30
>> > 2 2016-05-30
>> > 3 2016-05-30
>> > 4 2016-05-30
>> > 5 2016-05-30
>> > 6 2016-05-30
>> >
>> > eir$days <- weekdays(eir$date)
>> >
>> > > str(eir)
>> > 'data.frame':   6 obs. of  2 variables:
>> >  $ date: Date, format: "2016-05-30" ...
>> >  $ days: chr  "Monday" "Monday" "Monday" "Monday" ...
>> >
>> > > eir
>> > date   days
>> > 1 2016-05-30 Monday
>> > 2 2016-05-30 Monday
>> > 3 2016-05-30 Monday
>> > 4 2016-05-30 Monday
>> > 5 2016-05-30 Monday
>> > 6 2016-05-30 Monday
>> >
>> >
>> > I would check to be sure that you do not have any typos in your code.
>> >
>> > Regards,
>> >
>> > Marc Schwartz
>> >
>> >
>> > > On Jul 26, 2016, at 6:58 AM, Shivi Bhatia 
>> wrote:
>> > >
>> > > Hello Again,
>> > >
>> > > While i tried your solution as you suggested above it seems to be
>> > working.
>> > > Here is the output
>> > > temp<- dput(head(eir$date))
>> > > c("05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16",
>> "05-30-16")
>> > > however it still shows 

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Hi David please see the code and some reproducible data:
eir$date<- as.Date(eir$date,format = "%m-%d-%y")  then i had used the
lubridate library to help with the dates:
install.packages("lubridate")
library(lubridate)
eir$date <- mdy(eir$date)
weekdays <- wdy(eir$date)
week names <- wdy(eir$date, label = TRUE)

This the output from the file:

structure(list(date = structure(c(NA_real_, NA_real_, NA_real_), class =
"Date"),

month = structure(c(2L, 2L, 2L), .Label = c("Jun","May"), class = "factor"),

day = c(30L, 30L, 30L),

weekday = structure(c(2L,2L, 2L), .Label = c("Fri", "Mon", "Sat", "Sun",
"Thu", "Tue","Wed"), class = "factor"),

survey_rating = c(3L, 2L, 3L), query_status = c("Yes", "Don't know","No"),

 a = c("05-30-16", "05-30-16", "05-30-16")), .Names = c("date","month",
"day", "weekday", "survey_rating"), row.names = c(NA, 3L), class =
"data.frame")

There are several other variables that i have removed which are not
relevant in this context.

On Tue, Jul 26, 2016 at 8:55 PM, David L Carlson  wrote:

> Show us the output, don’t just tell us what you are seeing. If the dates
> are correct in the csv file, show us the structure of the data frame you
> created with read.csv() and show the command(s) you used to convert the
> character data to date format. The solution is likely to be simple if you
> will cut/paste the R console and not just describe what is happening.
>
>
>
> David C
>
>
>
> *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
> *Sent:* Tuesday, July 26, 2016 10:08 AM
> *To:* David L Carlson
>
> *Subject:* Re: [R] Date Time in R
>
>
>
> Hi David,
>
> This gives the results accurately. The first line shows all the variable
> names and the rest shows all values stored for each of the variable. Here
> date is appearing as correct.
>
>
>
> Thanks, Shivi
>
>
>
> On Tue, Jul 26, 2016 at 7:39 PM, David L Carlson 
> wrote:
>
> What does this produce?
>
> > readLines("YourCSVfilename.csv", n=5)
>
> If the data are in Excel, the date format used in .csv files is not always
> in the same as the format used when viewing dates in the spreadsheet.
>
> -
> David L Carlson
> Department of Anthropology
> Texas A University
> College Station, TX 77840-4352
>
>
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi
> Bhatia
> Sent: Tuesday, July 26, 2016 7:42 AM
> To: Marc Schwartz
> Cc: R-help
> Subject: Re: [R] Date Time in R
>
> Thanks Marc for the help. this really helps.
> I think there is some issue with the data saved in csv format for this
> variable as when i checked:
> str(eir$date)- this results in :-
> Date[1:5327], format: NA NA NA NA NA.
>
> Thanks again.
>
> On Tue, Jul 26, 2016 at 5:58 PM, Marc Schwartz 
> wrote:
>
> > Hi,
> >
> > That eir$date might be a factor is irrelevant. There is an as.Date()
> > method for factors, which does the factor to character coercion
> internally
> > and then calls as.Date.character() on the result.
> >
> > Using the example data below:
> >
> > eir <- data.frame(date = c("05-30-16", "05-30-16", "05-30-16",
> >"05-30-16", "05-30-16", "05-30-16"))
> >
> > > str(eir)
> > 'data.frame':   6 obs. of  1 variable:
> >  $ date: Factor w/ 1 level "05-30-16": 1 1 1 1 1 1
> >
> > > eir
> >   date
> > 1 05-30-16
> > 2 05-30-16
> > 3 05-30-16
> > 4 05-30-16
> > 5 05-30-16
> > 6 05-30-16
> >
> > eir$date <- as.Date(eir$date, format = "%m-%d-%y")
> >
> > > str(eir)
> > 'data.frame':   6 obs. of  1 variable:
> >  $ date: Date, format: "2016-05-30" ...
> >
> > > eir
> > date
> > 1 2016-05-30
> > 2 2016-05-30
> > 3 2016-05-30
> > 4 2016-05-30
> > 5 2016-05-30
> > 6 2016-05-30
> >
> > eir$days <- weekdays(eir$date)
> >
> > > str(eir)
> > 'data.frame':   6 obs. of  2 variables:
> >  $ date: Date, format: "2016-05-30" ...
> >  $ days: chr  "Monday" "Monday" "Monday" "Monday" ...
> >
> > > eir
> > date   days
> > 1 2016-05-30 Monday
> > 2 2016-05-30 Monday
> > 3 2016-05-30 Monday
> > 4 2016-05-30 Monday
> > 5 2016-05-30 Monday
> > 6 2016-05-30 Monday
> >
> >
> > I would check to be sure that you do not have any typos in your code.
> >
> > Regards,
> >
> > Marc Schwartz
> >
> >
> > > On Jul 26, 2016, at 6:58 AM, Shivi Bhatia 
> wrote:
> > >
> > > Hello Again,
> > >
> > > While i tried your solution as you suggested above it seems to be
> > working.
> > > Here is the output
> > > temp<- dput(head(eir$date))
> > > c("05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16",
> "05-30-16")
> > > however it still shows class(eir$date) as character and hence i cannot
> > find
> > > weekdays from this variable.
> > >
> > > Sorry but i still dont understand in totality how R reads dates even
> > though
> > > have tried enough.
> > >
> > > Regards, Shivi
> > >
> > >
> > > On Tue, Jul 26, 2016 at 5:12 PM, Shivi Bhatia 
> > wrote:
> > >
> > >> Thanks 

Re: [R] Date Time in R

2016-07-26 Thread Nordlund, Dan (DSHS/RDA)
You still seem to be having problems, so where is the promised reproducible 
example?

Dan

Daniel Nordlund, PhD
Research and Data Analysis Division
Services & Enterprise Support Administration
Washington State Department of Social and Health Services

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi
> Bhatia
> Sent: Tuesday, July 26, 2016 4:43 AM
> To: Duncan Murdoch
> Cc: r-help@r-project.org
> Subject: Re: [R] Date Time in R
> 
> Thanks Duncan for the quick response. I will check again as you suggested.
> If that doesn't work i will share a reproducible example.
> 
> Thanks again
> 
> On Tue, Jul 26, 2016 at 4:43 PM, Duncan Murdoch
> 
> wrote:
> 
> > On 26/07/2016 7:05 AM, Shivi Bhatia wrote:
> >
> >> Hi Team,
> >>
> >> This scenario may have come across a number of times however i
> >> checked nabble & SO and couldn't find a solution hence request
> assistance.
> >>
> >> I have a date variable in my data-set eir. The class of this var was
> >> character while i had read the file in r studio. Example of date -
> >> 05-30-16
> >>
> >> To change this i have used eir$date<- as.Date(eir$date, "%m-%d-%y").
> >> This converts it to a date variable. However when i check few obs
> >> with head(eir$date) all the results are .
> >>
> >
> > I think you don't have character data like that, because I see
> >
> > > as.Date("05-30-16", "%m-%d-%y")
> > [1] "2016-05-30"
> >
> > I'd guess eir$date is really a factor, because character data is
> > frequently changed to factor automatically.  If that's the case, this
> > should work for the conversion:
> >
> > as.Date(as.character(eir$date), "%m-%d-%y")
> >
> > If that doesn't work, you'll need to post something reproducible.
> >
> > Duncan Murdoch
> >
> > I also need to create weekdays from this date variable but until i get
> > this
> >> resolved i cant find a weekday. For weekday i have used:
> >> eir$week<- (eir$date)
> >> eir$week<- weekdays(as.Date(eir$week))
> >> class(eir$week)
> >> eir$week<- as.factor(eir$week)
> >> head(eir$week)
> >>
> >> Head of this eir$week results again as expected in  but shows
> Levels:
> >> Friday Monday Saturday Sunday Thursday Tuesday Wednesday
> >>
> >> Not sure what i should do here. Kindly suggest.
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >>
> >
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Date Time in R

2016-07-26 Thread David L Carlson
Show us the output, don’t just tell us what you are seeing. If the dates are 
correct in the csv file, show us the structure of the data frame you created 
with read.csv() and show the command(s) you used to convert the character data 
to date format. The solution is likely to be simple if you will cut/paste the R 
console and not just describe what is happening.

David C

From: Shivi Bhatia [mailto:shivipm...@gmail.com]
Sent: Tuesday, July 26, 2016 10:08 AM
To: David L Carlson
Subject: Re: [R] Date Time in R

Hi David,
This gives the results accurately. The first line shows all the variable names 
and the rest shows all values stored for each of the variable. Here date is 
appearing as correct.

Thanks, Shivi

On Tue, Jul 26, 2016 at 7:39 PM, David L Carlson 
> wrote:
What does this produce?

> readLines("YourCSVfilename.csv", n=5)

If the data are in Excel, the date format used in .csv files is not always in 
the same as the format used when viewing dates in the spreadsheet.

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


-Original Message-
From: R-help 
[mailto:r-help-boun...@r-project.org] On 
Behalf Of Shivi Bhatia
Sent: Tuesday, July 26, 2016 7:42 AM
To: Marc Schwartz
Cc: R-help
Subject: Re: [R] Date Time in R

Thanks Marc for the help. this really helps.
I think there is some issue with the data saved in csv format for this
variable as when i checked:
str(eir$date)- this results in :-
Date[1:5327], format: NA NA NA NA NA.

Thanks again.

On Tue, Jul 26, 2016 at 5:58 PM, Marc Schwartz 
> wrote:

> Hi,
>
> That eir$date might be a factor is irrelevant. There is an as.Date()
> method for factors, which does the factor to character coercion internally
> and then calls as.Date.character() on the result.
>
> Using the example data below:
>
> eir <- data.frame(date = c("05-30-16", "05-30-16", "05-30-16",
>"05-30-16", "05-30-16", "05-30-16"))
>
> > str(eir)
> 'data.frame':   6 obs. of  1 variable:
>  $ date: Factor w/ 1 level "05-30-16": 1 1 1 1 1 1
>
> > eir
>   date
> 1 05-30-16
> 2 05-30-16
> 3 05-30-16
> 4 05-30-16
> 5 05-30-16
> 6 05-30-16
>
> eir$date <- as.Date(eir$date, format = "%m-%d-%y")
>
> > str(eir)
> 'data.frame':   6 obs. of  1 variable:
>  $ date: Date, format: "2016-05-30" ...
>
> > eir
> date
> 1 2016-05-30
> 2 2016-05-30
> 3 2016-05-30
> 4 2016-05-30
> 5 2016-05-30
> 6 2016-05-30
>
> eir$days <- weekdays(eir$date)
>
> > str(eir)
> 'data.frame':   6 obs. of  2 variables:
>  $ date: Date, format: "2016-05-30" ...
>  $ days: chr  "Monday" "Monday" "Monday" "Monday" ...
>
> > eir
> date   days
> 1 2016-05-30 Monday
> 2 2016-05-30 Monday
> 3 2016-05-30 Monday
> 4 2016-05-30 Monday
> 5 2016-05-30 Monday
> 6 2016-05-30 Monday
>
>
> I would check to be sure that you do not have any typos in your code.
>
> Regards,
>
> Marc Schwartz
>
>
> > On Jul 26, 2016, at 6:58 AM, Shivi Bhatia 
> > > wrote:
> >
> > Hello Again,
> >
> > While i tried your solution as you suggested above it seems to be
> working.
> > Here is the output
> > temp<- dput(head(eir$date))
> > c("05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16")
> > however it still shows class(eir$date) as character and hence i cannot
> find
> > weekdays from this variable.
> >
> > Sorry but i still dont understand in totality how R reads dates even
> though
> > have tried enough.
> >
> > Regards, Shivi
> >
> >
> > On Tue, Jul 26, 2016 at 5:12 PM, Shivi Bhatia 
> > >
> wrote:
> >
> >> Thanks Duncan for the quick response. I will check again as you
> suggested.
> >> If that doesn't work i will share a reproducible example.
> >>
> >> Thanks again
> >>
> >> On Tue, Jul 26, 2016 at 4:43 PM, Duncan Murdoch <
> murdoch.dun...@gmail.com>
> >> wrote:
> >>
> >>> On 26/07/2016 7:05 AM, Shivi Bhatia wrote:
> >>>
>  Hi Team,
> 
>  This scenario may have come across a number of times however i checked
>  nabble & SO and couldn't find a solution hence request assistance.
> 
>  I have a date variable in my data-set eir. The class of this var was
>  character while i had read the file in r studio. Example of date -
>  05-30-16
> 
>  To change this i have used eir$date<- as.Date(eir$date, "%m-%d-%y").
> This
>  converts it to a date variable. However when i check few obs
>  with head(eir$date) all the results are .
> 
> >>>
> >>> I think you don't have character data like that, because I see
> >>>
>  as.Date("05-30-16", "%m-%d-%y")
> >>> [1] "2016-05-30"
> >>>
> >>> I'd guess eir$date is really a factor, because character data is
> >>> frequently changed to factor automatically.  If 

Re: [R-es] Exportar datos en formato de Excel

2016-07-26 Thread Fernando Macedo
Que error te dá el uso de xlsx?

Lo he probado tanto en windows 10 como en Ubuntu 16.04 y no he tenido
problemas.

Saludos



Fernando Macedo

El 26/07/16 a las 07:22, Alexa Aristizabal escribió:

Buenos días a todos!

Estoy trabajando con una base de datos que directamente he descargado de
internet y después de prepararla un poco necesito exportarla a Excel he
intentando con las dos opciones que mencionaré al final pero ninguna
funciona, de qué otra manera puedo exportar esos datos a Excel... muchas
gracias por su ayuda y pronta respuesta!

1)

library(xlsx)
library(rJava)
library(xlsxjars)
write.xlsx(mydata, file="mydata.xlsx")

2)

library(xlsReadWrite) #abrimos el paquete
write.xls(prueba, file="datanueva.xls",sheet="lapop10")

[[alternative HTML version deleted]]

___
R-help-es mailing
listR-help-es@r-project.orghttps://stat.ethz.ch/mailman/listinfo/r-help-es

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Exportar datos en formato de Excel

2016-07-26 Thread Javier Marcuzzi
Estimados

Exportar a Excel desde R es posible, pero muchas opciones utilizan java, y este 
lenguaje últimamente tiene algunos problemas, yo experimente inconvenientes al 
exportar desde R a Excel en Windows 10.

Aunque también tengo inconvenientes por otros lados, por ejemplo ideaJ y 
netbeans me informan de errores con códigos demo, ejemplos en repositorios 
públicos o generados por los programas, donde no hay error de lógica, de 
programación, desde fábrica sin cambiar nada, sin tocar, …, hay algo que hace 
varios días me rompe la cabeza y no funciona.

Regresando a R, si no es una cantidad alta de data.frames, por simplicidad 
puede llegar a exportarlos como csv, luego los abre desde Excel, le inserta una 
fila con un título y alguna letra distinta y lo guarda con formato de Excel. 
Simple para pocos datos aunque depende la situación esto puede llegar a ser muy 
improductivo.

Javier Rubén Marcuzzi

De: Mauricio Monsalvo
[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

[R] Linear Dependance of Model Matrix and How Fitted/ Sums of Squares Follow

2016-07-26 Thread Justin Thong
Below is the covariates for a model ~x1+x2+x3+x4+x5+x6. I noticed that when
fitting this model that the coefficient x6 is unestimable.*Is this merely a
case that adding more columns to my model matrix will eventually lead to
linear dependance so the more terms I have in the model formulae the more
likely the model matrix becomes linearly dependant?*   I found that for
model formulae ~x1+x2+x3+x4+x5, all the coefficients are estimable so I
guess this example supports my statement.

But that being said, since not all coefficients are estimated then how does
R compute the fitted values and anova table. *Does it just ignore the
existence of x6 and consider the model to be ~x1+x2+x3+x4+x5? Or is there
something deeper that I do not understand.* Because the sums of squares and
fitted seem to be the same for model ~x1+x2+x3+x4+x5 as it is for
~x1+x2+x3+x4+x5+x6

However, this is not so clear cut for model with factors. Because factors
are only represented by a parameter for each level in the model matrix.
Consider factor F with 2 levels and G with 3 levels. The problem is that R
has a way of excluding certain rows from the anova table. Again, it can be
seen that it excludes the rows associated with the parameters which are not
estimable, but this is not absolutely clear in my mind.Look at small
example below for model ~F*G for two factors. As you can see, the
interaction parameters are not estimable ie F2:G2 and F2:G3. Now from what
I was told, F1 and G1 is contained within the (Intercept) parameter so
F1:G1, F1:G2, F2:G1 are not considered. You can see from the anova table
that the interaction row F:G is ignored. My main problem is why is it
ignored.
*Does that mean that if all the parameters (excluding the ones asasociated
with intercept) that is associated with a particular term is unestimable
then the row of that term in the anova table is ignored? How many
 unestimable parameters must there be for the row of a term to be
ignored? *Because
If the answer to the second question is to calculate fitted values and sums
of squares by ignoring unestimable parameters, then it means that the rows
of sums of squares disappear for a different reason other than
unestimability.

Sorry for the generally wordy question. I may not be thinking of it in the
correct manner and I would appreciate if anyone has an answer and perhaps
even some generalisations towards the use of QR decomposition.

(There is more code below this data)

 x1 x2 x3 x4 x5 x6
1   12  0  0  0  0  0
2   12  0  0  0  0  0
3   12  0  0  0  0  0
4   12  0  0  0  0  0
50 12  0  0  0  0
60 12  0  0  0  0
70 12  0  0  0  0
80 12  0  0  0  0
90  0 12  0  0  0
10   0  0 12  0  0  0
11   0  0 12  0  0  0
12   0  0 12  0  0  0
13   0  0  0 12  0  0
14   0  0  0 12  0  0
15   0  0  0 12  0  0
16   0  0  0 12  0  0
17   0  0  0  0 12  0
18   0  0  0  0 12  0
19   0  0  0  0 12  0
20   0  0  0  0 12  0
21   0  0  0  0  0 12
22   0  0  0  0  0 12
23   0  0  0  0  0 12
24   0  0  0  0  0 12
25   6  6  0  0  0  0
26   6  6  0  0  0  0
27   6  6  0  0  0  0
28   6  6  0  0  0  0
29   6  0  6  0  0  0
30   6  0  6  0  0  0
31   6  0  6  0  0  0
32   6  0  6  0  0  0
33   6  0  0  6  0  0
34   6  0  0  6  0  0
35   6  0  0  6  0  0
36   6  0  0  6  0  0
37   6  0  0  0  6  0
38   6  0  0  0  6  0
39   6  0  0  0  6  0
40   6  0  0  0  6  0
41   6  0  0  0  0  6
42   6  0  0  0  0  6
43   6  0  0  0  0  6
44   6  0  0  0  0  6
45   0  6  6  0  0  0
46   0  6  6  0  0  0
47   0  6  6  0  0  0
48   0  6  6  0  0  0
49   0  6  0  6  0  0
50   0  6  0  6  0  0
51   0  6  0  6  0  0
52   0  6  0  6  0  0
53   0  6  0  0  6  0
54   0  6  0  0  6  0
55   0  6  0  0  6  0
56   0  6  0  0  6  0
57   0  6  0  0  0  6
58   0  6  0  0  0  6
59   0  6  0  0  0  6
60   0  6  0  0  0  6
61   0  0  6  6  0  0
62   0  0  6  6  0  0
63   0  0  6  6  0  0
64   0  0  6  6  0  0
65   0  0  6  0  6  0
66   0  0  6  0  6  0
67   0  0  6  0  6  0
68   0  0  6  0  6  0
69   0  0  6  0  0  6
70   0  0  6  0  0  6
71   0  0  6  0  0  6
72   0  0  6  0  0  6
73   0  0  0  6  6  0
74   0  0  0  6  6  0
75   0  0  0  6  6  0
76   0  0  0  6  6  0
77   0  0  0  6  0  6
78   0  0  0  6  0  6
79   0  0  0  6  0  6
80   0  0  0  6  0  6
81   0  0  0  0  6  6
82   0  0  0  0  6  6
83   0  0  0  0  6  6
84   0  0  0  0  6  6
85   4  4  4  0  0  0
86   4  4  4  0  0  0
87   4  4  4  0  0  0
88   4  4  4  0  0  0
89   4  4  0  4  0  0
90   4  4  0  4  0  0
91   4  4  0  4  0  0
92   4  4  0  4  0  0
93   4  4  0  0  4  0
94   4  4  0  0  4  0
95   4  4  0  0  4  0
96   4  4  0  0  4  0
97   4  4  0  0  0  4
98   4  4  0  0  0  4
99   4  4  0  0  0  4
100  4  4  0  0  0  4
101  4  0  4  4  0  0
102  4  0  4  4  0  0
103  4  0  4  4  0  0
104  4  0  4  4  0  0
105  4  0  4  0  4  0
106  4  0  4  0  4  0
107  4  0  4  0  4  0
108  4  0  4  0  4  0
109  4  0  4  0  0  4
110  4  0  4  0  0  4
111  4  0  4  0  0  4
112  4  0  4  0  0  4
113  4  0  0  4  4  0
114  4  0  0  4  4  0
115  4  0  0  4  4 

Re: [R-es] Exportar datos en formato de Excel

2016-07-26 Thread Mauricio Monsalvo
Yo uso Windows, que suele ser la explicación de todos los males... Voy a
intentar pasarme a XLConnect y si resulta, lo comparto.
De todos modos, para leer y guardar como un xlsx eñ openxlsx con RTools
funciona bien.


El 26 de julio de 2016, 11:44, Javier Martínez-López <
javi.martinez.lo...@gmail.com> escribió:

> vaya, pues no sé, yo uso Ubuntu Linux 14.04 con Oracle Java 1.8 instalado,
> a lo mejor con windows da problemas pero el script funciona bien. Puede ser
> que tengáis que añadir el JAVA_HOME al path?
>
> 2016-07-26 16:39 GMT+02:00 Mauricio Monsalvo :
>
>> Hola.
>> En mi caso, no he podido resolver los problemas con el Java para usar
>> XLConnect, que en los papeles me parece el mejor. Supongo que algo de la
>> arquitectura del sistema o bien de la relación entre el Java, el R y el
>> RStudio.
>> Así que utilizo
>> library(openxlsx)
>> write.xlsx(datos, file = "EDA1.xlsx") #donde datos es el objeto que
>> quiero guardar.
>> Requiere instalar el RTools, según tipo y arquitectura del sistema
>> operativo que utilices para que camine (para Win:
>> https://cran.r-project.org/bin/windows/Rtools/). Es importante que
>> RTools se instale en el path que pone por defecto (ni idea por qué, pero me
>> pasó que lo instalé en otro Dir y nunca anduvo). También es posible que
>> debas ejecutar este comando en la consola:
>> Sys.setenv(R_ZIPCMD= "C:/Rtools/bin/zip") #Por el RTools
>> Saludos.
>>
>>
>> El 26 de julio de 2016, 8:49, Javier Martínez-López <
>> javi.martinez.lo...@gmail.com> escribió:
>>
>>> que raro... se te ha instalado bien la librería? tiene pinta de un
>>> problema
>>> de JAVA pero no sé cuál...
>>>
>>> 2016-07-26 13:46 GMT+02:00 Alexa Aristizabal <
>>> alexa.aristizaba...@gmail.com>
>>> :
>>>
>>> > Hola Javier, de antemano muchas gracias por tu ayuda! :)
>>> >
>>> > He intentado replicar tu script pero sale el siguiente error:
>>> >
>>> > Error in .jarray(v) :
>>> >   Java Exception >> failed>.jarray(v)>> > object of class "jobjRef">
>>> > > saveWorkbook(exc)
>>> > Error in .jcheck() :
>>> >   Java Exception >> > failed>.jcall("RJavaTools", "Z", "hasMethod", .jcast(x,
>>> > "java/lang/Object"), name)
>>> >
>>> > El 26 de julio de 2016, 13:25, Javier Martínez-López <
>>> > javier.marti...@bc3research.org> escribió:
>>> >
>>> >> Yo utilizo este script, done 'DataFrame' es el df que quieres guardar:
>>> >>
>>> >> library(XLConnect)
>>> >>
>>> >> fileXls <- "newFile.xlsx"
>>> >> unlink(fileXls, recursive = FALSE, force = FALSE)
>>> >> exc <- loadWorkbook(fileXls, create = TRUE)
>>> >> createSheet(exc,'Data')
>>> >> saveWorkbook(exc)
>>> >> writeWorksheet(exc, DataFrame, sheet = "Data", startRow = 1, startCol
>>> = 1)
>>> >> saveWorkbook(exc)
>>> >>
>>> >> Saludos,
>>> >>
>>> >> Javier
>>> >>
>>> >> 2016-07-26 12:52 GMT+02:00 Isidro Hidalgo Arellano >> >:
>>> >>
>>> >>> Te recomiendo el paquete "openxlsx". Verás que es muy sencillo de
>>> >>> utilizar.
>>> >>> En la página "
>>> >>> https://cran.r-project.org/web/packages/openxlsx/index.html;
>>> >>> tienes las vignettes, los ejemplos son instantáneos:
>>> >>>
>>> >>>
>>> https://cran.r-project.org/web/packages/openxlsx/vignettes/Introduction.pdf
>>> >>> Un saludo
>>> >>>
>>> >>> Isidro Hidalgo Arellano
>>> >>> Observatorio del Mercado de Trabajo
>>> >>> Consejería de Economía, Empresas y Empleo
>>> >>> http://www.castillalamancha.es/
>>> >>>
>>> >>>
>>> >>>
>>> >>> -Mensaje original-
>>> >>> De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de
>>> >>> Alexa
>>> >>> Aristizabal
>>> >>> Enviado el: martes, 26 de julio de 2016 12:22
>>> >>> Para: r-help-es@r-project.org
>>> >>> Asunto: [R-es] Exportar datos en formato de Excel
>>> >>>
>>> >>> Buenos días a todos!
>>> >>>
>>> >>> Estoy trabajando con una base de datos que directamente he
>>> descargado de
>>> >>> internet y después de prepararla un poco necesito exportarla a Excel
>>> he
>>> >>> intentando con las dos opciones que mencionaré al final pero ninguna
>>> >>> funciona, de qué otra manera puedo exportar esos datos a Excel...
>>> muchas
>>> >>> gracias por su ayuda y pronta respuesta!
>>> >>>
>>> >>> 1)
>>> >>>
>>> >>> library(xlsx)
>>> >>> library(rJava)
>>> >>> library(xlsxjars)
>>> >>> write.xlsx(mydata, file="mydata.xlsx")
>>> >>>
>>> >>> 2)
>>> >>>
>>> >>> library(xlsReadWrite) #abrimos el paquete write.xls(prueba,
>>> >>> file="datanueva.xls",sheet="lapop10")
>>> >>>
>>> >>> [[alternative HTML version deleted]]
>>> >>>
>>> >>> ___
>>> >>> R-help-es mailing list
>>> >>> R-help-es@r-project.org
>>> >>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>> >>>
>>> >>> ___
>>> >>> R-help-es mailing list
>>> >>> R-help-es@r-project.org
>>> >>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>> >>>
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >>
>>> >>
>>> >
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> 

Re: [R-es] Exportar datos en formato de Excel

2016-07-26 Thread Manuel Spínola
Hola,

Yo estoy usando la librería rio y la función export es muy práctica.

Manuel Spínola

El 26 de julio de 2016, 8:39, Mauricio Monsalvo 
escribió:

> Hola.
> En mi caso, no he podido resolver los problemas con el Java para usar
> XLConnect, que en los papeles me parece el mejor. Supongo que algo de la
> arquitectura del sistema o bien de la relación entre el Java, el R y el
> RStudio.
> Así que utilizo
> library(openxlsx)
> write.xlsx(datos, file = "EDA1.xlsx") #donde datos es el objeto que quiero
> guardar.
> Requiere instalar el RTools, según tipo y arquitectura del sistema
> operativo que utilices para que camine (para Win:
> https://cran.r-project.org/bin/windows/Rtools/). Es importante que RTools
> se instale en el path que pone por defecto (ni idea por qué, pero me pasó
> que lo instalé en otro Dir y nunca anduvo). También es posible que debas
> ejecutar este comando en la consola:
> Sys.setenv(R_ZIPCMD= "C:/Rtools/bin/zip") #Por el RTools
> Saludos.
>
>
> El 26 de julio de 2016, 8:49, Javier Martínez-López <
> javi.martinez.lo...@gmail.com> escribió:
>
> > que raro... se te ha instalado bien la librería? tiene pinta de un
> problema
> > de JAVA pero no sé cuál...
> >
> > 2016-07-26 13:46 GMT+02:00 Alexa Aristizabal <
> > alexa.aristizaba...@gmail.com>
> > :
> >
> > > Hola Javier, de antemano muchas gracias por tu ayuda! :)
> > >
> > > He intentado replicar tu script pero sale el siguiente error:
> > >
> > > Error in .jarray(v) :
> > >   Java Exception  failed>.jarray(v) > > object of class "jobjRef">
> > > > saveWorkbook(exc)
> > > Error in .jcheck() :
> > >   Java Exception  > > failed>.jcall("RJavaTools", "Z", "hasMethod", .jcast(x,
> > > "java/lang/Object"), name)
> > >
> > > El 26 de julio de 2016, 13:25, Javier Martínez-López <
> > > javier.marti...@bc3research.org> escribió:
> > >
> > >> Yo utilizo este script, done 'DataFrame' es el df que quieres guardar:
> > >>
> > >> library(XLConnect)
> > >>
> > >> fileXls <- "newFile.xlsx"
> > >> unlink(fileXls, recursive = FALSE, force = FALSE)
> > >> exc <- loadWorkbook(fileXls, create = TRUE)
> > >> createSheet(exc,'Data')
> > >> saveWorkbook(exc)
> > >> writeWorksheet(exc, DataFrame, sheet = "Data", startRow = 1, startCol
> =
> > 1)
> > >> saveWorkbook(exc)
> > >>
> > >> Saludos,
> > >>
> > >> Javier
> > >>
> > >> 2016-07-26 12:52 GMT+02:00 Isidro Hidalgo Arellano  >:
> > >>
> > >>> Te recomiendo el paquete "openxlsx". Verás que es muy sencillo de
> > >>> utilizar.
> > >>> En la página "
> > >>> https://cran.r-project.org/web/packages/openxlsx/index.html;
> > >>> tienes las vignettes, los ejemplos son instantáneos:
> > >>>
> > >>>
> >
> https://cran.r-project.org/web/packages/openxlsx/vignettes/Introduction.pdf
> > >>> Un saludo
> > >>>
> > >>> Isidro Hidalgo Arellano
> > >>> Observatorio del Mercado de Trabajo
> > >>> Consejería de Economía, Empresas y Empleo
> > >>> http://www.castillalamancha.es/
> > >>>
> > >>>
> > >>>
> > >>> -Mensaje original-
> > >>> De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de
> > >>> Alexa
> > >>> Aristizabal
> > >>> Enviado el: martes, 26 de julio de 2016 12:22
> > >>> Para: r-help-es@r-project.org
> > >>> Asunto: [R-es] Exportar datos en formato de Excel
> > >>>
> > >>> Buenos días a todos!
> > >>>
> > >>> Estoy trabajando con una base de datos que directamente he descargado
> > de
> > >>> internet y después de prepararla un poco necesito exportarla a Excel
> he
> > >>> intentando con las dos opciones que mencionaré al final pero ninguna
> > >>> funciona, de qué otra manera puedo exportar esos datos a Excel...
> > muchas
> > >>> gracias por su ayuda y pronta respuesta!
> > >>>
> > >>> 1)
> > >>>
> > >>> library(xlsx)
> > >>> library(rJava)
> > >>> library(xlsxjars)
> > >>> write.xlsx(mydata, file="mydata.xlsx")
> > >>>
> > >>> 2)
> > >>>
> > >>> library(xlsReadWrite) #abrimos el paquete write.xls(prueba,
> > >>> file="datanueva.xls",sheet="lapop10")
> > >>>
> > >>> [[alternative HTML version deleted]]
> > >>>
> > >>> ___
> > >>> R-help-es mailing list
> > >>> R-help-es@r-project.org
> > >>> https://stat.ethz.ch/mailman/listinfo/r-help-es
> > >>>
> > >>> ___
> > >>> R-help-es mailing list
> > >>> R-help-es@r-project.org
> > >>> https://stat.ethz.ch/mailman/listinfo/r-help-es
> > >>>
> > >>
> > >>
> > >>
> > >> --
> > >>
> > >>
> > >
> >
> > [[alternative HTML version deleted]]
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
> >
>
>
>
> --
> Mauricio
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de 

Re: [R-es] Exportar datos en formato de Excel

2016-07-26 Thread Javier Martínez-López
vaya, pues no sé, yo uso Ubuntu Linux 14.04 con Oracle Java 1.8 instalado,
a lo mejor con windows da problemas pero el script funciona bien. Puede ser
que tengáis que añadir el JAVA_HOME al path?

2016-07-26 16:39 GMT+02:00 Mauricio Monsalvo :

> Hola.
> En mi caso, no he podido resolver los problemas con el Java para usar
> XLConnect, que en los papeles me parece el mejor. Supongo que algo de la
> arquitectura del sistema o bien de la relación entre el Java, el R y el
> RStudio.
> Así que utilizo
> library(openxlsx)
> write.xlsx(datos, file = "EDA1.xlsx") #donde datos es el objeto que quiero
> guardar.
> Requiere instalar el RTools, según tipo y arquitectura del sistema
> operativo que utilices para que camine (para Win:
> https://cran.r-project.org/bin/windows/Rtools/). Es importante que RTools
> se instale en el path que pone por defecto (ni idea por qué, pero me pasó
> que lo instalé en otro Dir y nunca anduvo). También es posible que debas
> ejecutar este comando en la consola:
> Sys.setenv(R_ZIPCMD= "C:/Rtools/bin/zip") #Por el RTools
> Saludos.
>
>
> El 26 de julio de 2016, 8:49, Javier Martínez-López <
> javi.martinez.lo...@gmail.com> escribió:
>
>> que raro... se te ha instalado bien la librería? tiene pinta de un
>> problema
>> de JAVA pero no sé cuál...
>>
>> 2016-07-26 13:46 GMT+02:00 Alexa Aristizabal <
>> alexa.aristizaba...@gmail.com>
>> :
>>
>> > Hola Javier, de antemano muchas gracias por tu ayuda! :)
>> >
>> > He intentado replicar tu script pero sale el siguiente error:
>> >
>> > Error in .jarray(v) :
>> >   Java Exception .jarray(v)> > object of class "jobjRef">
>> > > saveWorkbook(exc)
>> > Error in .jcheck() :
>> >   Java Exception > > failed>.jcall("RJavaTools", "Z", "hasMethod", .jcast(x,
>> > "java/lang/Object"), name)
>> >
>> > El 26 de julio de 2016, 13:25, Javier Martínez-López <
>> > javier.marti...@bc3research.org> escribió:
>> >
>> >> Yo utilizo este script, done 'DataFrame' es el df que quieres guardar:
>> >>
>> >> library(XLConnect)
>> >>
>> >> fileXls <- "newFile.xlsx"
>> >> unlink(fileXls, recursive = FALSE, force = FALSE)
>> >> exc <- loadWorkbook(fileXls, create = TRUE)
>> >> createSheet(exc,'Data')
>> >> saveWorkbook(exc)
>> >> writeWorksheet(exc, DataFrame, sheet = "Data", startRow = 1, startCol
>> = 1)
>> >> saveWorkbook(exc)
>> >>
>> >> Saludos,
>> >>
>> >> Javier
>> >>
>> >> 2016-07-26 12:52 GMT+02:00 Isidro Hidalgo Arellano :
>> >>
>> >>> Te recomiendo el paquete "openxlsx". Verás que es muy sencillo de
>> >>> utilizar.
>> >>> En la página "
>> >>> https://cran.r-project.org/web/packages/openxlsx/index.html;
>> >>> tienes las vignettes, los ejemplos son instantáneos:
>> >>>
>> >>>
>> https://cran.r-project.org/web/packages/openxlsx/vignettes/Introduction.pdf
>> >>> Un saludo
>> >>>
>> >>> Isidro Hidalgo Arellano
>> >>> Observatorio del Mercado de Trabajo
>> >>> Consejería de Economía, Empresas y Empleo
>> >>> http://www.castillalamancha.es/
>> >>>
>> >>>
>> >>>
>> >>> -Mensaje original-
>> >>> De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de
>> >>> Alexa
>> >>> Aristizabal
>> >>> Enviado el: martes, 26 de julio de 2016 12:22
>> >>> Para: r-help-es@r-project.org
>> >>> Asunto: [R-es] Exportar datos en formato de Excel
>> >>>
>> >>> Buenos días a todos!
>> >>>
>> >>> Estoy trabajando con una base de datos que directamente he descargado
>> de
>> >>> internet y después de prepararla un poco necesito exportarla a Excel
>> he
>> >>> intentando con las dos opciones que mencionaré al final pero ninguna
>> >>> funciona, de qué otra manera puedo exportar esos datos a Excel...
>> muchas
>> >>> gracias por su ayuda y pronta respuesta!
>> >>>
>> >>> 1)
>> >>>
>> >>> library(xlsx)
>> >>> library(rJava)
>> >>> library(xlsxjars)
>> >>> write.xlsx(mydata, file="mydata.xlsx")
>> >>>
>> >>> 2)
>> >>>
>> >>> library(xlsReadWrite) #abrimos el paquete write.xls(prueba,
>> >>> file="datanueva.xls",sheet="lapop10")
>> >>>
>> >>> [[alternative HTML version deleted]]
>> >>>
>> >>> ___
>> >>> R-help-es mailing list
>> >>> R-help-es@r-project.org
>> >>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>> >>>
>> >>> ___
>> >>> R-help-es mailing list
>> >>> R-help-es@r-project.org
>> >>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >>
>> >>
>> >
>>
>> [[alternative HTML version deleted]]
>>
>> ___
>> R-help-es mailing list
>> R-help-es@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>
>
>
>
> --
> Mauricio
>

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Visualization of a Convex Hull in R (Possibly with RGL)

2016-07-26 Thread Lorenzo Isella

On Tue, Jul 26, 2016 at 10:48:22AM +, Michael Sumner wrote:

On Tue, 26 Jul 2016 at 20:29 Lorenzo Isella 
wrote:


Dear All,
I am not an expert about the calculation and visualization of convex
hulls, but I am trying to do something relatively simple.
Please consider the snippet at the end of the email.
The array pts  represents the position of (the centres of) a set of
spheres in 3D (whose radius is 0.5).
I found the geometry package which provides bindings to the qhull
(http://www.qhull.org/) library and allows me to calculate the convex
hull of pts and some interesting properties, like the area and the
volume of the convex hull.
That is all fine, but I would like to represent the results in 3D.
I would like to see a set of spheres with the given position in pts
and the radius R=0.5 and the convex hull going based on the
coordinates of pts.
Does anybody know how to achieve that?
Many thanks

Lorenzo






library(geometry)



pts <- read.table("test-agg.dat")

## names(pts) <- c("x", "y", "z")


pts <- structure(list(x = c(0.145138112090815, 0.880429452229448,
-1.66682740805663,
-0.955356943224252, 1.09396798448412, -2.63620653885452,
0.190270563436841,
2.77638842095489, -0.0914977922901252, -0.484087722062158,
0.674992784754569,
1.02571108118502, 2.78789154912298, -0.146882388586427,
-1.71507089246001,
-1.87886026272455, 6.61540228778138, 7.46818822627362,
4.80777628045963,
6.35487269602107, 4.70026626314108, 3.44366671298125,
2.92460648354883,
5.07053866161192, 7.2164343710271, 6.93292242981006, 7.84238243682145,
7.4321237311656, 9.59692827237335, 8.3454086671306, 6.574251622581,
6.93340304175759), y = c(-0.189309482569001, 1.67057595730283,
-0.995542605143325, 2.31599069771684, 1.79876139786291,
0.165886909346058,
2.70740725397259, 1.70535678189514, -0.819087329147786,
0.967935667739331,
-2.53860079551206, -1.60932884056828, -1.42050583991613,
-2.36883245674979,
0.191848867151458, -1.58255618338079, 1.98324724741419,
3.0095048680572,
1.97159273200079, 2.26459561200295, 0.4461804374566, 1.87939977307282,
1.98510457359889, -0.103495422088799, -1.32050185858493,
0.584580736435273,
-2.97562362406436, 0.10620417814, -2.0843758994948,
-1.1492729389287,
-2.13797391772643, -4.45916649729404), z = c(-1.44428170702261,
-1.45742688370091, -1.70267889327056, -1.93637881287001,
-3.4452409532781,
-3.02436538816822, 0.114790290814684, -2.10208878117278,
2.07425243689128,
1.26652602551291, 1.39914827137784, -0.345006925422662,
0.596828021941431,
3.351773622867, 2.68408561840144, 3.97006405709929, 0.82767367646934,
-0.662142231346811, 1.68344957582882, 2.92819854377685,
0.386683699222387,
-0.220305098209874, 2.37510769001993, -1.51041233970289,
-0.707073219742548,
-1.24585080403725, -1.63914669343685, 0.683153891726357,
-1.26623658129696,
1.95073173465968, -2.94804638502708, -0.635785458903106)), .Names =
c("x",
"y", "z"), class = "data.frame", row.names = c(NA, -32L))

res<-convhulln(pts, options = "FA")



In short

library(rgl)
bg3d("grey")
spheres3d(pts, radius = 0.5, col = "white")
## triangle functions generally expect triplets of points, one after another
## and hull/triangulation functions generally return arrays of indexes
## so transpose index of hull is the right order to draw triangles
triangles3d(pts[t(res$hull), ], col = "firebrick", alpha = 0.3)

(But, I wonder if you mean to find the convex hull based on the outer shell
of those spheres? )

Cheers, Mike.





Dear Mike,
Thanks a lot, this is spot on.
Yep, if possible I would even prefer to have the convex hull based on
the outer shell of the spheres, but I wonder if that is easy to
achieve with a few lines of code.
Any ideas would be welcome.
Cheers

Lorenzo

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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-es] Exportar datos en formato de Excel

2016-07-26 Thread Mauricio Monsalvo
Hola.
En mi caso, no he podido resolver los problemas con el Java para usar
XLConnect, que en los papeles me parece el mejor. Supongo que algo de la
arquitectura del sistema o bien de la relación entre el Java, el R y el
RStudio.
Así que utilizo
library(openxlsx)
write.xlsx(datos, file = "EDA1.xlsx") #donde datos es el objeto que quiero
guardar.
Requiere instalar el RTools, según tipo y arquitectura del sistema
operativo que utilices para que camine (para Win:
https://cran.r-project.org/bin/windows/Rtools/). Es importante que RTools
se instale en el path que pone por defecto (ni idea por qué, pero me pasó
que lo instalé en otro Dir y nunca anduvo). También es posible que debas
ejecutar este comando en la consola:
Sys.setenv(R_ZIPCMD= "C:/Rtools/bin/zip") #Por el RTools
Saludos.


El 26 de julio de 2016, 8:49, Javier Martínez-López <
javi.martinez.lo...@gmail.com> escribió:

> que raro... se te ha instalado bien la librería? tiene pinta de un problema
> de JAVA pero no sé cuál...
>
> 2016-07-26 13:46 GMT+02:00 Alexa Aristizabal <
> alexa.aristizaba...@gmail.com>
> :
>
> > Hola Javier, de antemano muchas gracias por tu ayuda! :)
> >
> > He intentado replicar tu script pero sale el siguiente error:
> >
> > Error in .jarray(v) :
> >   Java Exception .jarray(v) > object of class "jobjRef">
> > > saveWorkbook(exc)
> > Error in .jcheck() :
> >   Java Exception  > failed>.jcall("RJavaTools", "Z", "hasMethod", .jcast(x,
> > "java/lang/Object"), name)
> >
> > El 26 de julio de 2016, 13:25, Javier Martínez-López <
> > javier.marti...@bc3research.org> escribió:
> >
> >> Yo utilizo este script, done 'DataFrame' es el df que quieres guardar:
> >>
> >> library(XLConnect)
> >>
> >> fileXls <- "newFile.xlsx"
> >> unlink(fileXls, recursive = FALSE, force = FALSE)
> >> exc <- loadWorkbook(fileXls, create = TRUE)
> >> createSheet(exc,'Data')
> >> saveWorkbook(exc)
> >> writeWorksheet(exc, DataFrame, sheet = "Data", startRow = 1, startCol =
> 1)
> >> saveWorkbook(exc)
> >>
> >> Saludos,
> >>
> >> Javier
> >>
> >> 2016-07-26 12:52 GMT+02:00 Isidro Hidalgo Arellano :
> >>
> >>> Te recomiendo el paquete "openxlsx". Verás que es muy sencillo de
> >>> utilizar.
> >>> En la página "
> >>> https://cran.r-project.org/web/packages/openxlsx/index.html;
> >>> tienes las vignettes, los ejemplos son instantáneos:
> >>>
> >>>
> https://cran.r-project.org/web/packages/openxlsx/vignettes/Introduction.pdf
> >>> Un saludo
> >>>
> >>> Isidro Hidalgo Arellano
> >>> Observatorio del Mercado de Trabajo
> >>> Consejería de Economía, Empresas y Empleo
> >>> http://www.castillalamancha.es/
> >>>
> >>>
> >>>
> >>> -Mensaje original-
> >>> De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de
> >>> Alexa
> >>> Aristizabal
> >>> Enviado el: martes, 26 de julio de 2016 12:22
> >>> Para: r-help-es@r-project.org
> >>> Asunto: [R-es] Exportar datos en formato de Excel
> >>>
> >>> Buenos días a todos!
> >>>
> >>> Estoy trabajando con una base de datos que directamente he descargado
> de
> >>> internet y después de prepararla un poco necesito exportarla a Excel he
> >>> intentando con las dos opciones que mencionaré al final pero ninguna
> >>> funciona, de qué otra manera puedo exportar esos datos a Excel...
> muchas
> >>> gracias por su ayuda y pronta respuesta!
> >>>
> >>> 1)
> >>>
> >>> library(xlsx)
> >>> library(rJava)
> >>> library(xlsxjars)
> >>> write.xlsx(mydata, file="mydata.xlsx")
> >>>
> >>> 2)
> >>>
> >>> library(xlsReadWrite) #abrimos el paquete write.xls(prueba,
> >>> file="datanueva.xls",sheet="lapop10")
> >>>
> >>> [[alternative HTML version deleted]]
> >>>
> >>> ___
> >>> R-help-es mailing list
> >>> R-help-es@r-project.org
> >>> https://stat.ethz.ch/mailman/listinfo/r-help-es
> >>>
> >>> ___
> >>> R-help-es mailing list
> >>> R-help-es@r-project.org
> >>> https://stat.ethz.ch/mailman/listinfo/r-help-es
> >>>
> >>
> >>
> >>
> >> --
> >>
> >>
> >
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Mauricio

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Error when installing packages

2016-07-26 Thread Ulrik Stervbo
Hi Georg,

excel.link and installr: as far as I can tell from CRAN, excel.link and
installr are for windows OS only
1-5: you are installing packages that are wrappers to system
function/programms. They must be present on your system first.

2: Maybe Weka is missing in the path? Is your java excutable really at
'/usr/lib/jvm/default-java/jre/bin/java'. Maybe you need to tell R where to
find Java

I always install things like Rgraphviz from the ubuntu repository.

Hope this helps,
Ulrik


On Tue, 26 Jul 2016 at 16:09  wrote:

> Hi All,
>
> I try to install packages on Debian GNU Linux 8 (Kernel 3.16.0-4-amd64).
>
> My sessionInfo() is
>
> R version 3.3.1 (2016-06-21)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Debian GNU/Linux 8 (jessie)
>
> locale:
>  [1] LC_CTYPE=de_DE.UTF-8   LC_NUMERIC=C
>  [3] LC_TIME=de_DE.UTF-8LC_COLLATE=de_DE.UTF-8
>  [5] LC_MONETARY=de_DE.UTF-8LC_MESSAGES=de_DE.UTF-8
>  [7] LC_PAPER=de_DE.UTF-8   LC_NAME=C
>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
> [11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] tools_3.3.1
>
> Installing the following packages
>
> Warning in install.packages :
>   packages ‘excel.link’, ‘installr’ are not available (for R version 3.3.1)
> Warning in install.packages :
>   dependencies ‘latticist’, ‘graph’, ‘RBGL’, ‘pkgDepTools’, ‘Rgraphviz’
> are not available
> also installing the dependencies ‘RCurl’, ‘RWekajars’
>
> results in the following messages:
>
> (1)
> * installing *source* package ‘RCurl’ ...
> checking for curl-config... no
> Cannot find curl-config
>
> (2)
> * installing *source* package ‘RWekajars’ ...
> ./configure: 1: ./configure: /usr/lib/jvm/default-java/jre/bin/java: not
> found
> ./configure: 50: test: -ge: unexpected operator
> ./configure: 51: test: -eq: unexpected operator
> Need at least Java version 1.6/6.0.
> ERROR: configuration failed for package ‘RWekajars’
>
> Annotation: I have openjdk-8-jre installed.
>
> (3)
> * installing *source* package ‘cairoDevice’ ...
> ERROR: gtk+2. not found by pkg-config.
> ERROR: configuration failed for package ‘cairoDevice’
>
> (4)
> * installing *source* package ‘rgdal’ ...
> configure: CC: gcc -std=gnu99
> configure: CXX: g++
> configure: rgdal: 1.1-10
> checking for /usr/bin/svnversion... no
> configure: svn revision: 622
> checking for gdal-config... no
> no
> configure: error: gdal-config not found or not executable.
> ERROR: configuration failed for package ‘rgdal’
>
> (5)
> * installing *source* package ‘rgeos’ ...
> configure: CC: gcc -std=gnu99
> configure: CXX: g++
> configure: rgeos: 0.3-19
> checking for /usr/bin/svnversion... no
> configure: svn revision: 524
> checking for geos-config... no
> no
> configure: error: geos-config not found or not executable.
> ERROR: configuration failed for package ‘rgeos’
>
> ... and much more.
>
> Do all these error messages have something in common?
>
> How could I fix the installation?
>
> Kind regards
>
> Georg
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

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

Re: [R] Date Time in R

2016-07-26 Thread David L Carlson
What does this produce?

> readLines("YourCSVfilename.csv", n=5)

If the data are in Excel, the date format used in .csv files is not always in 
the same as the format used when viewing dates in the spreadsheet.

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


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi Bhatia
Sent: Tuesday, July 26, 2016 7:42 AM
To: Marc Schwartz
Cc: R-help
Subject: Re: [R] Date Time in R

Thanks Marc for the help. this really helps.
I think there is some issue with the data saved in csv format for this
variable as when i checked:
str(eir$date)- this results in :-
Date[1:5327], format: NA NA NA NA NA.

Thanks again.

On Tue, Jul 26, 2016 at 5:58 PM, Marc Schwartz  wrote:

> Hi,
>
> That eir$date might be a factor is irrelevant. There is an as.Date()
> method for factors, which does the factor to character coercion internally
> and then calls as.Date.character() on the result.
>
> Using the example data below:
>
> eir <- data.frame(date = c("05-30-16", "05-30-16", "05-30-16",
>"05-30-16", "05-30-16", "05-30-16"))
>
> > str(eir)
> 'data.frame':   6 obs. of  1 variable:
>  $ date: Factor w/ 1 level "05-30-16": 1 1 1 1 1 1
>
> > eir
>   date
> 1 05-30-16
> 2 05-30-16
> 3 05-30-16
> 4 05-30-16
> 5 05-30-16
> 6 05-30-16
>
> eir$date <- as.Date(eir$date, format = "%m-%d-%y")
>
> > str(eir)
> 'data.frame':   6 obs. of  1 variable:
>  $ date: Date, format: "2016-05-30" ...
>
> > eir
> date
> 1 2016-05-30
> 2 2016-05-30
> 3 2016-05-30
> 4 2016-05-30
> 5 2016-05-30
> 6 2016-05-30
>
> eir$days <- weekdays(eir$date)
>
> > str(eir)
> 'data.frame':   6 obs. of  2 variables:
>  $ date: Date, format: "2016-05-30" ...
>  $ days: chr  "Monday" "Monday" "Monday" "Monday" ...
>
> > eir
> date   days
> 1 2016-05-30 Monday
> 2 2016-05-30 Monday
> 3 2016-05-30 Monday
> 4 2016-05-30 Monday
> 5 2016-05-30 Monday
> 6 2016-05-30 Monday
>
>
> I would check to be sure that you do not have any typos in your code.
>
> Regards,
>
> Marc Schwartz
>
>
> > On Jul 26, 2016, at 6:58 AM, Shivi Bhatia  wrote:
> >
> > Hello Again,
> >
> > While i tried your solution as you suggested above it seems to be
> working.
> > Here is the output
> > temp<- dput(head(eir$date))
> > c("05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16")
> > however it still shows class(eir$date) as character and hence i cannot
> find
> > weekdays from this variable.
> >
> > Sorry but i still dont understand in totality how R reads dates even
> though
> > have tried enough.
> >
> > Regards, Shivi
> >
> >
> > On Tue, Jul 26, 2016 at 5:12 PM, Shivi Bhatia 
> wrote:
> >
> >> Thanks Duncan for the quick response. I will check again as you
> suggested.
> >> If that doesn't work i will share a reproducible example.
> >>
> >> Thanks again
> >>
> >> On Tue, Jul 26, 2016 at 4:43 PM, Duncan Murdoch <
> murdoch.dun...@gmail.com>
> >> wrote:
> >>
> >>> On 26/07/2016 7:05 AM, Shivi Bhatia wrote:
> >>>
>  Hi Team,
> 
>  This scenario may have come across a number of times however i checked
>  nabble & SO and couldn't find a solution hence request assistance.
> 
>  I have a date variable in my data-set eir. The class of this var was
>  character while i had read the file in r studio. Example of date -
>  05-30-16
> 
>  To change this i have used eir$date<- as.Date(eir$date, "%m-%d-%y").
> This
>  converts it to a date variable. However when i check few obs
>  with head(eir$date) all the results are .
> 
> >>>
> >>> I think you don't have character data like that, because I see
> >>>
>  as.Date("05-30-16", "%m-%d-%y")
> >>> [1] "2016-05-30"
> >>>
> >>> I'd guess eir$date is really a factor, because character data is
> >>> frequently changed to factor automatically.  If that's the case, this
> >>> should work for the conversion:
> >>>
> >>> as.Date(as.character(eir$date), "%m-%d-%y")
> >>>
> >>> If that doesn't work, you'll need to post something reproducible.
> >>>
> >>> Duncan Murdoch
> >>>
> >>> I also need to create weekdays from this date variable but until i get
>  this
>  resolved i cant find a weekday. For weekday i have used:
>  eir$week<- (eir$date)
>  eir$week<- weekdays(as.Date(eir$week))
>  class(eir$week)
>  eir$week<- as.factor(eir$week)
>  head(eir$week)
> 
>  Head of this eir$week results again as expected in  but shows
> Levels:
>  Friday Monday Saturday Sunday Thursday Tuesday Wednesday
> 
>  Not sure what i should do here. Kindly suggest.
>
>

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

Re: [R] word stemming for corpus linguistics

2016-07-26 Thread Andy Wolfe

Hi

Thanks for following up on this thread.

I've opted for this, albeit circuitous, route: use the tm package to 
stem the document and then use writeCorpus to write the stemmed document 
to disk, so that I can open it up and do the concordancing piece.


Many thanks - this'll do me fine until I come across a better (read, 
more elegant) solution.

Best
Andy


On 26/07/16 14:05, Paul Johnston wrote:

Hi

I use the tm_map() with stemDocument used as an argument

Looking at a particular file before stemming

writeLines(as.character(data_mined_volatile[[1]]))

## The European Union is a "force for social injustice" which backs "the haves 
rather than the have-nots", Iain Duncan Smith has said.
## The ex-work and pensions secretary said "uncontrolled migration" drove down 
wages and increased the cost of living.
## He appealed to people "who may have done OK from the EU" to "think about the 
people that haven't".
## But Labour's Alan Johnson said the EU protected workers and stopped them from being 
"exploited".
## The former Labour home secretary accused the Leave campaign of dismissing such 
protections as "red tape".
## In other EU referendum campaign developments:
## Thirteen former US secretaries of state and defence and national security advisers, including 
Madeleine Albright and Leon Panetta, say in a letter to the Times that the UK's "place and 
influence" in the world would be diminished if it left the EU - and Europe would be 
"dangerously weakened"
## A British Chambers of Commerce survey suggests most business people back 
Remain but the gap with those backing Leave has narrowed.
## Five former heads of Nato claimed the UK would lose influence and "give succour 
to its enemies" by leaving the EU - claims dismissed as scaremongering by Boris 
Johnson
## Mr Corbyn is launching his party's battle bus, saying Labour votes will be 
crucial if the Remain side is to win
## The official Scottish campaign to keep the UK in the European Union is due 
to be launched in Edinburgh
## Mr Duncan Smith's speech came after he told the Sun Germany had a "de facto veto" over 
David Cameron's EU renegotiations, with Angela Merkel blocking the PM's plans for an 
"emergency brake" on EU migration.
## Downing Street said curbs it negotiated on in-work benefits for EU migrants were a 
"more effective" way forward.
## Follow the latest developments on BBC EU referendum live
## Laura Kuenssberg: Can Leave win over the have-nots


Now look at the same text after stemming

corpus <- data_mined_volatile
corpus <- tm_map(corpus,stemDocument)

writeLines(as.character(corpus[[1]]))

## The European Union is a "forc for social injustice" which back "the have rather 
than the have-nots", Iain Duncan Smith has said.
## The ex-work and pension secretari said "uncontrol migration" drove down wage 
and increas the cost of living.
## He appeal to peopl "who may have done OK from the EU" to "think about the peopl 
that haven't".
## But Labour Alan Johnson said the EU protect worker and stop them from be 
"exploited".
## The former Labour home secretari accus the Leav campaign of dismiss such protect as 
"red tape".
2
## In other EU referendum campaign developments:
## Thirteen former US secretari of state and defenc and nation secur advisers, includ Madelein 
Albright and Leon Panetta, say in a letter to the Time that the UK "place and influence" 
in the world would be diminish if it left the EU - and Europ would be "danger weakened"
## A British Chamber of Commerc survey suggest most busi peopl back Remain but 
the gap with those back Leav has narrowed.
## Five former head of Nato claim the UK would lose influenc and "give succour to it 
enemies" by leav the EU - claim dismiss as scaremong by Bori Johnson
## Mr Corbyn is launch his parti battl bus, say Labour vote will be crucial if 
the Remain side is to win
## The offici Scottish campaign to keep the UK in the European Union is due to 
be launch in Edinburgh
## Mr Duncan Smith speech came after he told the Sun Germani had a "de facto veto" over 
David Cameron EU renegotiations, with Angela Merkel block the PM plan for an "emerg 
brake" on EU migration.
## Down Street said curb it negoti on in-work benefit for EU migrant were a "more 
effective" way forward.
## Follow the latest develop on BBC EU referendum live
## Laura Kuenssberg: Can Leav win over the have-not

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Andy Wolfe
Sent: 26 July 2016 09:14
To: r-help@r-project.org
Subject: Re: [R] word stemming for corpus linguistics

Hi Paul

I have seen this - it's part of the tm package mentioned originally. So, I've 
tried it again and perhaps I'm using stemDocument incorrectly, but this is what 
I am doing:

# > library(tm)
Loading required package: NLP
  > text.v <- scan(file.choose(), what = 'char', sep = '\n') Read 938 items # 
>text.stem.v <- stemDocument(text.v, language = 'english')

But it isn't changing anything in the body of the text 

Re: [R-es] Vision por computador

2016-07-26 Thread Fernando Fernández
Hola,

Llevo trabajando en este área los últimos dos años. C++ y Python son los
lenguajes más adecuados para trabajar con OpenCV y con CV en general (ojo,
digo en general, no digo que para imagen médica por ejemplo no pueda haber
cosas interesantes en R). Yo uso R para cosas puntuales como el análisis de
la precisión de determinados algoritmos, o pintar algunas gráficas
auxiliares, pero no para CV en sí. En Matlab también hay bastantes cosillas
pero más orientado a investigación. Si lo que buscas es algo para
producción C++ y Python son el camino. Lo que vas a encontrar en python en
realidad generalmente son wrappers a las librerías en C/C++, pero está muy
bien para montar flujos de trabajo rápidos siempre que no estés programando
tus propios algoritmos a bajo nivel (en cuyo caso es mejor irse a C++
directamente o combinar python y c++).

Nota: No siempre se hace "reconocimiento de patrones con redes neuronales".
Hay muchos problemas en visión artificial en los que el deep learning y las
redes neuronales todavía no son la mejor solución, lo que pasa es que en
los últimos años estos algoritmos han dado muy buenos resultados en algunos
de los problemas de CV, básicamente detección y clasificación de objetos y
parece que hay que usarlos para todo... Empieza por lo básico, y acabarás
llegando a Caffe, TensorFlow y compañía.


El 25 de julio de 2016, 15:23, Javier Marcuzzi <
javier.ruben.marcu...@gmail.com> escribió:

> Estimado Carlos Agüero
>
> Opencv es c++, tiene una cantidad de filtros como ser pasar la imagen a
> escala de grises, cambiar el contraste, etc. Luego hace un reconocimiento
> de patrones con redes neuronales.
>
> Si quieres aprender la parte informática de como se escribe el algoritmo
> para utilizar luego en el reconocimiento de imágenes, puede ser que R sea
> útil, pero si quiere reconocer imágenes hasta donde yo se lo importante es
> el entrenamiento, es decir varios filtros con los valores correctos que
> ingresan a la red neuronal y como resultado compara los patrones y reconoce
> o no una imagen. Para eso hay que encontrar un software que facilite, por
> ejemplo ir cambiando la saturación y ver en pantalla el cambio en la
> imagen, luego otro filtro y ver en pantalla el cambio de ambos, una vez
> finalizado obtener los filtros y valores para poder usarlos en la red
> neuronal y realizar el reconocimiento.
>
> Para esto una empresa ofrece un software para open cv, pero la versión
> libre no guarda y la comercial ni siquiera tiene el precio publicado.
>
> Hay una forma con r-opencv, pero nunca la exploré, si encuentras algo por
> ejemplo yo tomo 10 imágenes de bicicletas, las entreno (viendo visualmente
> los parámetros), y puedo reconocer las imágenes, avisa.
>
> Javier Rubén Marcuzzi
>
> De: Carlos Ortega
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] knitr package error.

2016-07-26 Thread Jeff Newmiller
The mailing list allows very few types of attachments through to limit virus 
problems. You need to learn how to convey your problem as a reproducible 
sequence of R statements to get clear assistance here. [1]

In this case,  you may be confused between the interactive working environment 
(variables) and the environment set up by knitr for generating the TeX 
document. You need to put every statement that is needed to create your 
variables in the knitr document, directly or by using the source or library 
functions. Variables you create interactively are not available to knitr. This 
is a key step to making your documents reproducible, much like your example 
code you should be sending here with your questions. 

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

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

On July 26, 2016 1:27:49 AM PDT, Shadrack Magut  
wrote:
>hello, someone help me sort out this error "## Error in summary(data):
>object ’analysis’ not found"" in using Knitr package in R. I imported
>the
>data into R studio but as soon as i use any code involving the data i
>imported in the Knitr environment within the latex document i encounter
>the
>above error.Kindly help me sort out this error.
>
>Attached to this mail is a word document containing the screenshot of
>my R
>codes and output error.
>
>Regards
>shadrack.
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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

[R] change the colour line in gamm4 plotting

2016-07-26 Thread Maria Lathouri via R-help
Dear all 

I am stuck probably in a simple plotting question

My model is:model.1<-gamm4(y~s(x1, by=end.group)+Year+K1+k2+k3, data=.., 
random=~(1|WB_ID/Site_ID))
where y is my dependent variable, x1 is the smooth covariate and I use the by 
argument for the smooth term based on six different groups, and then the Year, 
k1, k2, k3 are explanatory fixed variables

I use the plot command to plot the model and I get six different 
plots:plot(model.1$gam, pages=1, xlab=" ", ylab=" ")
I would like to change the colour of the fitted and the standard error lines, 
from black which is the default to another colour; I tried to use the col=" " 
function, at least for the main line, in the plot command but it is not 
working. 

Any advice/suggestion is welcome.
Many thanks.Maria

[[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] Error when installing packages

2016-07-26 Thread G . Maubach
Hi All,

I try to install packages on Debian GNU Linux 8 (Kernel 3.16.0-4-amd64).

My sessionInfo() is

R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 8 (jessie)

locale:
 [1] LC_CTYPE=de_DE.UTF-8   LC_NUMERIC=C  
 [3] LC_TIME=de_DE.UTF-8LC_COLLATE=de_DE.UTF-8
 [5] LC_MONETARY=de_DE.UTF-8LC_MESSAGES=de_DE.UTF-8   
 [7] LC_PAPER=de_DE.UTF-8   LC_NAME=C 
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base 

loaded via a namespace (and not attached):
[1] tools_3.3.1

Installing the following packages

Warning in install.packages :
  packages ‘excel.link’, ‘installr’ are not available (for R version 3.3.1)
Warning in install.packages :
  dependencies ‘latticist’, ‘graph’, ‘RBGL’, ‘pkgDepTools’, ‘Rgraphviz’ are not 
available
also installing the dependencies ‘RCurl’, ‘RWekajars’

results in the following messages:

(1)
* installing *source* package ‘RCurl’ ...
checking for curl-config... no
Cannot find curl-config

(2)
* installing *source* package ‘RWekajars’ ...
./configure: 1: ./configure: /usr/lib/jvm/default-java/jre/bin/java: not found
./configure: 50: test: -ge: unexpected operator
./configure: 51: test: -eq: unexpected operator
Need at least Java version 1.6/6.0.
ERROR: configuration failed for package ‘RWekajars’

Annotation: I have openjdk-8-jre installed.

(3)
* installing *source* package ‘cairoDevice’ ...
ERROR: gtk+2. not found by pkg-config.
ERROR: configuration failed for package ‘cairoDevice’

(4)
* installing *source* package ‘rgdal’ ...
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgdal: 1.1-10
checking for /usr/bin/svnversion... no
configure: svn revision: 622
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘rgdal’

(5)
* installing *source* package ‘rgeos’ ...
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgeos: 0.3-19
checking for /usr/bin/svnversion... no
configure: svn revision: 524
checking for geos-config... no
no
configure: error: geos-config not found or not executable.
ERROR: configuration failed for package ‘rgeos’

... and much more.

Do all these error messages have something in common?

How could I fix the installation?

Kind regards

Georg

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] word stemming for corpus linguistics

2016-07-26 Thread Paul Johnston

Hi

I use the tm_map() with stemDocument used as an argument

Looking at a particular file before stemming

writeLines(as.character(data_mined_volatile[[1]]))

## The European Union is a "force for social injustice" which backs "the haves 
rather than the have-nots", Iain Duncan Smith has said.
## The ex-work and pensions secretary said "uncontrolled migration" drove down 
wages and increased the cost of living.
## He appealed to people "who may have done OK from the EU" to "think about the 
people that haven't".
## But Labour's Alan Johnson said the EU protected workers and stopped them 
from being "exploited".
## The former Labour home secretary accused the Leave campaign of dismissing 
such protections as "red tape".
## In other EU referendum campaign developments:
## Thirteen former US secretaries of state and defence and national security 
advisers, including Madeleine Albright and Leon Panetta, say in a letter to the 
Times that the UK's "place and influence" in the world would be diminished if 
it left the EU - and Europe would be "dangerously weakened"
## A British Chambers of Commerce survey suggests most business people back 
Remain but the gap with those backing Leave has narrowed.
## Five former heads of Nato claimed the UK would lose influence and "give 
succour to its enemies" by leaving the EU - claims dismissed as scaremongering 
by Boris Johnson
## Mr Corbyn is launching his party's battle bus, saying Labour votes will be 
crucial if the Remain side is to win
## The official Scottish campaign to keep the UK in the European Union is due 
to be launched in Edinburgh
## Mr Duncan Smith's speech came after he told the Sun Germany had a "de facto 
veto" over David Cameron's EU renegotiations, with Angela Merkel blocking the 
PM's plans for an "emergency brake" on EU migration.
## Downing Street said curbs it negotiated on in-work benefits for EU migrants 
were a "more effective" way forward.
## Follow the latest developments on BBC EU referendum live
## Laura Kuenssberg: Can Leave win over the have-nots


Now look at the same text after stemming

corpus <- data_mined_volatile
corpus <- tm_map(corpus,stemDocument)

writeLines(as.character(corpus[[1]]))

## The European Union is a "forc for social injustice" which back "the have 
rather than the have-nots", Iain Duncan Smith has said.
## The ex-work and pension secretari said "uncontrol migration" drove down wage 
and increas the cost of living.
## He appeal to peopl "who may have done OK from the EU" to "think about the 
peopl that haven't".
## But Labour Alan Johnson said the EU protect worker and stop them from be 
"exploited".
## The former Labour home secretari accus the Leav campaign of dismiss such 
protect as "red tape".
2
## In other EU referendum campaign developments:
## Thirteen former US secretari of state and defenc and nation secur advisers, 
includ Madelein Albright and Leon Panetta, say in a letter to the Time that the 
UK "place and influence" in the world would be diminish if it left the EU - and 
Europ would be "danger weakened"
## A British Chamber of Commerc survey suggest most busi peopl back Remain but 
the gap with those back Leav has narrowed.
## Five former head of Nato claim the UK would lose influenc and "give succour 
to it enemies" by leav the EU - claim dismiss as scaremong by Bori Johnson
## Mr Corbyn is launch his parti battl bus, say Labour vote will be crucial if 
the Remain side is to win
## The offici Scottish campaign to keep the UK in the European Union is due to 
be launch in Edinburgh
## Mr Duncan Smith speech came after he told the Sun Germani had a "de facto 
veto" over David Cameron EU renegotiations, with Angela Merkel block the PM 
plan for an "emerg brake" on EU migration.
## Down Street said curb it negoti on in-work benefit for EU migrant were a 
"more effective" way forward.
## Follow the latest develop on BBC EU referendum live
## Laura Kuenssberg: Can Leav win over the have-not

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Andy Wolfe
Sent: 26 July 2016 09:14
To: r-help@r-project.org
Subject: Re: [R] word stemming for corpus linguistics

Hi Paul

I have seen this - it's part of the tm package mentioned originally. So, I've 
tried it again and perhaps I'm using stemDocument incorrectly, but this is what 
I am doing:

# > library(tm)
Loading required package: NLP
 > text.v <- scan(file.choose(), what = 'char', sep = '\n') Read 938 items # 
 > >text.stem.v <- stemDocument(text.v, language = 'english')

But it isn't changing anything in the body of the text I'm passing to it
- the words are unlemmatized/ unstemmed.

When I try using SnowballC, the error returned is that tm_map doesn't have a 
method to work with objects of class 'character'.

Again, the problem is that tm doesn't seem to allow for concordance analysis 
... or perhaps it does and I just haven't figured out how to do it, so am happy 
to be shown some documentation on that process, and 

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Thanks Marc for the help. this really helps.
I think there is some issue with the data saved in csv format for this
variable as when i checked:
str(eir$date)- this results in :-
Date[1:5327], format: NA NA NA NA NA.

Thanks again.

On Tue, Jul 26, 2016 at 5:58 PM, Marc Schwartz  wrote:

> Hi,
>
> That eir$date might be a factor is irrelevant. There is an as.Date()
> method for factors, which does the factor to character coercion internally
> and then calls as.Date.character() on the result.
>
> Using the example data below:
>
> eir <- data.frame(date = c("05-30-16", "05-30-16", "05-30-16",
>"05-30-16", "05-30-16", "05-30-16"))
>
> > str(eir)
> 'data.frame':   6 obs. of  1 variable:
>  $ date: Factor w/ 1 level "05-30-16": 1 1 1 1 1 1
>
> > eir
>   date
> 1 05-30-16
> 2 05-30-16
> 3 05-30-16
> 4 05-30-16
> 5 05-30-16
> 6 05-30-16
>
> eir$date <- as.Date(eir$date, format = "%m-%d-%y")
>
> > str(eir)
> 'data.frame':   6 obs. of  1 variable:
>  $ date: Date, format: "2016-05-30" ...
>
> > eir
> date
> 1 2016-05-30
> 2 2016-05-30
> 3 2016-05-30
> 4 2016-05-30
> 5 2016-05-30
> 6 2016-05-30
>
> eir$days <- weekdays(eir$date)
>
> > str(eir)
> 'data.frame':   6 obs. of  2 variables:
>  $ date: Date, format: "2016-05-30" ...
>  $ days: chr  "Monday" "Monday" "Monday" "Monday" ...
>
> > eir
> date   days
> 1 2016-05-30 Monday
> 2 2016-05-30 Monday
> 3 2016-05-30 Monday
> 4 2016-05-30 Monday
> 5 2016-05-30 Monday
> 6 2016-05-30 Monday
>
>
> I would check to be sure that you do not have any typos in your code.
>
> Regards,
>
> Marc Schwartz
>
>
> > On Jul 26, 2016, at 6:58 AM, Shivi Bhatia  wrote:
> >
> > Hello Again,
> >
> > While i tried your solution as you suggested above it seems to be
> working.
> > Here is the output
> > temp<- dput(head(eir$date))
> > c("05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16")
> > however it still shows class(eir$date) as character and hence i cannot
> find
> > weekdays from this variable.
> >
> > Sorry but i still dont understand in totality how R reads dates even
> though
> > have tried enough.
> >
> > Regards, Shivi
> >
> >
> > On Tue, Jul 26, 2016 at 5:12 PM, Shivi Bhatia 
> wrote:
> >
> >> Thanks Duncan for the quick response. I will check again as you
> suggested.
> >> If that doesn't work i will share a reproducible example.
> >>
> >> Thanks again
> >>
> >> On Tue, Jul 26, 2016 at 4:43 PM, Duncan Murdoch <
> murdoch.dun...@gmail.com>
> >> wrote:
> >>
> >>> On 26/07/2016 7:05 AM, Shivi Bhatia wrote:
> >>>
>  Hi Team,
> 
>  This scenario may have come across a number of times however i checked
>  nabble & SO and couldn't find a solution hence request assistance.
> 
>  I have a date variable in my data-set eir. The class of this var was
>  character while i had read the file in r studio. Example of date -
>  05-30-16
> 
>  To change this i have used eir$date<- as.Date(eir$date, "%m-%d-%y").
> This
>  converts it to a date variable. However when i check few obs
>  with head(eir$date) all the results are .
> 
> >>>
> >>> I think you don't have character data like that, because I see
> >>>
>  as.Date("05-30-16", "%m-%d-%y")
> >>> [1] "2016-05-30"
> >>>
> >>> I'd guess eir$date is really a factor, because character data is
> >>> frequently changed to factor automatically.  If that's the case, this
> >>> should work for the conversion:
> >>>
> >>> as.Date(as.character(eir$date), "%m-%d-%y")
> >>>
> >>> If that doesn't work, you'll need to post something reproducible.
> >>>
> >>> Duncan Murdoch
> >>>
> >>> I also need to create weekdays from this date variable but until i get
>  this
>  resolved i cant find a weekday. For weekday i have used:
>  eir$week<- (eir$date)
>  eir$week<- weekdays(as.Date(eir$week))
>  class(eir$week)
>  eir$week<- as.factor(eir$week)
>  head(eir$week)
> 
>  Head of this eir$week results again as expected in  but shows
> Levels:
>  Friday Monday Saturday Sunday Thursday Tuesday Wednesday
> 
>  Not sure what i should do here. Kindly suggest.
>
>

[[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] Date Time in R

2016-07-26 Thread Marc Schwartz
Hi, 

That eir$date might be a factor is irrelevant. There is an as.Date() method for 
factors, which does the factor to character coercion internally and then calls 
as.Date.character() on the result.

Using the example data below:

eir <- data.frame(date = c("05-30-16", "05-30-16", "05-30-16", 
   "05-30-16", "05-30-16", "05-30-16"))

> str(eir)
'data.frame':   6 obs. of  1 variable:
 $ date: Factor w/ 1 level "05-30-16": 1 1 1 1 1 1

> eir
  date
1 05-30-16
2 05-30-16
3 05-30-16
4 05-30-16
5 05-30-16
6 05-30-16

eir$date <- as.Date(eir$date, format = "%m-%d-%y")

> str(eir)
'data.frame':   6 obs. of  1 variable:
 $ date: Date, format: "2016-05-30" ...

> eir
date
1 2016-05-30
2 2016-05-30
3 2016-05-30
4 2016-05-30
5 2016-05-30
6 2016-05-30

eir$days <- weekdays(eir$date)

> str(eir)
'data.frame':   6 obs. of  2 variables:
 $ date: Date, format: "2016-05-30" ...
 $ days: chr  "Monday" "Monday" "Monday" "Monday" ...

> eir
date   days
1 2016-05-30 Monday
2 2016-05-30 Monday
3 2016-05-30 Monday
4 2016-05-30 Monday
5 2016-05-30 Monday
6 2016-05-30 Monday


I would check to be sure that you do not have any typos in your code.

Regards,

Marc Schwartz


> On Jul 26, 2016, at 6:58 AM, Shivi Bhatia  wrote:
> 
> Hello Again,
> 
> While i tried your solution as you suggested above it seems to be working.
> Here is the output
> temp<- dput(head(eir$date))
> c("05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16")
> however it still shows class(eir$date) as character and hence i cannot find
> weekdays from this variable.
> 
> Sorry but i still dont understand in totality how R reads dates even though
> have tried enough.
> 
> Regards, Shivi
> 
> 
> On Tue, Jul 26, 2016 at 5:12 PM, Shivi Bhatia  wrote:
> 
>> Thanks Duncan for the quick response. I will check again as you suggested.
>> If that doesn't work i will share a reproducible example.
>> 
>> Thanks again
>> 
>> On Tue, Jul 26, 2016 at 4:43 PM, Duncan Murdoch 
>> wrote:
>> 
>>> On 26/07/2016 7:05 AM, Shivi Bhatia wrote:
>>> 
 Hi Team,
 
 This scenario may have come across a number of times however i checked
 nabble & SO and couldn't find a solution hence request assistance.
 
 I have a date variable in my data-set eir. The class of this var was
 character while i had read the file in r studio. Example of date -
 05-30-16
 
 To change this i have used eir$date<- as.Date(eir$date, "%m-%d-%y"). This
 converts it to a date variable. However when i check few obs
 with head(eir$date) all the results are .
 
>>> 
>>> I think you don't have character data like that, because I see
>>> 
 as.Date("05-30-16", "%m-%d-%y")
>>> [1] "2016-05-30"
>>> 
>>> I'd guess eir$date is really a factor, because character data is
>>> frequently changed to factor automatically.  If that's the case, this
>>> should work for the conversion:
>>> 
>>> as.Date(as.character(eir$date), "%m-%d-%y")
>>> 
>>> If that doesn't work, you'll need to post something reproducible.
>>> 
>>> Duncan Murdoch
>>> 
>>> I also need to create weekdays from this date variable but until i get
 this
 resolved i cant find a weekday. For weekday i have used:
 eir$week<- (eir$date)
 eir$week<- weekdays(as.Date(eir$week))
 class(eir$week)
 eir$week<- as.factor(eir$week)
 head(eir$week)
 
 Head of this eir$week results again as expected in  but shows Levels:
 Friday Monday Saturday Sunday Thursday Tuesday Wednesday
 
 Not sure what i should do here. Kindly suggest.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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-es] Exportar datos en formato de Excel

2016-07-26 Thread Javier Martínez-López
Yo utilizo este script, done 'DataFrame' es el df que quieres guardar:

library(XLConnect)

fileXls <- "newFile.xlsx"
unlink(fileXls, recursive = FALSE, force = FALSE)
exc <- loadWorkbook(fileXls, create = TRUE)
createSheet(exc,'Data')
saveWorkbook(exc)
writeWorksheet(exc, DataFrame, sheet = "Data", startRow = 1, startCol = 1)
saveWorkbook(exc)

Saludos,

Javier

2016-07-26 12:52 GMT+02:00 Isidro Hidalgo Arellano :

> Te recomiendo el paquete "openxlsx". Verás que es muy sencillo de utilizar.
> En la página "https://cran.r-project.org/web/packages/openxlsx/index.html;
> tienes las vignettes, los ejemplos son instantáneos:
> https://cran.r-project.org/web/packages/openxlsx/vignettes/Introduction.pdf
> Un saludo
>
> Isidro Hidalgo Arellano
> Observatorio del Mercado de Trabajo
> Consejería de Economía, Empresas y Empleo
> http://www.castillalamancha.es/
>
>
>
> -Mensaje original-
> De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de Alexa
> Aristizabal
> Enviado el: martes, 26 de julio de 2016 12:22
> Para: r-help-es@r-project.org
> Asunto: [R-es] Exportar datos en formato de Excel
>
> Buenos días a todos!
>
> Estoy trabajando con una base de datos que directamente he descargado de
> internet y después de prepararla un poco necesito exportarla a Excel he
> intentando con las dos opciones que mencionaré al final pero ninguna
> funciona, de qué otra manera puedo exportar esos datos a Excel... muchas
> gracias por su ayuda y pronta respuesta!
>
> 1)
>
> library(xlsx)
> library(rJava)
> library(xlsxjars)
> write.xlsx(mydata, file="mydata.xlsx")
>
> 2)
>
> library(xlsReadWrite) #abrimos el paquete write.xls(prueba,
> file="datanueva.xls",sheet="lapop10")
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Hello Again,

While i tried your solution as you suggested above it seems to be working.
Here is the output
temp<- dput(head(eir$date))
c("05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16")
however it still shows class(eir$date) as character and hence i cannot find
weekdays from this variable.

Sorry but i still dont understand in totality how R reads dates even though
have tried enough.

Regards, Shivi


On Tue, Jul 26, 2016 at 5:12 PM, Shivi Bhatia  wrote:

> Thanks Duncan for the quick response. I will check again as you suggested.
> If that doesn't work i will share a reproducible example.
>
> Thanks again
>
> On Tue, Jul 26, 2016 at 4:43 PM, Duncan Murdoch 
> wrote:
>
>> On 26/07/2016 7:05 AM, Shivi Bhatia wrote:
>>
>>> Hi Team,
>>>
>>> This scenario may have come across a number of times however i checked
>>> nabble & SO and couldn't find a solution hence request assistance.
>>>
>>> I have a date variable in my data-set eir. The class of this var was
>>> character while i had read the file in r studio. Example of date -
>>> 05-30-16
>>>
>>> To change this i have used eir$date<- as.Date(eir$date, "%m-%d-%y"). This
>>> converts it to a date variable. However when i check few obs
>>> with head(eir$date) all the results are .
>>>
>>
>> I think you don't have character data like that, because I see
>>
>> > as.Date("05-30-16", "%m-%d-%y")
>> [1] "2016-05-30"
>>
>> I'd guess eir$date is really a factor, because character data is
>> frequently changed to factor automatically.  If that's the case, this
>> should work for the conversion:
>>
>> as.Date(as.character(eir$date), "%m-%d-%y")
>>
>> If that doesn't work, you'll need to post something reproducible.
>>
>> Duncan Murdoch
>>
>> I also need to create weekdays from this date variable but until i get
>>> this
>>> resolved i cant find a weekday. For weekday i have used:
>>> eir$week<- (eir$date)
>>> eir$week<- weekdays(as.Date(eir$week))
>>> class(eir$week)
>>> eir$week<- as.factor(eir$week)
>>> head(eir$week)
>>>
>>> Head of this eir$week results again as expected in  but shows Levels:
>>> Friday Monday Saturday Sunday Thursday Tuesday Wednesday
>>>
>>> Not sure what i should do here. Kindly suggest.
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>>
>

[[alternative HTML version deleted]]

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


Re: [R] Visualization of a Convex Hull in R (Possibly with RGL)

2016-07-26 Thread Michael Sumner
On Tue, 26 Jul 2016 at 20:29 Lorenzo Isella 
wrote:

> Dear All,
> I am not an expert about the calculation and visualization of convex
> hulls, but I am trying to do something relatively simple.
> Please consider the snippet at the end of the email.
> The array pts  represents the position of (the centres of) a set of
> spheres in 3D (whose radius is 0.5).
> I found the geometry package which provides bindings to the qhull
> (http://www.qhull.org/) library and allows me to calculate the convex
> hull of pts and some interesting properties, like the area and the
> volume of the convex hull.
> That is all fine, but I would like to represent the results in 3D.
> I would like to see a set of spheres with the given position in pts
> and the radius R=0.5 and the convex hull going based on the
> coordinates of pts.
> Does anybody know how to achieve that?
> Many thanks
>
> Lorenzo
>
>
>
> 
>
>
> library(geometry)
>
>
>
> pts <- read.table("test-agg.dat")
>
> ## names(pts) <- c("x", "y", "z")
>
>
> pts <- structure(list(x = c(0.145138112090815, 0.880429452229448,
> -1.66682740805663,
> -0.955356943224252, 1.09396798448412, -2.63620653885452,
> 0.190270563436841,
> 2.77638842095489, -0.0914977922901252, -0.484087722062158,
> 0.674992784754569,
> 1.02571108118502, 2.78789154912298, -0.146882388586427,
> -1.71507089246001,
> -1.87886026272455, 6.61540228778138, 7.46818822627362,
> 4.80777628045963,
> 6.35487269602107, 4.70026626314108, 3.44366671298125,
> 2.92460648354883,
> 5.07053866161192, 7.2164343710271, 6.93292242981006, 7.84238243682145,
> 7.4321237311656, 9.59692827237335, 8.3454086671306, 6.574251622581,
> 6.93340304175759), y = c(-0.189309482569001, 1.67057595730283,
> -0.995542605143325, 2.31599069771684, 1.79876139786291,
> 0.165886909346058,
> 2.70740725397259, 1.70535678189514, -0.819087329147786,
> 0.967935667739331,
> -2.53860079551206, -1.60932884056828, -1.42050583991613,
> -2.36883245674979,
> 0.191848867151458, -1.58255618338079, 1.98324724741419,
> 3.0095048680572,
> 1.97159273200079, 2.26459561200295, 0.4461804374566, 1.87939977307282,
> 1.98510457359889, -0.103495422088799, -1.32050185858493,
> 0.584580736435273,
> -2.97562362406436, 0.10620417814, -2.0843758994948,
> -1.1492729389287,
> -2.13797391772643, -4.45916649729404), z = c(-1.44428170702261,
> -1.45742688370091, -1.70267889327056, -1.93637881287001,
> -3.4452409532781,
> -3.02436538816822, 0.114790290814684, -2.10208878117278,
> 2.07425243689128,
> 1.26652602551291, 1.39914827137784, -0.345006925422662,
> 0.596828021941431,
> 3.351773622867, 2.68408561840144, 3.97006405709929, 0.82767367646934,
> -0.662142231346811, 1.68344957582882, 2.92819854377685,
> 0.386683699222387,
> -0.220305098209874, 2.37510769001993, -1.51041233970289,
> -0.707073219742548,
> -1.24585080403725, -1.63914669343685, 0.683153891726357,
> -1.26623658129696,
> 1.95073173465968, -2.94804638502708, -0.635785458903106)), .Names =
> c("x",
> "y", "z"), class = "data.frame", row.names = c(NA, -32L))
>
> res<-convhulln(pts, options = "FA")
>
>
In short

library(rgl)
bg3d("grey")
spheres3d(pts, radius = 0.5, col = "white")
## triangle functions generally expect triplets of points, one after another
## and hull/triangulation functions generally return arrays of indexes
## so transpose index of hull is the right order to draw triangles
triangles3d(pts[t(res$hull), ], col = "firebrick", alpha = 0.3)

(But, I wonder if you mean to find the convex hull based on the outer shell
of those spheres? )

Cheers, Mike.



> print("So far so good")
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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.


Re: [R-es] Exportar datos en formato de Excel

2016-07-26 Thread Javier Martínez-López
que raro... se te ha instalado bien la librería? tiene pinta de un problema
de JAVA pero no sé cuál...

2016-07-26 13:46 GMT+02:00 Alexa Aristizabal 
:

> Hola Javier, de antemano muchas gracias por tu ayuda! :)
>
> He intentado replicar tu script pero sale el siguiente error:
>
> Error in .jarray(v) :
>   Java Exception .jarray(v) object of class "jobjRef">
> > saveWorkbook(exc)
> Error in .jcheck() :
>   Java Exception  failed>.jcall("RJavaTools", "Z", "hasMethod", .jcast(x,
> "java/lang/Object"), name)
>
> El 26 de julio de 2016, 13:25, Javier Martínez-López <
> javier.marti...@bc3research.org> escribió:
>
>> Yo utilizo este script, done 'DataFrame' es el df que quieres guardar:
>>
>> library(XLConnect)
>>
>> fileXls <- "newFile.xlsx"
>> unlink(fileXls, recursive = FALSE, force = FALSE)
>> exc <- loadWorkbook(fileXls, create = TRUE)
>> createSheet(exc,'Data')
>> saveWorkbook(exc)
>> writeWorksheet(exc, DataFrame, sheet = "Data", startRow = 1, startCol = 1)
>> saveWorkbook(exc)
>>
>> Saludos,
>>
>> Javier
>>
>> 2016-07-26 12:52 GMT+02:00 Isidro Hidalgo Arellano :
>>
>>> Te recomiendo el paquete "openxlsx". Verás que es muy sencillo de
>>> utilizar.
>>> En la página "
>>> https://cran.r-project.org/web/packages/openxlsx/index.html;
>>> tienes las vignettes, los ejemplos son instantáneos:
>>>
>>> https://cran.r-project.org/web/packages/openxlsx/vignettes/Introduction.pdf
>>> Un saludo
>>>
>>> Isidro Hidalgo Arellano
>>> Observatorio del Mercado de Trabajo
>>> Consejería de Economía, Empresas y Empleo
>>> http://www.castillalamancha.es/
>>>
>>>
>>>
>>> -Mensaje original-
>>> De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de
>>> Alexa
>>> Aristizabal
>>> Enviado el: martes, 26 de julio de 2016 12:22
>>> Para: r-help-es@r-project.org
>>> Asunto: [R-es] Exportar datos en formato de Excel
>>>
>>> Buenos días a todos!
>>>
>>> Estoy trabajando con una base de datos que directamente he descargado de
>>> internet y después de prepararla un poco necesito exportarla a Excel he
>>> intentando con las dos opciones que mencionaré al final pero ninguna
>>> funciona, de qué otra manera puedo exportar esos datos a Excel... muchas
>>> gracias por su ayuda y pronta respuesta!
>>>
>>> 1)
>>>
>>> library(xlsx)
>>> library(rJava)
>>> library(xlsxjars)
>>> write.xlsx(mydata, file="mydata.xlsx")
>>>
>>> 2)
>>>
>>> library(xlsReadWrite) #abrimos el paquete write.xls(prueba,
>>> file="datanueva.xls",sheet="lapop10")
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> ___
>>> R-help-es mailing list
>>> R-help-es@r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>>
>>> ___
>>> R-help-es mailing list
>>> R-help-es@r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>>
>>
>>
>>
>> --
>>
>>
>

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Thanks Duncan for the quick response. I will check again as you suggested.
If that doesn't work i will share a reproducible example.

Thanks again

On Tue, Jul 26, 2016 at 4:43 PM, Duncan Murdoch 
wrote:

> On 26/07/2016 7:05 AM, Shivi Bhatia wrote:
>
>> Hi Team,
>>
>> This scenario may have come across a number of times however i checked
>> nabble & SO and couldn't find a solution hence request assistance.
>>
>> I have a date variable in my data-set eir. The class of this var was
>> character while i had read the file in r studio. Example of date -
>> 05-30-16
>>
>> To change this i have used eir$date<- as.Date(eir$date, "%m-%d-%y"). This
>> converts it to a date variable. However when i check few obs
>> with head(eir$date) all the results are .
>>
>
> I think you don't have character data like that, because I see
>
> > as.Date("05-30-16", "%m-%d-%y")
> [1] "2016-05-30"
>
> I'd guess eir$date is really a factor, because character data is
> frequently changed to factor automatically.  If that's the case, this
> should work for the conversion:
>
> as.Date(as.character(eir$date), "%m-%d-%y")
>
> If that doesn't work, you'll need to post something reproducible.
>
> Duncan Murdoch
>
> I also need to create weekdays from this date variable but until i get this
>> resolved i cant find a weekday. For weekday i have used:
>> eir$week<- (eir$date)
>> eir$week<- weekdays(as.Date(eir$week))
>> class(eir$week)
>> eir$week<- as.factor(eir$week)
>> head(eir$week)
>>
>> Head of this eir$week results again as expected in  but shows Levels:
>> Friday Monday Saturday Sunday Thursday Tuesday Wednesday
>>
>> Not sure what i should do here. Kindly suggest.
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>

[[alternative HTML version deleted]]

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


Re: [R-es] Exportar datos en formato de Excel

2016-07-26 Thread Javier Martínez-López
Yo utilizo este script, done 'DataFrame' es el df que quieres guardar:

library(XLConnect)

fileXls <- "newFile.xlsx"
unlink(fileXls, recursive = FALSE, force = FALSE)
exc <- loadWorkbook(fileXls, create = TRUE)
createSheet(exc,'Data')
saveWorkbook(exc)
writeWorksheet(exc, DataFrame, sheet = "Data", startRow = 1, startCol = 1)
saveWorkbook(exc)

Saludos,

Javier

2016-07-26 12:52 GMT+02:00 Isidro Hidalgo Arellano :

> Te recomiendo el paquete "openxlsx". Verás que es muy sencillo de utilizar.
> En la página "https://cran.r-project.org/web/packages/openxlsx/index.html;
> tienes las vignettes, los ejemplos son instantáneos:
> https://cran.r-project.org/web/packages/openxlsx/vignettes/Introduction.pdf
> Un saludo
>
> Isidro Hidalgo Arellano
> Observatorio del Mercado de Trabajo
> Consejería de Economía, Empresas y Empleo
> http://www.castillalamancha.es/
>
>
>
> -Mensaje original-
> De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de Alexa
> Aristizabal
> Enviado el: martes, 26 de julio de 2016 12:22
> Para: r-help-es@r-project.org
> Asunto: [R-es] Exportar datos en formato de Excel
>
> Buenos días a todos!
>
> Estoy trabajando con una base de datos que directamente he descargado de
> internet y después de prepararla un poco necesito exportarla a Excel he
> intentando con las dos opciones que mencionaré al final pero ninguna
> funciona, de qué otra manera puedo exportar esos datos a Excel... muchas
> gracias por su ayuda y pronta respuesta!
>
> 1)
>
> library(xlsx)
> library(rJava)
> library(xlsxjars)
> write.xlsx(mydata, file="mydata.xlsx")
>
> 2)
>
> library(xlsReadWrite) #abrimos el paquete write.xls(prueba,
> file="datanueva.xls",sheet="lapop10")
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Date Time in R

2016-07-26 Thread Duncan Murdoch

On 26/07/2016 7:05 AM, Shivi Bhatia wrote:

Hi Team,

This scenario may have come across a number of times however i checked
nabble & SO and couldn't find a solution hence request assistance.

I have a date variable in my data-set eir. The class of this var was
character while i had read the file in r studio. Example of date - 05-30-16

To change this i have used eir$date<- as.Date(eir$date, "%m-%d-%y"). This
converts it to a date variable. However when i check few obs
with head(eir$date) all the results are .


I think you don't have character data like that, because I see

> as.Date("05-30-16", "%m-%d-%y")
[1] "2016-05-30"

I'd guess eir$date is really a factor, because character data is 
frequently changed to factor automatically.  If that's the case, this 
should work for the conversion:


as.Date(as.character(eir$date), "%m-%d-%y")

If that doesn't work, you'll need to post something reproducible.

Duncan Murdoch


I also need to create weekdays from this date variable but until i get this
resolved i cant find a weekday. For weekday i have used:
eir$week<- (eir$date)
eir$week<- weekdays(as.Date(eir$week))
class(eir$week)
eir$week<- as.factor(eir$week)
head(eir$week)

Head of this eir$week results again as expected in  but shows Levels:
Friday Monday Saturday Sunday Thursday Tuesday Wednesday

Not sure what i should do here. Kindly suggest.

[[alternative HTML version deleted]]

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



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


[R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Hi Team,

This scenario may have come across a number of times however i checked
nabble & SO and couldn't find a solution hence request assistance.

I have a date variable in my data-set eir. The class of this var was
character while i had read the file in r studio. Example of date - 05-30-16

To change this i have used eir$date<- as.Date(eir$date, "%m-%d-%y"). This
converts it to a date variable. However when i check few obs
with head(eir$date) all the results are .
I also need to create weekdays from this date variable but until i get this
resolved i cant find a weekday. For weekday i have used:
eir$week<- (eir$date)
eir$week<- weekdays(as.Date(eir$week))
class(eir$week)
eir$week<- as.factor(eir$week)
head(eir$week)

Head of this eir$week results again as expected in  but shows Levels:
Friday Monday Saturday Sunday Thursday Tuesday Wednesday

Not sure what i should do here. Kindly suggest.

[[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-es] Exportar datos en formato de Excel

2016-07-26 Thread Isidro Hidalgo Arellano
Te recomiendo el paquete "openxlsx". Verás que es muy sencillo de utilizar.
En la página "https://cran.r-project.org/web/packages/openxlsx/index.html;
tienes las vignettes, los ejemplos son instantáneos:
https://cran.r-project.org/web/packages/openxlsx/vignettes/Introduction.pdf
Un saludo

Isidro Hidalgo Arellano
Observatorio del Mercado de Trabajo
Consejería de Economía, Empresas y Empleo
http://www.castillalamancha.es/



-Mensaje original-
De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de Alexa
Aristizabal
Enviado el: martes, 26 de julio de 2016 12:22
Para: r-help-es@r-project.org
Asunto: [R-es] Exportar datos en formato de Excel

Buenos días a todos!

Estoy trabajando con una base de datos que directamente he descargado de
internet y después de prepararla un poco necesito exportarla a Excel he
intentando con las dos opciones que mencionaré al final pero ninguna
funciona, de qué otra manera puedo exportar esos datos a Excel... muchas
gracias por su ayuda y pronta respuesta!

1)

library(xlsx)
library(rJava)
library(xlsxjars)
write.xlsx(mydata, file="mydata.xlsx")

2)

library(xlsReadWrite) #abrimos el paquete write.xls(prueba,
file="datanueva.xls",sheet="lapop10")

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Exportar datos en formato de Excel

2016-07-26 Thread Carlos Ortega
Puedes utilizar esa alternativa con paquetes que conectan con "Excel" y
otra muy directa es exportar tu data.frame a un "csv" que directamente
puedes importar cómodamente en Excel...

Para hacer esto con la función "write()" y asociadas puedes hacerlo sin
problemas

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 26 de julio de 2016, 12:22, Alexa Aristizabal <
alexa.aristizaba...@gmail.com> escribió:

> Buenos días a todos!
>
> Estoy trabajando con una base de datos que directamente he descargado de
> internet y después de prepararla un poco necesito exportarla a Excel he
> intentando con las dos opciones que mencionaré al final pero ninguna
> funciona, de qué otra manera puedo exportar esos datos a Excel... muchas
> gracias por su ayuda y pronta respuesta!
>
> 1)
>
> library(xlsx)
> library(rJava)
> library(xlsxjars)
> write.xlsx(mydata, file="mydata.xlsx")
>
> 2)
>
> library(xlsReadWrite) #abrimos el paquete
> write.xls(prueba, file="datanueva.xls",sheet="lapop10")
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R] Visualization of a Convex Hull in R (Possibly with RGL)

2016-07-26 Thread Lorenzo Isella

Dear All,
I am not an expert about the calculation and visualization of convex
hulls, but I am trying to do something relatively simple.
Please consider the snippet at the end of the email.
The array pts  represents the position of (the centres of) a set of
spheres in 3D (whose radius is 0.5).
I found the geometry package which provides bindings to the qhull
(http://www.qhull.org/) library and allows me to calculate the convex
hull of pts and some interesting properties, like the area and the
volume of the convex hull.
That is all fine, but I would like to represent the results in 3D.
I would like to see a set of spheres with the given position in pts
and the radius R=0.5 and the convex hull going based on the
coordinates of pts.
Does anybody know how to achieve that?
Many thanks

Lorenzo






library(geometry)


pts <- structure(list(x = c(0.145138112090815, 0.880429452229448,
-1.66682740805663,
-0.955356943224252, 1.09396798448412, -2.63620653885452,
0.190270563436841,
2.77638842095489, -0.0914977922901252, -0.484087722062158,
0.674992784754569,
1.02571108118502, 2.78789154912298, -0.146882388586427,
-1.71507089246001,
-1.87886026272455, 6.61540228778138, 7.46818822627362,
4.80777628045963,
6.35487269602107, 4.70026626314108, 3.44366671298125,
2.92460648354883,
5.07053866161192, 7.2164343710271, 6.93292242981006, 7.84238243682145,
7.4321237311656, 9.59692827237335, 8.3454086671306, 6.574251622581,
6.93340304175759), y = c(-0.189309482569001, 1.67057595730283,
-0.995542605143325, 2.31599069771684, 1.79876139786291,
0.165886909346058,
2.70740725397259, 1.70535678189514, -0.819087329147786,
0.967935667739331,
-2.53860079551206, -1.60932884056828, -1.42050583991613,
-2.36883245674979,
0.191848867151458, -1.58255618338079, 1.98324724741419,
3.0095048680572,
1.97159273200079, 2.26459561200295, 0.4461804374566, 1.87939977307282,
1.98510457359889, -0.103495422088799, -1.32050185858493,
0.584580736435273,
-2.97562362406436, 0.10620417814, -2.0843758994948,
-1.1492729389287,
-2.13797391772643, -4.45916649729404), z = c(-1.44428170702261,
-1.45742688370091, -1.70267889327056, -1.93637881287001,
-3.4452409532781,
-3.02436538816822, 0.114790290814684, -2.10208878117278,
2.07425243689128,
1.26652602551291, 1.39914827137784, -0.345006925422662,
0.596828021941431,
3.351773622867, 2.68408561840144, 3.97006405709929, 0.82767367646934,
-0.662142231346811, 1.68344957582882, 2.92819854377685,
0.386683699222387,
-0.220305098209874, 2.37510769001993, -1.51041233970289,
-0.707073219742548,
-1.24585080403725, -1.63914669343685, 0.683153891726357,
-1.26623658129696,
1.95073173465968, -2.94804638502708, -0.635785458903106)), .Names =
c("x",
"y", "z"), class = "data.frame", row.names = c(NA, -32L))

res<-convhulln(pts, options = "FA")

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Visualization of a Convex Hull in R (Possibly with RGL)

2016-07-26 Thread Lorenzo Isella

Dear All,
I am not an expert about the calculation and visualization of convex
hulls, but I am trying to do something relatively simple.
Please consider the snippet at the end of the email.
The array pts  represents the position of (the centres of) a set of
spheres in 3D (whose radius is 0.5).
I found the geometry package which provides bindings to the qhull
(http://www.qhull.org/) library and allows me to calculate the convex
hull of pts and some interesting properties, like the area and the
volume of the convex hull.
That is all fine, but I would like to represent the results in 3D.
I would like to see a set of spheres with the given position in pts
and the radius R=0.5 and the convex hull going based on the
coordinates of pts.
Does anybody know how to achieve that?
Many thanks

Lorenzo






library(geometry)



pts <- read.table("test-agg.dat")

## names(pts) <- c("x", "y", "z")


pts <- structure(list(x = c(0.145138112090815, 0.880429452229448,
-1.66682740805663,
-0.955356943224252, 1.09396798448412, -2.63620653885452,
0.190270563436841,
2.77638842095489, -0.0914977922901252, -0.484087722062158,
0.674992784754569,
1.02571108118502, 2.78789154912298, -0.146882388586427,
-1.71507089246001,
-1.87886026272455, 6.61540228778138, 7.46818822627362,
4.80777628045963,
6.35487269602107, 4.70026626314108, 3.44366671298125,
2.92460648354883,
5.07053866161192, 7.2164343710271, 6.93292242981006, 7.84238243682145,
7.4321237311656, 9.59692827237335, 8.3454086671306, 6.574251622581,
6.93340304175759), y = c(-0.189309482569001, 1.67057595730283,
-0.995542605143325, 2.31599069771684, 1.79876139786291,
0.165886909346058,
2.70740725397259, 1.70535678189514, -0.819087329147786,
0.967935667739331,
-2.53860079551206, -1.60932884056828, -1.42050583991613,
-2.36883245674979,
0.191848867151458, -1.58255618338079, 1.98324724741419,
3.0095048680572,
1.97159273200079, 2.26459561200295, 0.4461804374566, 1.87939977307282,
1.98510457359889, -0.103495422088799, -1.32050185858493,
0.584580736435273,
-2.97562362406436, 0.10620417814, -2.0843758994948,
-1.1492729389287,
-2.13797391772643, -4.45916649729404), z = c(-1.44428170702261,
-1.45742688370091, -1.70267889327056, -1.93637881287001,
-3.4452409532781,
-3.02436538816822, 0.114790290814684, -2.10208878117278,
2.07425243689128,
1.26652602551291, 1.39914827137784, -0.345006925422662,
0.596828021941431,
3.351773622867, 2.68408561840144, 3.97006405709929, 0.82767367646934,
-0.662142231346811, 1.68344957582882, 2.92819854377685,
0.386683699222387,
-0.220305098209874, 2.37510769001993, -1.51041233970289,
-0.707073219742548,
-1.24585080403725, -1.63914669343685, 0.683153891726357,
-1.26623658129696,
1.95073173465968, -2.94804638502708, -0.635785458903106)), .Names =
c("x",
"y", "z"), class = "data.frame", row.names = c(NA, -32L))

res<-convhulln(pts, options = "FA")

print("So far so good")

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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-es] Exportar datos en formato de Excel

2016-07-26 Thread Alexa Aristizabal
Buenos días a todos!

Estoy trabajando con una base de datos que directamente he descargado de
internet y después de prepararla un poco necesito exportarla a Excel he
intentando con las dos opciones que mencionaré al final pero ninguna
funciona, de qué otra manera puedo exportar esos datos a Excel... muchas
gracias por su ayuda y pronta respuesta!

1)

library(xlsx)
library(rJava)
library(xlsxjars)
write.xlsx(mydata, file="mydata.xlsx")

2)

library(xlsReadWrite) #abrimos el paquete
write.xls(prueba, file="datanueva.xls",sheet="lapop10")

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] about netcdf files

2016-07-26 Thread Jon Skoien

You could try with the brick function from the raster package.

bvar = brick(netcdfName)

This uses the ncdf4 functions for opening and reading the netcdf, but 
makes it easier to extract data for each day:


p1 = rasterToPoints(bvar[[1]])
and write p1 to csv.

Best,
Jon


On 7/26/2016 6:54 AM, lily li wrote:

Hi all,

I have a problem in opening netcdf files. If one netcdf file contains
longitude, latitude, and daily precipitation. How to relate each
precipitation record to its associated location, and export them as csv
files? Thanks.

I just use nc_open(), ncvar_get(), but it is not very helpful. Thanks for
any ideas.

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



--
Jon Olav Skøien
Joint Research Centre - European Commission
Institute for Space, Security & Migration
Disaster Risk Management Unit

Via E. Fermi 2749, TP 122,  I-21027 Ispra (VA), ITALY

jon.sko...@jrc.ec.europa.eu
Tel:  +39 0332 789205

Disclaimer: Views expressed in this email are those of the individual 
and do not necessarily represent official views of the European Commission.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] knitr package error.

2016-07-26 Thread Shadrack Magut
hello, someone help me sort out this error "## Error in summary(data):
object ’analysis’ not found"" in using Knitr package in R. I imported the
data into R studio but as soon as i use any code involving the data i
imported in the Knitr environment within the latex document i encounter the
above error.Kindly help me sort out this error.

Attached to this mail is a word document containing the screenshot of my R
codes and output error.

Regards
shadrack.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] lm() silently drops NAs

2016-07-26 Thread Martin Maechler
I have been asked (in private)

> Hi Martin,

y <- c(1, 2, 3, NA, 4)
x <- c(1, 2, 2, 1, 1)

t.test(y ~ x)
lm(y ~ x)

> Normally, most R functions follow the principle that
> "missings should never silently go missing". Do you have
> any background on why these functions (and most model/test
> function in stats, I presume) silently drop missing values?

And I think, the issue and an answer are important enough to be
public, hence this posting to R-help :

First note that in some sense it is not true that lm(y ~ x) silently drops 
NAs: Everybody who is taught about lm() is taught to look at
   summary( fm )  where  fm <- lm(y ~ x)

and that (for the above case)  "says"

 ' (1 observation deleted due to missingness) '

and so is not entirely silent.


This goes all back to the idea of having an 'na.action' argument
which may be a function (a very good idea, "functional
programming" in a double sense!)... which Chambers et al
introduced in The White Book (*1) and which I think to remember 
was quite a revolutionary idea; at least I had liked that very much
once I understood the beauty of passing functions as arguments
to other functions.
One problem already back then has been that we already had the
---much more primitive but often sufficient--- standard of an
'na.rm = FALSE' (i.e. default FALSE) argument.

This has been tought in all good classes/course about statistical
modeling with S and R ever since ... I had hoped 
(but it seems I was too optimistic, .. or many students have too
 quickly forgotten what they were taught ..)
Notably the white book itself, and the MASS (*2) book do teach
this.. though possibly not loudly enough.

Two more decisions about this were made back then, as well:

  1) The default for na.action to be na.omit  (==> "silently dropping")

  2) na.action being governed by  options(na.action = ..)

'1)' may have been mostly "historical": I think it had been the behavior of
other "main stream" statistical packages back then (and now?) *and*
possibly more importantly, notably with the later (than white book = "S3")
advent of na.replace, you did want to keep the missing in your
data frame, for later analysis; e.g. drawing (-> "gaps" in
plots) so the NA *were* carried along and would not be
forgotten, something very important in most case.s.
   
and '2)' is something I personally no longer like very
much, as it is "killing" the functional paradigm.
OTOH, it has to be said in favor of that "session wide" / "global" setting
  options(na.action = *)
that indeed it depends on the specific data analysis, or even
the specific *phase* of a data analysis, *what* behavior of NA
treatment is desired and at the time it was thought smart
that all methods (also functions "deep down" called by
user-called functtions) would automatically use the "currently
desired" NA handling.

There have been recommendations (I don't know exactly where and
by whom) to always set

   options(na.action = na.fail)

in your global .First() or nowadays rather your  Rprofile, and
I assume that some of the CRAN packages and some of the "teaching
setups" would do that (and if you do that, the lm() and t.test()
calls above give an error). 

Of course, there's much more to say about this, quite a bit of which
has been published in scientific papers and books..

Martin Maechler
ETH Zurich and R Core Team



*1) "The White Book": Chambers and Hastie (1992):
 https://www.r-project.org/doc/bib/R-books_bib.html#R:Chambers+Hastie:1992

*2) "MASS - the book": Venables and Ripley (2002 (= 4th ed.)):
 https://www.r-project.org/doc/bib/R-books_bib.html#R:Venables+Ripley:2002

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] word stemming for corpus linguistics

2016-07-26 Thread Andy Wolfe

Hi Paul

I have seen this - it's part of the tm package mentioned originally. So, 
I've tried it again and perhaps I'm using stemDocument incorrectly, but 
this is what I am doing:


# > library(tm)
Loading required package: NLP
> text.v <- scan(file.choose(), what = 'char', sep = '\n')
Read 938 items
# >text.stem.v <- stemDocument(text.v, language = 'english')

But it isn't changing anything in the body of the text I'm passing to it 
- the words are unlemmatized/ unstemmed.


When I try using SnowballC, the error returned is that tm_map doesn't 
have a method to work with objects of class 'character'.


Again, the problem is that tm doesn't seem to allow for concordance 
analysis ... or perhaps it does and I just haven't figured out how to do 
it, so am happy to be shown some documentation on that process, and 
whether that is applied before or after the text is transformed into a 
DTM because searching on-line hasn't (yet) thrown anything back.


Thanks.
Andy


On 26/07/16 08:50, Paul Johnston wrote:

Suggest look at http://www.inside-r.org/packages/cran/tm/docs/stemDocument



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Andy Wolfe
Sent: 26 July 2016 08:10
To: r-help@r-project.org
Subject: [R] word stemming for corpus linguistics

Hi list

On a piece of work I'm doing in corpus linguistics, using a combo of texts by Gries 
"Quantitative Corpus Linguistics with R: A Practical Introduction" and Jockers "Text 
Analysis with R for Students of Literature", which are both really excellent by the way, I 
want to stem or lemmatize the words so that, for e.g., 'facilitating', 'facilitated', and 
'facilitates' all become 'facilit'.

In text mining, using a combination of the packages 'tm' and 'SnowballC'
this is feasible, but then I am finding that working with the DTM (document 
term matrix) becomes difficult for when I want to do concordance (or key word 
in context) analysis.

So, two questions:

(1) is there a package for R version 3.3.1 that can work with corpus 
linguistics? and/ or

(2) is there a way of doing concordance analysis using the tm package as part 
of the whole text mining process?

I appreciate any help. Thanks.

Andy


[[alternative HTML version deleted]]

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



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


Re: [R] word stemming for corpus linguistics

2016-07-26 Thread Paul Johnston
Suggest look at http://www.inside-r.org/packages/cran/tm/docs/stemDocument



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Andy Wolfe
Sent: 26 July 2016 08:10
To: r-help@r-project.org
Subject: [R] word stemming for corpus linguistics

Hi list

On a piece of work I'm doing in corpus linguistics, using a combo of texts by 
Gries "Quantitative Corpus Linguistics with R: A Practical Introduction" and 
Jockers "Text Analysis with R for Students of Literature", which are both 
really excellent by the way, I want to stem or lemmatize the words so that, for 
e.g., 'facilitating', 'facilitated', and 'facilitates' all become 'facilit'.

In text mining, using a combination of the packages 'tm' and 'SnowballC' 
this is feasible, but then I am finding that working with the DTM (document 
term matrix) becomes difficult for when I want to do concordance (or key word 
in context) analysis.

So, two questions:

(1) is there a package for R version 3.3.1 that can work with corpus 
linguistics? and/ or

(2) is there a way of doing concordance analysis using the tm package as part 
of the whole text mining process?

I appreciate any help. Thanks.

Andy


[[alternative HTML version deleted]]

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

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


Re: [R] R version 3.2.5

2016-07-26 Thread Loris Bennett
Maria Alice Jacques  writes:

> Good night,
>
> How can I download and install R version 3.2.5 from cran mirror of
> University of São Paulo, São Paulo?
>
> Thanks for your support.
>
> Maria Alice P. Jacques

[snip (8 lines)]

On this page

https://cran.r-project.org/

you can click on 'Mirrors' and choose the one you want.  You can then
click on the appropriate 'Download R' link for your operating system.
Note you can only install binaries for an arbitrary old version if you
are using Windows (or possibly Mac OS X).  If you are using a
Linux-based distribution, there will often be only specific versions
available for the version of your particular distribution.  In this
case, you might have to install from source.

Regards

Loris

-- 
Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universität Berlin Email loris.benn...@fu-berlin.de

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] word stemming for corpus linguistics

2016-07-26 Thread Andy Wolfe
Hi list

On a piece of work I'm doing in corpus linguistics, using a combo of 
texts by Gries "Quantitative Corpus Linguistics with R: A Practical 
Introduction" and Jockers "Text Analysis with R for Students of 
Literature", which are both really excellent by the way, I want to stem 
or lemmatize the words so that, for e.g., 'facilitating', 'facilitated', 
and 'facilitates' all become 'facilit'.

In text mining, using a combination of the packages 'tm' and 'SnowballC' 
this is feasible, but then I am finding that working with the DTM 
(document term matrix) becomes difficult for when I want to do 
concordance (or key word in context) analysis.

So, two questions:

(1) is there a package for R version 3.3.1 that can work with corpus 
linguistics? and/ or

(2) is there a way of doing concordance analysis using the tm package as 
part of the whole text mining process?

I appreciate any help. Thanks.

Andy


[[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] about netcdf files

2016-07-26 Thread David Winsemius
Please show code that allows potential responders to reply meaningfully.

-- 
David

> On Jul 25, 2016, at 9:54 PM, lily li  wrote:
> 
> Hi all,
> 
> I have a problem in opening netcdf files. If one netcdf file contains
> longitude, latitude, and daily precipitation. How to relate each
> precipitation record to its associated location, and export them as csv
> files? Thanks.
> 
> I just use nc_open(), ncvar_get(), but it is not very helpful. Thanks for
> any ideas.
> 
>[[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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