[R] Visualize Sparse Matrix.

2016-06-09 Thread FRANCISCO XAVIER SUMBA TORAL
Hi,

First of all, sorry for my question it could be so basic for a common user in 
R, but I am starting with this new environment.

I have done a clustering job and I would like to visualize my vectors. I have a 
matrix of TF-IDF weights of 4602 x 1817. I store the values in a CSV file. How 
can I visualize my vectors in a 2D-space?

After that, I execute a clustering algorithm and I got a label for each 
cluster. How can I visualize my vectors resulting base on a color or figure for 
each cluster? 

This is the code that I am having trying to accomplish my graphs:

data <- read.csv(pathFile,header = FALSE, sep = ",”)
dMatrix <- matrix(unlist(data), ncol = 4602, byrow = TRUE) # Use a matrix to 
use melt.
# Graph my data
ggplot(melt(dMatrix), aes(Var1,Var2, fill=value)) + geom_raster() + 
scale_fill_gradient2(low='red', high=‘black', mid=‘white') + theme_bw() + 
xlab("x1") + ylab("x2")


Cheers.
[[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] New installation

2016-06-09 Thread Clint Bowman
I "experiment" with the Fedora distribution at home but am very satisfied 
with the Scientific Linux distribution here at work--I'm currently using 
SL7.2.


Clint BowmanINTERNET:   cl...@ecy.wa.gov
Air Quality Modeler INTERNET:   cl...@math.utah.edu
Department of Ecology   VOICE:  (360) 407-6815
PO Box 47600FAX:(360) 407-7534
Olympia, WA 98504-7600

USPS:   PO Box 47600, Olympia, WA 98504-7600
Parcels:300 Desmond Drive, Lacey, WA 98503-1274

On Thu, 9 Jun 2016, Leonardo Ferreira Fontenelle wrote:


I have tried many Linux distributions before, and never looked back
after switching for Arch Linux. It is one of the best distributions with
regard to having an up to date but still reasonably stable system. Other
options are Fedora  Rawhide (there's a Fedora SIG mailing list) or
Debian Sid (as others mentioned, there's a Debian SIG mailing list), but
I don't know how dependable those versions are.

Leonardo Ferreira Fontenelle
Former GNOME translator

Em Qui 9 jun. 2016, às 20:08, Ista Zahn escreveu:

Perhaps r-sig-debian is more appropriate, though it is not clear to me
that
a debian based linux is in fact the best for running R. Of course "best"
is
not clearly defined here, but I highly recommend Archlinux.

Best,
Ista
On Jun 9, 2016 6:47 PM, "Bert Gunter"  wrote:

> I suggest that you post to the r-sig-debian list instead of here. I
> think you are more likely to get good answers to your query there.
>
> Cheers,
> Bert
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Thu, Jun 9, 2016 at 1:44 PM, jax200  wrote:
> > Hi
> >
> > I'm starting off with both R and Linux Mint.  During a recent R course, I
> > had multiple difficulties with installing updates needed for the course.
> >
> > As such, I'd like to hit the restart button with fresh installs of Linux
> > and R.  I would appreciate your help with which Linux platform works best
> > with R, and how to go about getting all the updates installed for both
> > programs.
> >
> > Many thanks,  Jack
> >
> > [[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.
>

[[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] New installation

2016-06-09 Thread Leonardo Ferreira Fontenelle
I have tried many Linux distributions before, and never looked back
after switching for Arch Linux. It is one of the best distributions with
regard to having an up to date but still reasonably stable system. Other
options are Fedora  Rawhide (there's a Fedora SIG mailing list) or
Debian Sid (as others mentioned, there's a Debian SIG mailing list), but
I don't know how dependable those versions are.

Leonardo Ferreira Fontenelle
Former GNOME translator

Em Qui 9 jun. 2016, às 20:08, Ista Zahn escreveu:
> Perhaps r-sig-debian is more appropriate, though it is not clear to me
> that
> a debian based linux is in fact the best for running R. Of course "best"
> is
> not clearly defined here, but I highly recommend Archlinux.
> 
> Best,
> Ista
> On Jun 9, 2016 6:47 PM, "Bert Gunter"  wrote:
> 
> > I suggest that you post to the r-sig-debian list instead of here. I
> > think you are more likely to get good answers to your query there.
> >
> > Cheers,
> > Bert
> > Bert Gunter
> >
> > "The trouble with having an open mind is that people keep coming along
> > and sticking things into it."
> > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >
> >
> > On Thu, Jun 9, 2016 at 1:44 PM, jax200  wrote:
> > > Hi
> > >
> > > I'm starting off with both R and Linux Mint.  During a recent R course, I
> > > had multiple difficulties with installing updates needed for the course.
> > >
> > > As such, I'd like to hit the restart button with fresh installs of Linux
> > > and R.  I would appreciate your help with which Linux platform works best
> > > with R, and how to go about getting all the updates installed for both
> > > programs.
> > >
> > > Many thanks,  Jack
> > >
> > > [[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.
> >
> 
>   [[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] Non-negative matrix factorization for term documnt matrix

2016-06-09 Thread Nordlund, Dan (DSHS/RDA)
A quick Google search suggests that the package, NMF, might be of help.


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 Ragia .
> Sent: Thursday, June 09, 2016 4:42 PM
> To: r-help@r-project.org
> Subject: [R] Non-negative matrix factorization for term documnt matrix
> 
> 
> 
> 
> 
>  Dear group,
>  kindly how can I apply Non-negative matrix factorization for term document
> matrix in R.  Please if you any link to guide or tutorial send it.
>   thanks in advance
> 
>   Ragia
> 
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] Non-negative matrix factorization for term documnt matrix

2016-06-09 Thread Ragia .



 
 Dear group,
 kindly how can I apply Non-negative matrix factorization for term document 
matrix in R.  Please if you any link to guide or tutorial send it.
  thanks in advance
 
  Ragia
  
  
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] New installation

2016-06-09 Thread Ista Zahn
Perhaps r-sig-debian is more appropriate, though it is not clear to me that
a debian based linux is in fact the best for running R. Of course "best" is
not clearly defined here, but I highly recommend Archlinux.

Best,
Ista
On Jun 9, 2016 6:47 PM, "Bert Gunter"  wrote:

> I suggest that you post to the r-sig-debian list instead of here. I
> think you are more likely to get good answers to your query there.
>
> Cheers,
> Bert
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Thu, Jun 9, 2016 at 1:44 PM, jax200  wrote:
> > Hi
> >
> > I'm starting off with both R and Linux Mint.  During a recent R course, I
> > had multiple difficulties with installing updates needed for the course.
> >
> > As such, I'd like to hit the restart button with fresh installs of Linux
> > and R.  I would appreciate your help with which Linux platform works best
> > with R, and how to go about getting all the updates installed for both
> > programs.
> >
> > Many thanks,  Jack
> >
> > [[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.
>

[[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] New installation

2016-06-09 Thread Bert Gunter
I suggest that you post to the r-sig-debian list instead of here. I
think you are more likely to get good answers to your query there.

Cheers,
Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Thu, Jun 9, 2016 at 1:44 PM, jax200  wrote:
> Hi
>
> I'm starting off with both R and Linux Mint.  During a recent R course, I
> had multiple difficulties with installing updates needed for the course.
>
> As such, I'd like to hit the restart button with fresh installs of Linux
> and R.  I would appreciate your help with which Linux platform works best
> with R, and how to go about getting all the updates installed for both
> programs.
>
> Many thanks,  Jack
>
> [[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-es] Reemplazar NA con el último valor no NA de una columna en una data.table

2016-06-09 Thread Patricio Fuenmayor
Para que quede de constancia en el hilo, he realizado el siguiente código

# REEMPLAZAR NA POR ULTINO VALOR NO NA
for(col in c("V10DP","V25DP","V50D","V25DC","V10DC")){
  cond <- !is.na(eod_cmvl03[,get(col)])
  eod_cmvl03[,(col):=.SD[,get(col)][1L],by=cumsum(cond)]}

gracias por las ideas...
saludos.

[[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] New installation

2016-06-09 Thread jax200
Hi

I'm starting off with both R and Linux Mint.  During a recent R course, I
had multiple difficulties with installing updates needed for the course.

As such, I'd like to hit the restart button with fresh installs of Linux
and R.  I would appreciate your help with which Linux platform works best
with R, and how to go about getting all the updates installed for both
programs.

Many thanks,  Jack

[[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 identification of CRAN CHECK machines in logs

2016-06-09 Thread Hadley Wickham
On Thu, Jun 9, 2016 at 9:24 AM, Marcelo Perlin  wrote:
> Hi,
>
> I recently released two packages (RndTexExams and GetTDData) in CRAN and
> I'm trying to track the number of downloads and location of users.
>
> I wrote a simple script to download and analyze the log files in http://cran
> -logs.rstudio.com.
> I realized, however, that during the release of a new version of the
> packages there is a spike in the number of downloads. I believe that the
> CRAN checks are included in the number of installations of the package in
> the log files.

I don't think that's true. Why would CRAN be installing the package
from a mirror?

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.


Re: [R] problem: the id of the data set

2016-06-09 Thread Nordlund, Dan (DSHS/RDA)
We really need a reproducible example.  Otherwise, we can only guess what the 
starting point was, how the merge was done, what the expected result was, and 
how the obtained result differed from the expected result.

Dan

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


> -Original Message-
> On 09/06/2016 09:00, 周 可卫 wrote:
> > I got the dataset after merge two old one .The  id of the column isn’t  just
> the number of the column.So when I identify some obs,I got the figure
> 28000(though my obs is only 6000).So it causes the trouble to remove these
> obs in the dataset.I wander how to make the id of the merged dataset in a
> right order.Or what could I do when I did identify the id of the outliner(but
> not the number of the column it belongs to ) when I need to remove those
> obs.
> > Thanks for your time.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R-es] analisis estadistica hidrologica y de precipitaciones con R

2016-06-09 Thread Carlos J. Gil Bellosta
Comienza por https://cran.r-project.org/web/views/Environmetrics.html

El 9 de junio de 2016, 21:07, Javier Valdes Cantallopts (DGA) <
javier.val...@mop.gov.cl> escribió:

> Necesito saber consejos sobre algún paquete para realizar análisis
> estadístico para hidrología y precipitaciones con R.
>
> Saludos.
>
>
>
> [image: R]
>
>
>
> --
>
> CONFIDENCIALIDAD: La información contenida en este mensaje y/o en los
> archivos adjuntos es de carácter confidencial o privilegiada y está
> destinada al uso exclusivo del emisor y/o de la persona o entidad a quien
> va dirigida. Si usted no es el destinatario, cualquier almacenamiento,
> divulgación, distribución o copia de esta información está estrictamente
> prohibido y sancionado por la ley. Si recibió este mensaje por error, por
> favor infórmenos inmediatamente respondiendo este mismo mensaje y borre
> todos los archivos adjuntos. Gracias.
>
> CONFIDENTIAL NOTE: The information transmitted in this message and/or
> attachments is confidential and/or privileged and is intented only for use
> of the person or entity to whom it is addressed. If you are not the
> intended recipient, any retention, dissemination, distribution or copy of
> this information is strictly prohibited and sanctioned by law. If you
> received this message in error, please reply us this same message and
> delete this message and all attachments. Thank you.
>
> ___
> 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] problem: the id of the data set

2016-06-09 Thread Ulrik Stervbo
How do you merge the two data.frames? Could it be that you make an outer
join?

HTH
Ulrik

On Thu, 9 Jun 2016 at 19:45 Michael Dewey  wrote:

> Perhaps I do not understand you correctly but why not create a variable
> for the id before you merge?
>
> On 09/06/2016 09:00, 周 可卫 wrote:
> > I got the dataset after merge two old one .The  id of the column isn’t
> just the number of the column.So when I identify some obs,I got the figure
> 28000(though my obs is only 6000).So it causes the trouble to remove these
> obs in the dataset.I wander how to make the id of the merged dataset in a
> right order.Or what could I do when I did identify the id of the
> outliner(but not the number of the column it belongs to ) when I need to
> remove those obs.
> > Thanks for your time.
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
> --
> Michael
> http://www.dewey.myzen.co.uk/home.html
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

[[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-es] analisis estadistica hidrologica y de precipitaciones con R

2016-06-09 Thread Javier Valdes Cantallopts (DGA)
Necesito saber consejos sobre algún paquete para realizar análisis estadístico 
para hidrología y precipitaciones con R.
Saludos.

[R]




CONFIDENCIALIDAD: La información contenida en este mensaje y/o en los archivos 
adjuntos es de carácter confidencial o privilegiada y está destinada al uso 
exclusivo del emisor y/o de la persona o entidad a quien va dirigida. Si usted 
no es el destinatario, cualquier almacenamiento, divulgación, distribución o 
copia de esta información está estrictamente prohibido y sancionado por la ley. 
Si recibió este mensaje por error, por favor infórmenos inmediatamente 
respondiendo este mismo mensaje y borre todos los archivos adjuntos. Gracias.

CONFIDENTIAL NOTE: The information transmitted in this message and/or 
attachments is confidential and/or privileged and is intented only for use of 
the person or entity to whom it is addressed. If you are not the intended 
recipient, any retention, dissemination, distribution or copy of this 
information is strictly prohibited and sanctioned by law. If you received this 
message in error, please reply us this same message and delete this message and 
all attachments. Thank you.
___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R] problem: the id of the data set

2016-06-09 Thread Michael Dewey
Perhaps I do not understand you correctly but why not create a variable 
for the id before you merge?


On 09/06/2016 09:00, 周 可卫 wrote:

I got the dataset after merge two old one .The  id of the column isn’t  just 
the number of the column.So when I identify some obs,I got the figure 
28000(though my obs is only 6000).So it causes the trouble to remove these obs 
in the dataset.I wander how to make the id of the merged dataset in a right 
order.Or what could I do when I did identify the id of the outliner(but not the 
number of the column it belongs to ) when I need to remove those obs.
Thanks for your time.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
Michael
http://www.dewey.myzen.co.uk/home.html

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

Re: [R] Reading and converting time data via read.table

2016-06-09 Thread William Dunlap via R-help
>In fact, I learned most of them the hard way
>by trial and error and realized that it’s difficult to separate time and
>date using POSIXct and POSIXlt.

It is difficult to separate time from data in real life as well.  The most
common problem is when your time zone switches between 'daylight
savings' ('summer') and 'standard' ('winter') each spring and fall.

You can attach your time to a fake date and arrange to only print the
time portion, but since you have a date, use it.




Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Jun 8, 2016 at 10:40 PM, Ek Esawi  wrote:

> Thank you Jeff and Don. As I stated on my original posting that I am
> relatively new to R. After a few weeks of searching and reading I have come
> to the same point that Don made which is base R doesn’t have a class for
> time only. I explored the chron and lubridate packages and even looked at
> Ecfun
> package; the latter is too long and I did not have time to experiment with
> it. I think the lubridate package might be useful for this; but again I did
> not want to get into many packages. So I tried chron using the times
> function that produced what I want. Indeed as Don said, I could not figure
> out how to use it in a read.table; so I had already decided to do what Don
> suggested which is read them as character then convert them one vector at a
> time to time class.
>
>
>
> What do I need this stuff for? Well, I published a paper 6 months ago where
> I had to deal with time data and needed to convert and manipulate time
> data. I did all that work in Excel and it took too long; so I want to learn
> R for future research and use the same data using R.
>
>
>
> I agree with Jeff’s comments. In fact, I learned most of them the hard way
> by trial and error and realized that it’s difficult to separate time and
> date using POSIXct and POSIXlt.
>
>
>
> Thanks againEK
>
> [[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] R install on AIX 7

2016-06-09 Thread Duncan Murdoch

On 09/06/2016 11:19 AM, Himani wrote:

Hi,
I am trying to install R on AIX 7, could you please refer me to any
document which i can refer to.


The R Installation and Administration manual (distributed with R) seems 
like the place to start.  It doesn't mention AIX 7 but does go up to AIX 
6.2.  It also mentions an "R on AIX" project; I don't know if that is 
still active.


Duncan Murdoch


My ultimate goal is to integrate R with
microstrategy and my microstrategy server is on AIX 7, so i need to have R
installed over there before i can install integration pack.

Any suggestions please.

Thanks
Himani

[[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] VIM package

2016-06-09 Thread Tom Wright
Did you install the package before loading it?
install.packages("VIM")

On Thu, Jun 9, 2016 at 1:19 PM, Ayyappa Chaturvedula
 wrote:
> Dear R users,
> I am trying to use VIM (Visualization and Imputation of Missing Values)
> package in R.  When I try to install the VIM library (library(VIM)), I am
> getting this: Error in library(VIM) : there is no package called ‘VIM’. I
> appreciate any comments on this problem.
> Regards,
> Ayyappa
>
> [[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] About identification of CRAN CHECK machines in logs

2016-06-09 Thread Marcelo Perlin
Hi,

I recently released two packages (RndTexExams and GetTDData) in CRAN and
I'm trying to track the number of downloads and location of users.

I wrote a simple script to download and analyze the log files in http://cran
-logs.rstudio.com.
I realized, however, that during the release of a new version of the
packages there is a spike in the number of downloads. I believe that the
CRAN checks are included in the number of installations of the package in
the log files.

I see from the log files the existence of column "ip_id", which sets a
daily unique id for each new ip. My question is, can CRAN set the ip_id of
the CRAN machines to a fixed value so that we can filter only "real" users
out of the data? Can anyone see any other way around it?


Thanks.

-- 
Marcelo Perlin
Professor Adjunto | Escola de Administração
Universidade Federal do Rio Grande do Sul
Rua Washington Luiz, 855 | 90010-460| Porto Alegre RS| Brasil
Tel.: (51) 3308-3303 | www.ea.ufrgs.br
http://lattes.cnpq.br/3262699324398819
https://sites.google.com/site/marceloperlin/

[[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] VIM package

2016-06-09 Thread Ayyappa Chaturvedula
Dear R users,
I am trying to use VIM (Visualization and Imputation of Missing Values)
package in R.  When I try to install the VIM library (library(VIM)), I am
getting this: Error in library(VIM) : there is no package called ‘VIM’. I
appreciate any comments on this problem.
Regards,
Ayyappa

[[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] R install on AIX 7

2016-06-09 Thread Himani
Hi,
I am trying to install R on AIX 7, could you please refer me to any
document which i can refer to. My ultimate goal is to integrate R with
microstrategy and my microstrategy server is on AIX 7, so i need to have R
installed over there before i can install integration pack.

Any suggestions please.

Thanks
Himani

[[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] problem: the id of the data set

2016-06-09 Thread 周 可卫
I got the dataset after merge two old one .The  id of the column isn’t  just 
the number of the column.So when I identify some obs,I got the figure 
28000(though my obs is only 6000).So it causes the trouble to remove these obs 
in the dataset.I wander how to make the id of the merged dataset in a right 
order.Or what could I do when I did identify the id of the outliner(but not the 
number of the column it belongs to ) when I need to remove those obs.
Thanks for your time.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Reading and converting time data via read.table

2016-06-09 Thread Ek Esawi
Thank you Jeff and Don. As I stated on my original posting that I am
relatively new to R. After a few weeks of searching and reading I have come
to the same point that Don made which is base R doesn’t have a class for
time only. I explored the chron and lubridate packages and even looked at Ecfun
package; the latter is too long and I did not have time to experiment with
it. I think the lubridate package might be useful for this; but again I did
not want to get into many packages. So I tried chron using the times
function that produced what I want. Indeed as Don said, I could not figure
out how to use it in a read.table; so I had already decided to do what Don
suggested which is read them as character then convert them one vector at a
time to time class.



What do I need this stuff for? Well, I published a paper 6 months ago where
I had to deal with time data and needed to convert and manipulate time
data. I did all that work in Excel and it took too long; so I want to learn
R for future research and use the same data using R.



I agree with Jeff’s comments. In fact, I learned most of them the hard way
by trial and error and realized that it’s difficult to separate time and
date using POSIXct and POSIXlt.



Thanks againEK

[[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] apply and cousins

2016-06-09 Thread John Logsdon
Thanks Jim and others (and sorry Jim - an early version of this slipped
into your inbox :))

Apologies for not giving some concrete code - I was trying to explain in
words.

What I need to do is to fit a simple linear model to successive sections
of a long matrix.

So far, the best solution I have come up with uses apply twice:

Generate some data in a 10*3 matrix:

N = 10
Z = cbind(1:N,cumsum(rnorm(N,1,0.01)),rnorm(N,1.2,0.1)) #

where the first column is an index, the second a monotonic increasing
value representing time and the third just the measurements I want to
process.

Then write a function dVals1:

dVals1 = function(Y,DD,dT){which.min((Y[2] - dT) > DD[,2])))

which will identify the first row where the time is greater than current
time - dT.

So to identify the start of the data (say) 10 units before for each row,
we use apply and prepended this as a column to the array for later use:

ZZ = cbind(apply(Z,1,dVals1,Z,10),Z)

There may be some cases, particularly at the start, where later values are
extracted because the minimum returned by which.min is 1.

I now have start and finish pointers for each position so can proceed to
fit a simple linear model with the following function:

dVals2=function(D2,DD){
  if((D2[2]-D2[1])<10){return(rep(0,2))} # reject short examples
  DX=DD[D2[1]:D2[2],]
  Res=as.vector(lm(DX[,3]~DX[,2])$coefficients)
  return(Res)
}

which returns 2 0's either if there are fewer than 10 values, otherwise it
returns the intercept and slope calculated over the specified range.

Applying this to the whole data by:

t(apply(ZZ,1,dVals2,DD=ZZ))

does the job I think returning the results as an N * 2 matrix.

> Hi John,
> With due respect to the other respondents, here is something that might
help:
>
> # get a vector of values
> foo<-rnorm(100)
> # get a vector of increasing indices (aka your "recent" values)
> bar<-sort(sample(1:100,40))
> # write a function to "clump" the adjacent index values
> clump_adj_int<-function(x) {
>  index_list<-list(x[1])
>  list_index<-1
>  for(i in 2:length(x)) {
>   if(x[i]==x[i-1]+1)
>index_list[[list_index]]<-c(index_list[[list_index]],x[i])
>   else {
>list_index<-list_index+1
>index_list[[list_index]]<-x[i]
>   }
>  }
>  return(index_list)
> }
> index_clumps<-clump_adj_int(bar)
> # write another function to sum the values
> sum_subsets<-function(indices,vector)
> return(sum(vector[indices],na.rm=TRUE))
> # now "apply" the function to the list of indices
> lapply(index_clumps,sum_subsets,foo)
>
> Jim
>
>
> On Thu, Jun 9, 2016 at 2:41 AM, John Logsdon
>  wrote:
>> Folks
>>
>> Is there any way to get the row index into apply as a variable?
>>
>> I want a function to do some sums on a small subset of some very long
vectors, rolling through the whole vectors.
>>
>> apply(X,1,function {do something}, other arguments)
>>
>> seems to be the way to do it.
>>
>> The subset I want is the most recent set of measurements only - perhaps a
>> couple of hundred out of millions - but I can't see how to index each
value.  The ultimate output should be a matrix of results the length of
the input vector.  But to do the sum I need to access the current row
number.
>>
>> It is easy in a loop but that will take ages. Is there any vectorised
apply-like solution to this?
>>
>> Or does apply etc only operate on each row at a time, independently of
other rows?
>>
>>
>> Best wishes
>>
>> John
>>
>> John Logsdon
>> Quantex Research Ltd
>> +44 161 445 4951/+44 7717758675
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>


Best wishes

John

John Logsdon
Quantex Research Ltd
+44 161 445 4951/+44 7717758675



Best wishes

John

John Logsdon
Quantex Research Ltd
+44 161 445 4951/+44 7717758675

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


Re: [R] Problem loading aplpack library

2016-06-09 Thread Marc Schwartz
Hi,

First, since David is reporting an issue on OS X, this should be posted to 
R-SIG-Mac:

  https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Second, he is installing a binary version of the package and XCode should not 
be required in that setting.

There are a variety of warnings related to that package on CRAN:

  https://cran.r-project.org/web/checks/check_results_aplpack.html

Since they are warnings and not errors, that is presumably a low enough hurdle 
to enable the package to be released on CRAN, but the package author should 
really be working on resolving them. That being said, the package has not been 
updated since September of 2014, so unless it is updated at some point 
soon-ish, it may end up being orphaned and/or archived, depending upon CRAN 
policies.

FWIW, I did try to install the package on my Mac, running R 3.3.0 under El 
Capitan and had no issues, either with the install or loading the package.

It might be prudent for David to consider removing his R installation 
completely and install R 3.3.0 from scratch, along with XQuartz after 
installing R, which was just recently updated to 2.7.9.

David appears to be running R 3.1.x based upon the CRAN path being used below, 
so installing the latest stable version of R would be prudent.

Lastly, tclck is part of the base R distribution and does not need to be 
installed separately. That is why David is not finding it when trying to 
install it. It is already installed.

tcltk2 is a third party CRAN package and is not indicated as being a dependency 
for aplpack.

Regards,

Marc Schwartz


> On Jun 9, 2016, at 9:00 AM, Tom Wright  wrote:
> 
> Assuming you are on a mac this link may be of assistance:
> http://tips.tutorialhorizon.com/2015/10/01/xcrun-error-invalid-active-developer-path-library-developer-commandline-tools-missing-xcrun/
> 
> On Wed, Jun 8, 2016 at 7:14 PM, David Howell  wrote:
>> I am having trouble running aplpack on my Mac. It will run on my PC, but the
>> Mac gives an error message. Below is the result that I obtained.  It seems
>> to install fine--see below--but I can't load the library.
>> 
>> 
>>> install.packages("aplpack")
>> trying URL
>> 'http://cran.rstudio.com/bin/macosx/contrib/3.1/aplpack_1.3.0.tgz'
>> Content type 'application/x-gzip' length 3157548 bytes (3.0 Mb)
>> opened URL
>> ==
>> downloaded 3.0 Mb
>> 
>> 
>> The downloaded binary packages are in
>> /var/folders/6m/t4wvnh9x39500z_rh3p5jlk0gp/T//Rtmp26I5Ej/downloaded_packages
>> 
>>> library(aplpack)
>> Loading required package: tcltk
>> xcrun: error: invalid active developer path
>> (/Library/Developer/CommandLineTools), missing xcrun at:
>> /Library/Developer/CommandLineTools/usr/bin/xcrun
>> 
>> It looks as if it has a problem with tcltk. I can install tcltk2, but when I
>> try to install tcltk it tells me "package not found. Is that the problem
>> that aplpack is having when it tries to load the library?
>> 
>> Any suggestions?

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


Re: [R] Problem loading aplpack library

2016-06-09 Thread Tom Wright
Assuming you are on a mac this link may be of assistance:
http://tips.tutorialhorizon.com/2015/10/01/xcrun-error-invalid-active-developer-path-library-developer-commandline-tools-missing-xcrun/

On Wed, Jun 8, 2016 at 7:14 PM, David Howell  wrote:
> I am having trouble running aplpack on my Mac. It will run on my PC, but the
> Mac gives an error message. Below is the result that I obtained.  It seems
> to install fine--see below--but I can't load the library.
>
>
>  > install.packages("aplpack")
> trying URL
> 'http://cran.rstudio.com/bin/macosx/contrib/3.1/aplpack_1.3.0.tgz'
> Content type 'application/x-gzip' length 3157548 bytes (3.0 Mb)
> opened URL
> ==
> downloaded 3.0 Mb
>
>
> The downloaded binary packages are in
> /var/folders/6m/t4wvnh9x39500z_rh3p5jlk0gp/T//Rtmp26I5Ej/downloaded_packages
>
>  > library(aplpack)
> Loading required package: tcltk
> xcrun: error: invalid active developer path
> (/Library/Developer/CommandLineTools), missing xcrun at:
> /Library/Developer/CommandLineTools/usr/bin/xcrun
>
> It looks as if it has a problem with tcltk. I can install tcltk2, but when I
> try to install tcltk it tells me "package not found. Is that the problem
> that aplpack is having when it tries to load the library?
>
> Any suggestions?
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Error: missing value where TRUE/FALSE needed

2016-06-09 Thread Fox, John
Dear Shashi Seth,

The principal problem here is that the "argument" to if() must be logical, 
while comparing anything to NA always produces NA. The proper way to test for 
NA is with is.na(). 

There's potentially something more subtle going on here, however, which is that 
even if some of the elements of the logical expression in the "call" to if() 
are NA, the expression may evaluate to FALSE (but never to TRUE) if the non-NA 
elements imply that it is FALSE. Consider the following examples:

> TRUE && FALSE && NA  # FALSE regardless of the value of the last element
[1] FALSE

> TRUE && TRUE && NA  # truth depends on the value of the last element
[1] NA

> (TRUE && FALSE && NA) != NA
[1] NA

> (TRUE && TRUE && NA) != NA
[1] NA

> is.na(TRUE && FALSE && NA)
[1] FALSE

> is.na(TRUE && TRUE && NA)
[1] TRUE

I hope that this helps,
 John

-
John Fox, Professor
McMaster University
Hamilton, Ontario
Canada L8S 4M4
Web: socserv.mcmaster.ca/jfox



> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of SHASHI SETH
> Sent: June 9, 2016 2:53 AM
> To: R-help@r-project.org
> Subject: [R] Error: missing value where TRUE/FALSE needed
> 
> Hi,
> 
> 
> 
> I am getting the following error:
> 
> Error in if ((sum > 0 && sums1 > 0 && sums2 > 0) != NA) { :
> 
> missing value where TRUE/FALSE needed
> 
> 
> 
> 
> 
> I have including my code below for your review:
> 
> 
> 
> fitness_1_data
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Importing data from a text file with no separator

2016-06-09 Thread Duncan Murdoch

On 09/06/2016 8:56 AM, Federman, Douglas wrote:

?read.fwf

There is a data import/export document on cran.r-project.org


And included with R distributions.  It's one of the manuals, and will be 
accessible via the help menu in front ends that have one.


Duncan Murdoch





-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Paolo Letizia
Sent: Wednesday, June 08, 2016 8:40 PM
To: r-help@r-project.org
Subject: [R] Importing data from a text file with no separator

I have row data in a text file, where each row consists of 22 numerical 
characters. Each row consists of three different column but there is no 
separator. Specifically, the first two characters of the raw represent  the 
first column of data, the subsequent 8 characters represent the second column 
of data and the last 12 characters represent the third column of data. An 
example follows:

row data:
10030614911608

The first two characters, "10", is the column "Regime"; the subsequent 8 characters, "03061490", is 
the column "Industry", and the last 12 characters, "00011608", is the column dollar value. How do I 
import the column data into R without having any separator in the text file?
Thanks for your help, Paolo.

[[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] Importing data from a text file with no separator

2016-06-09 Thread Federman, Douglas
?read.fwf

There is a data import/export document on cran.r-project.org 



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Paolo Letizia
Sent: Wednesday, June 08, 2016 8:40 PM
To: r-help@r-project.org
Subject: [R] Importing data from a text file with no separator

I have row data in a text file, where each row consists of 22 numerical 
characters. Each row consists of three different column but there is no 
separator. Specifically, the first two characters of the raw represent  the 
first column of data, the subsequent 8 characters represent the second column 
of data and the last 12 characters represent the third column of data. An 
example follows:

row data:
10030614911608

The first two characters, "10", is the column "Regime"; the subsequent 8 
characters, "03061490", is the column "Industry", and the last 12 characters, 
"00011608", is the column dollar value. How do I import the column data 
into R without having any separator in the text file?
Thanks for your help, Paolo.

[[alternative HTML version deleted]]

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

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


Re: [R] create an empty data frame and then fill in it

2016-06-09 Thread Duncan Murdoch

On 09/06/2016 6:22 AM, Stefano Sofia wrote:

Dear R list users,
sorry for this simple question, but I already spent many efforts to solve it.

I create an empty data frame called df_year like

df_year <- data.frame(day=as.Date(character()), hs_MteBove=integer(), 
hs_MtePrata=integer(), hs_Pintura=integer(), hs_Pizzo=integer(), 
hs_Sassotetto=integer(), hs_Sibilla=integer(), stringsAsFactors=FALSE)

and then I start to fill in it with

df_year$day <- seq(as.Date("2004-11-01-00-00","%Y-%m-%d"), 
as.Date("2005-05-01-00-00","%Y-%m-%d"), by="day")

but I get the following error:
"replacement has 182 rows, data has 0"

Where is my silly mistake?


Your dataframe has 0 rows, so you can't put a 182 row vector into the 
first column.


Unlike vectors, dataframes won't grow if you make assignments beyond the 
end of the rows.


There are at least a couple of solutions:

1.  Don't create columns until you have data ready for them.

You can wait to create the dataframe until your "day" column is ready:

df_year <- data.frame(day = seq(...))

As you compute other columns of the same length, you can add them, e.g.

df_year$hs_MteBove <- ...

2.  Create your columns with the right length from the beginning:

df_year <- data.frame(day = rep(as.Date(NA), 182), ...)

I don't like this solution as much.

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] create an empty data frame and then fill in it

2016-06-09 Thread Duncan Murdoch

On 09/06/2016 6:22 AM, Stefano Sofia wrote:

Dear R list users,
sorry for this simple question, but I already spent many efforts to solve it.

I create an empty data frame called df_year like

df_year <- data.frame(day=as.Date(character()), hs_MteBove=integer(), 
hs_MtePrata=integer(), hs_Pintura=integer(), hs_Pizzo=integer(), 
hs_Sassotetto=integer(), hs_Sibilla=integer(), stringsAsFactors=FALSE)

and then I start to fill in it with

df_year$day <- seq(as.Date("2004-11-01-00-00","%Y-%m-%d"), 
as.Date("2005-05-01-00-00","%Y-%m-%d"), by="day")

but I get the following error:
"replacement has 182 rows, data has 0"

Where is my silly mistake?


Your dataframe has 0 rows, so you can't put a 182 row vector into the 
first column.


Unlike vectors, dataframes won't grow if you make assignments beyond the 
end of the rows.


There are at least a couple of solutions:

1.  Don't create columns until you have data ready for them.

You can wait to create the dataframe until your "day" column is ready:

df_year <- data.frame(day = seq(...))

As you compute other columns of the same length, you can add them, e.g.

df_year$hs_MteBove <- ...

2.  Create your columns with the right length from the beginning:

df_year <- data.frame(day = rep(as.Date(NA), 182), ...)

I don't like this solution as much.

Duncan Murdoch

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


[R] create an empty data frame and then fill in it

2016-06-09 Thread Stefano Sofia
Dear R list users,
sorry for this simple question, but I already spent many efforts to solve it.

I create an empty data frame called df_year like

df_year <- data.frame(day=as.Date(character()), hs_MteBove=integer(), 
hs_MtePrata=integer(), hs_Pintura=integer(), hs_Pizzo=integer(), 
hs_Sassotetto=integer(), hs_Sibilla=integer(), stringsAsFactors=FALSE)

and then I start to fill in it with

df_year$day <- seq(as.Date("2004-11-01-00-00","%Y-%m-%d"), 
as.Date("2005-05-01-00-00","%Y-%m-%d"), by="day")

but I get the following error:
"replacement has 182 rows, data has 0"

Where is my silly mistake?

Thank you for your help
Stefano




AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere 
informazioni confidenziali, pertanto è destinato solo a persone autorizzate 
alla ricezione. I messaggi di posta elettronica per i client di Regione Marche 
possono contenere informazioni confidenziali e con privilegi legali. Se non si 
è il destinatario specificato, non leggere, copiare, inoltrare o archiviare 
questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al 
mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi 
dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed 
urgenza, la risposta al presente messaggio di posta elettronica può essere 
visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by 
persons entitled to receive the confidential information it may contain. E-mail 
messages to clients of Regione Marche may contain information that is 
confidential and legally privileged. Please do not read, copy, forward, or 
store this message unless you are an intended recipient of it. If you have 
received this message in error, please forward it to the sender and delete it 
completely from your computer system.

[[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] expand.model.frame issue

2016-06-09 Thread Keith Jewell
Following on from a stackoverflow question "Why does this simple 
function calling `lm(..., subset)` fail?"


--
myfun <- function(form., data., subs.) lm(form., data., subs.)
myfun(mpg ~ cyl + hp, mtcars, TRUE)
## Error in eval(expr, envir, enclos) : object 'subs.' not found
-

The answer to the stated question was in ?lm "If not found in data, the 
variables are taken from environment(formula), typically the environment 
from which lm is called"; the environment of the formula (mpg ~ cyl + 
hp) does not contain 'subs.'. A fix is quite straightforward, set the 
environment of the formula to that of the function, which does contain 
'subs.'. There are multiple ways of doing that, this works but to me 
seems a bit "clunky":

---
myfun <- function(form., data., subs.) lm(as.formula(deparse(form.)), 
data., subs.)

myfun(mpg ~ cyl + hp, mtcars, TRUE)
--
To me this seems more elegant, but then I have no taste :-}
--
myfun <- function(form., data., subs.){
  environment(form.) <- environment()
  lm(form., data., subs.)}
myfun(mpg ~ cyl + hp, mtcars, TRUE)
--

But the OP went on to consider `expand.model.frame` e.g.
-
myfun <- function(form., data., subs.){
  environment(form.) <- environment()
  model <- lm(form., data., subs.)
  print(ls(envir = environment(formula(model
  expand.model.frame(model, ~drat)}
myfun(mpg ~ cyl + hp, mtcars, TRUE)
## [1] "data." "form." "model" "subs."
## Error in eval(expr, envir, enclos) : object 'subs.' not found
-

myfun can be fixed by (e.g.) avoiding the subset argument of lm

myfun <- function(form., data., subs.){
  environment(form.) <- environment()
  model <- lm(form., data.[subs.,])
  expand.model.frame(model, ~drat)}
myfun(mpg ~ cyl + hp, mtcars, TRUE)

... but this message is about the apparent inconsistency between the 
behaviour of expand.model.frame and the help text which says:

?expand.model.frame:
---
Usage

expand.model.frame(model, extras,
   envir = environment(formula(model)),
   na.expand = FALSE)

envir   an environment to evaluate things in
-

In the example of the `expand.model.frame` issue above the result of the 
'ls()' clearly shows that 'subs.' is in that environment, but 
expand.model.frame fails to find it.


Am I misunderstanding?
Or is there an error in the help text?
Or is there a bug in expand.model.frame?

=
I don't think this is relevant, but for completeness
> sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows Server 2008 R2 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United 
Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C 


[5] LC_TIME=English_United Kingdom.1252

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


other attached packages:
 [1] CBRIutils_1.0   stringr_1.0.0   svSocket_0.9-57 TinnR_1.0-5 
R2HTML_2.3.1Hmisc_3.17-4ggplot2_2.1.0

 [8] Formula_1.2-1   survival_2.39-4 lattice_0.20-33

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.5 magrittr_1.5cluster_2.0.4 
splines_3.3.0   devtools_1.11.1
 [6] munsell_0.4.3   colorspace_1.2-6plyr_1.8.3 
nnet_7.3-12 grid_3.3.0
[11] data.table_1.9.6gtable_0.2.0latticeExtra_0.6-28 
withr_1.0.1 svMisc_0.9-70
[16] digest_0.6.9Matrix_1.2-6gridExtra_2.2.1 
RColorBrewer_1.1-2  acepack_1.3-3.3
[21] rpart_4.1-10memoise_1.0.0   stringi_1.1.1 
scales_0.4.0foreign_0.8-66

[26] chron_2.3-47

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] [R-pkgs] New versions of heplots, candisc, mvinfluence and matlib on CRAN

2016-06-09 Thread Michael Friendly

# New versions of heplots, candisc, mvinfluence and matlib on CRAN
# 

New versions of my packages designed for visualization of multivariate
linear models have recently been submitted to CRAN. The matlib package
also contains some plot methods for vector diagrams representing linear
algebra concepts in multivariate statistical methods.

## heplots
## ---

Devel URL: https://r-forge.r-project.org/projects/heplots/
Issue tracker: https://r-forge.r-project.org/tracker/?group_id=24

Provides HE plot and other functions for visualizing hypothesis
tests in multivariate linear models. HE plots represent sums-of-squares-and-
products matrices for linear hypotheses and for error using ellipses (in two
dimensions) and ellipsoids (in three dimensions).

Version 1.3-0 (2016-06-03)

o In cqplot(), pch, col, and cex can now be vectors
o Bump version, prepare for release

Version 1.2-1 (2016-05-19)

o in coefplot.mlm(), now pass `label.pos` to label.ellipse()
o added Mahalanobis() for classical and robust squared distances; handles
  missing data gracefully and provides a confidence envelope
o added SocialCog data [Thx: Leah Hartman]
o added cqplot() of Mahalanobis distances as a plot method for an mlm 
and for multivariate data


Version 1.2-0 (2016-04-27)

o covEllipses() extended to more than two variables, giving a 
scatterplot matrix plot
o plot.boxM() now can plot other measures of the eigenvalues of the 
covariance matrices,

  useful for understanding the properties of the test.
o added bartlettTests() for a collection of univariate Bartlett tests
o added leveneTests() for a collection of univariate Levene tests
o added NeuroCog data, a simple one-way MANOVA [Thx: Leah Hartman]
o label.ellipse() now uses a much more flexible `label.pos` argument for 
positioning the

  text labels used in heplot() and friends.

## candisc
## ---

Devel URL: https://r-forge.r-project.org/projects/candisc/

Functions for computing and visualizing generalized canonical discriminant
analyses and canonical correlation analysis for a multivariate linear model.
Traditional canonical discriminant analysis is restricted to a one-way 
'MANOVA'

design and is equivalent to canonical correlation analysis between a set of
quantitative response variables and a set of dummy variables coded from the
factor variable. The 'candisc' package generalizes this to higher-way 
'MANOVA'

designs for all factors in a multivariate linear model, computing canonical
scores and vectors for each term. The graphic functions provide low-rank 
(1D,

2D, 3D) visualizations of terms in an 'mlm' via the 'plot.candisc' and
'heplot.candisc' methods. Related plots are now provided for canonical
correlation analysis when all predictors are quantitative.

Changes in version 0.7-1 (2016-05-23)

  o respect var.lwd in 2D plot.candisc()
  o heplot.candisc() gets a rev.axes argument to reverse the axes and a 
var.pos

argument to position  variable labels
  o vectors() now produces nicer arrow head a la matlib::vectors()
  o added var.pos argument to plot.candisc
  o allow to suppress likelihood ratio tests in print.candisc

Changes in version 0.7-0 (2016-04-25)

  o Added Wine data -- three cultivars with a very simple canonical 
structure

  o Added ellipses to plot.candisc(); enhanced candisc.Rd documentation
  o Added varOrder() for effect ordering in MLMs-- permutations of 
variables

according to various criteria for scatterplot matrices, etc.
  o plot.candisc() gets a var.labels argument
  o added method="colmean" and descending=T/F to varOrder()
  o plot.candisc() gets a rev.axes argument
  o fixed imports() in NAMESPACE for CRAN checks


## mvinfluence
## ---

Devel URL: https://r-forge.r-project.org/projects/mvinfluence/

Computes regression deletion diagnostics for multivariate linear models and
provides some associated diagnostic plots. The diagnostic measures 
include hat-

values (leverages), generalized Cook's distance, and generalized squared
'studentized' residuals. Several types of plots to detect influential
observations are provided.

Version 0.8 (2016-06-02)

o Fixed problems for CRAN: NAMESPACE, Rd files
o Added more examples to Rd files
o Added infIndexPlot for index plots of diagnostic measures
o Fixed buglet in influencePlot re: rownames of result

## matlib
## --

Devel URL: https://github.com/friendly/matlib
Issue tracker: https://github.com/friendly/matlib/issues

A collection of matrix functions for teaching and learning matrix
linear algebra as used in multivariate statistical methods. These 
functions are
mainly for tutorial purposes in learning matrix algebra ideas using R. 
In some
cases, functions are provided for concepts available elsewhere in R, but 
where
the function call or name is not obvious. In other cases, functions are 
provided
to show or demonstrate an algorithm. In addition, a collection of 
functions are
provided for drawing vector 

Re: [R] Antwort: RE: Antwort: Re: Merging variables

2016-06-09 Thread PIKAL Petr
Hi

Thanks for example.

see in line


> -Original Message-
> From: g.maub...@weinwolf.de [mailto:g.maub...@weinwolf.de]
> Sent: Wednesday, June 8, 2016 3:56 PM
> To: PIKAL Petr 
> Cc: r-help@r-project.org
> Subject: Antwort: RE: [R] Antwort: Re: Merging variables
>
> Hi Petr,
>
> thanks for your reply.
>
> I prepared little example for you:
>
> -- cut --
>
> ds_temp_1 <-
>   structure(list(
> CustId = c(1001, 1002, 1003, 1004, 1005, 1006),
> CustName = c("Miller", "Smith", "Doe", "White", "Black",
>  "Nobody"),
> sales = c(100, 500, 300, 50, 700, 10)
>   ),
>   .Names = c("CustId",
>  "CustName", "sales"), row.names = c(NA, 6L), class =
> "data.frame")
>
> ds_temp_2 <-
>   structure(
> list(
>   CustId = c(1001, 1002, 1003),
>   CustName = c("Miller",
>"Smith", "Doe"),
>   CustGroup = c(1, 2, 3)
> ),
> .Names = c("CustId",
>"CustName", "CustGroup"),
> row.names = c(NA, 3L),
> class = "data.frame"
>   )
>
> ds_merge <- merge(ds_temp_1, ds_temp_2,
>   by.x = "CustId", all.x = TRUE,
>   by.y = "CustId", all.y = FALSE)
>
> ds_merge
>
> -- cut --
>
> which gives
>
> ds_merge
>   CustId CustName.x sales CustName.y CustGroup
> 1   1001 Miller   100 Miller 1
> 2   1002  Smith   500  Smith 2
> 3   1003Doe   300Doe 3
> 4   1004  White50   NA
> 5   1005  Black   700   NA
> 6   1006 Nobody10   NA
>
> where CustName is split into CustName.x and CustName.y.
>
> What I would like to have is:
>
> ds_merge
>   CustId CustName   sales  CustGroup
> 1   1001 Miller   100  1
> 2   1002  Smith   500  2
> 3   1003Doe   300  3
> 4   1004  White50 NA
> 5   1005  Black   700 NA
> 6   1006 Nobody10 NA
>
> That is CustName in a single variable cause the values within that variable 
> are
> identical. I guess because of NA for some cases in ds_temp_2 R generates
> CustName.x and CustName.y.

Do not guess, try or read help page. The behavior is due to fact that ***you** 
restricted merge only on cust id and resulting data frame cannot have columns 
with the same names.

ds_merge <- merge(ds_temp_1, ds_temp_2, all.x = TRUE, all.y = FALSE)

Regards
Petr

>
> Is there a simple way of merging a dataset and having R return a single
> variable is the values are identical or missing in either one of the datasets?
>
> Kind regards
>
> Georg
>
>
>
>
>
> Von:PIKAL Petr 
> An: "g.maub...@weinwolf.de" ,
> Kopie:  "r-help@r-project.org" 
> Datum:  07.06.2016 13:11
> Betreff:RE: [R] Antwort: Re:  Merging variables
>
>
>
> Hi
>
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
> > g.maub...@weinwolf.de
> > Sent: Tuesday, June 7, 2016 8:19 AM
> > To: Michael Dewey 
> > Cc: r-help@r-project.org
> > Subject: [R] Antwort: Re: Merging variables
> >
> > Hi Michael,
> >
> > yes, I was astonished about this behaviour either. I have worked with
> SPSS a
> > lot - and that works different.
>
> If you want to join two data frames by common names you can use use
>
> merge(dat1, dat2, )
>
> without specifing by. From help page:
>
> By default the data frames are merged on the columns with names they both
> have, but separate specifications of the columns can be given by by.x and
> by.y. The rows in the two data frames that match on the specified columns
> are extracted, and joined together.
>
> >
> > I would like to share some of my data. Can you tell me how I can dump
> > a dataset in a way that I can post it here as text?
>
> copy result of dput directly to your mail
>
> dput(dat)
> structure(list(hz = c(0, 25, 50), vykon = c(0, 11.6, 22.6)), .Names = c("hz",
> "vykon"), row.names = c(NA, -3L), class = "data.frame")
>
> We can use
>
> dat <- structure(list(hz = c(0, 25, 50), vykon = c(0, 11.6, 22.6)), .Names =
> c("hz", "vykon"), row.names = c(NA, -3L), class = "data.frame")
>
> to reconstruct the object.
>
> Regards
> Petr
>
> >
> > Kind regards
> >
> > Georg
> >
> >
> >
> >
> > Von:Michael Dewey 
> > An: g.maub...@weinwolf.de, r-help@r-project.org,
> > Datum:  06.06.2016 15:45
> > Betreff:Re: [R] Merging variables
> >
> >
> >
> > X-Originating-<%= hostname %>-IP: [217.155.205.190]
> >
> > Dear Georg
> >
> > I find it a bit surprising that you end up with customer.x and
> customer.y. Can
> > you share with us a toy example of two data.frames which exhibit this
> > behaviour?
> >
> > On 06/06/2016 13:29, g.maub...@weinwolf.de wrote:
> > > Hi All,
> > >
> > > I merged two datasets:
> > >
> > > ds_merge1 <- merge(x = ds_bw_customer_4_match, y =
> > > ds_zww_customer_4_match,
> > >   by.x = 

Re: [R] Error: missing value where TRUE/FALSE needed

2016-06-09 Thread Ulrik Stervbo
Dear Shashi,

I don't see any code, but I will take a guess anyway:

The error tells you that you try to compare a boolean with something that
is not (TRUE or FALSE cannot be compared to NA).

HTH
Ulrik

On Thu, 9 Jun 2016 at 08:55 SHASHI SETH  wrote:

> Hi,
>
>
>
> I am getting the following error:
>
> Error in if ((sum > 0 && sums1 > 0 && sums2 > 0) != NA) { :
>
> missing value where TRUE/FALSE needed
>
>
>
>
>
> I have including my code below for your review:
>
>
>
> fitness_1_data
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[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: missing value where TRUE/FALSE needed

2016-06-09 Thread SHASHI SETH
Hi, 



I am getting the following error:

Error in if ((sum > 0 && sums1 > 0 && sums2 > 0) != NA) { : 

missing value where TRUE/FALSE needed





I have including my code below for your review:



fitness_1_data 
[[alternative HTML version deleted]]

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