[R] Is there a tool to find unused functions?

2017-11-15 Thread Alexander Engelhardt
I've inherited a large R codebase which has grown over a few years and a 
few different developers.


It contains many things I'd like to delete:
- Unused functions
- Variable definitions that are never called
- Unreachable code

I'd write that myself, it would even be fun, but I don't want to 
reinvent the wheel.

Is there an R package that can find these things?

I've heard of lintr, but I'm not sure if it's the right tool, since, 
unfortunately, the code is in a folder (not a package) with many R files 
that are sourced from one master file and lintr can only check a single 
file or an actual package, from what I understand. A workaround of 
course would be to concatenate all files into one R script.


I'd appreciate any hints on how to best solve this.

Thanks in advance,
Alex

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

2017-11-15 Thread Jeremie Juste


Hello,

I tried intalling mice package and got the following error:

* installing *source* package ‘mice’ ...
** package ‘mice’ successfully unpacked and MD5 sums checked
** libs
g++  -I/usr/local/lib/R/include -DNDEBUG  
-I"/home/djj/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" 
-I/usr/local/include   -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
g++  -I/usr/local/lib/R/include -DNDEBUG  
-I"/home/djj/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" 
-I/usr/local/include   -fpic  -g -O2  -c match.cpp -o match.o
g++ -shared -L/usr/local/lib -o mice.so RcppExports.o match.o Welcome to R! 
Goodbye!
g++: error: Welcome: No such file or directory
g++: error: to: No such file or directory
g++: error: R!: No such file or directory
g++: error: Goodbye!: No such file or directory
/usr/local/lib/R/share/make/shlib.mk:6: recipe for target 'mice.so' failed
make: *** [mice.so] Error 1
ERROR: compilation failed for package ‘mice’
* removing ‘/home/djj/R/x86_64-pc-linux-gnu-library/3.4/mice’

The downloaded source packages are in
‘/tmp/Rtmpgam70t/downloaded_packages’
Error in library(mice) : there is no package called ‘mice’
In addition: Warning message:
In install.packages(deparse(substitute(mice)), repos = 
"http://cran.us.r-project.org";) :
  installation of package ‘mice’ had non-zero exit status

I'm unable to resolve it. Any help please?

Best regards,

Jeremie

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Is there a tool to find unused functions?

2017-11-15 Thread Michael Hannon
mvbutils::foodweb produces a graphical display of the hierarchy (or
network or ...) of function calls.  Isolated functions are not called.
This might help you.

-- Mike


On Wed, Nov 15, 2017 at 12:44 AM, Alexander Engelhardt
 wrote:
> I've inherited a large R codebase which has grown over a few years and a few
> different developers.
>
> It contains many things I'd like to delete:
> - Unused functions
> - Variable definitions that are never called
> - Unreachable code
>
> I'd write that myself, it would even be fun, but I don't want to reinvent
> the wheel.
> Is there an R package that can find these things?
>
> I've heard of lintr, but I'm not sure if it's the right tool, since,
> unfortunately, the code is in a folder (not a package) with many R files
> that are sourced from one master file and lintr can only check a single file
> or an actual package, from what I understand. A workaround of course would
> be to concatenate all files into one R script.
>
> I'd appreciate any hints on how to best solve this.
>
> Thanks in advance,
> Alex
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] Problems installing mice package

2017-11-15 Thread Jérémie Juste
Hello,

The installation of the developpment version seems to go through
https://github.com/stefvanbuuren/mice,

Best regards,

Jeremie

On Wed, Nov 15, 2017 at 10:08 AM, Jeremie Juste 
wrote:

>
>
> Hello,
>
> I tried intalling mice package and got the following error:
>
> * installing *source* package ‘mice’ ...
> ** package ‘mice’ successfully unpacked and MD5 sums checked
> ** libs
> g++  -I/usr/local/lib/R/include -DNDEBUG  -I"/home/djj/R/x86_64-pc-
> linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include   -fpic  -g -O2
> -c RcppExports.cpp -o RcppExports.o
> g++  -I/usr/local/lib/R/include -DNDEBUG  -I"/home/djj/R/x86_64-pc-
> linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include   -fpic  -g -O2
> -c match.cpp -o match.o
> g++ -shared -L/usr/local/lib -o mice.so RcppExports.o match.o Welcome to
> R! Goodbye!
> g++: error: Welcome: No such file or directory
> g++: error: to: No such file or directory
> g++: error: R!: No such file or directory
> g++: error: Goodbye!: No such file or directory
> /usr/local/lib/R/share/make/shlib.mk:6: recipe for target 'mice.so' failed
> make: *** [mice.so] Error 1
> ERROR: compilation failed for package ‘mice’
> * removing ‘/home/djj/R/x86_64-pc-linux-gnu-library/3.4/mice’
>
> The downloaded source packages are in
> ‘/tmp/Rtmpgam70t/downloaded_packages’
> Error in library(mice) : there is no package called ‘mice’
> In addition: Warning message:
> In install.packages(deparse(substitute(mice)), repos = "
> http://cran.us.r-project.org";) :
>   installation of package ‘mice’ had non-zero exit status
>
> I'm unable to resolve it. Any help please?
>
> Best regards,
>
> Jeremie
>



-- 
Jérémie Juste

[[alternative HTML version deleted]]

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

[R] How to read PMML data from a text file and convert it to a model ?

2017-11-15 Thread Ashim Kapoor
Dear All,

I want to save the XML representation of a model using PMML. Then I want to
read the model and predict using the model and a new  dataset.

This is described in this blog post :
https://www.r-bloggers.com/predictive-modeling-using-r-and-the-openscoring-engine-a-pmml-approach/

I am able to save the PMML representation of the model. I am not able to
read this representation convert it into  a model.  How can I do that ?

Here is a MWE :

library(pmml)
mydata<- iris

# Creating a model

mymodel <- lm(Sepal.Length ~ Sepal.Width, data = mydata)
#Computing its pmml representation and storing it to a file
saveXML(pmml(mymodel),file = "myfile.xml")

testingReading <- fileToXMLNode("myfile.txt")

> testingReading
http://www.dmg.org/PMML-4_3";>
 
  
  2017-11-15T10:37:29Z
 
 
  
  
 
 
  
   
   
  
  
   
  
 

Warning messages:
1: In structure(x$children, class = "XMLNodeList") :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have
attributes.
  Consider 'structure(list(), *)' instead.
2: In structure(x$children, class = "XMLNodeList") :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have
attributes.
  Consider 'structure(list(), *)' instead.
3: In structure(x$children, class = "XMLNodeList") :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have
attributes.
  Consider 'structure(list(), *)' instead.
4: In structure(x$children, class = "XMLNodeList") :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have
attributes.
  Consider 'structure(list(), *)' instead.
5: In structure(x$children, class = "XMLNodeList") :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have
attributes.
  Consider 'structure(list(), *)' instead.
6: In structure(x$children, class = "XMLNodeList") :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have
attributes.
  Consider 'structure(list(), *)' instead.
>

Can someone show me how to extract the model from the variable
testingReading and predict using this model at the values of rnorm(100) ?

Best Regards,
Ashim

[[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] Is there a tool to find unused functions?

2017-11-15 Thread Alexander Engelhardt
Thanks, that helps! The visualization is very messy, because I have 
about 100 functions, but foodweb() returns a matrix of which function 
calls which, and the functions callers.of("myfunc") and 
callees.of("myfunc") do exactly what I was looking for.


 - Alex


On 11/15/2017 10:44 AM, Michael Hannon wrote:

mvbutils::foodweb produces a graphical display of the hierarchy (or
network or ...) of function calls.  Isolated functions are not called.
This might help you.

-- Mike


On Wed, Nov 15, 2017 at 12:44 AM, Alexander Engelhardt
 wrote:

I've inherited a large R codebase which has grown over a few years and a few
different developers.

It contains many things I'd like to delete:
- Unused functions
- Variable definitions that are never called
- Unreachable code

I'd write that myself, it would even be fun, but I don't want to reinvent
the wheel.
Is there an R package that can find these things?

I've heard of lintr, but I'm not sure if it's the right tool, since,
unfortunately, the code is in a folder (not a package) with many R files
that are sourced from one master file and lintr can only check a single file
or an actual package, from what I understand. A workaround of course would
be to concatenate all files into one R script.

I'd appreciate any hints on how to best solve this.

Thanks in advance,
Alex

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

[R] ks.test() with 2 samples vs. 1 sample an distr. function

2017-11-15 Thread tonja . krueger
Dear all,
I have a question concerning the ks.test() function. I tryed to calculate the 
example given on the German wikipedia page.
xi <- c(9.41,9.92,11.55,11.6,11.73,12,12.06,13.3)
I get the right results when I calculate: ks.test(xi,pnorm,11,1)
Now the question: shouldn't I obtain the same or a very similar result if I 
commpare the sample and a calculated sample from the distribution?
p<- c(0.125, 0.250, 0.375, 0.500, 0.625, 0.750, 0.875, 0.)
x <- qnorm(p,11,1)
ks.test(xi,x)
Why don't I?
Thanks for helping me!
Tonja

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


Re: [R] NEED HELP : Association in single DTM

2017-11-15 Thread Boris Steipe
If you consider the definition of a DTM, and that findAssoc() computes 
associations between words as correlations across documents(!), you will 
realize that you can't what you want from a single document. Indeed, what kind 
of an "association" would you even be looking for?

B.



> On Nov 15, 2017, at 12:40 AM, Rahul singh  wrote:
> 
> I have free text data in a single text document. I create a corpus, and
> then a document term matrix out of it. I can create a word cloud too.
> 
> But when I do word association for the same, using "findAssocs(), it always
> returns numeric(0).
> 
> EX : findAssocs(dtm, "king" ,0.1)
> 
> I read on stack overflow that it is because I have a single document.
> 
> What is the workaround for the same ?
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] error message for function: lmer (from lme4 package)

2017-11-15 Thread Bert Gunter
Always cc the list, which I have done here. I am not a (free) private
consultant, nor do I have all the answers.

Based on what you sent me, which is not what you have previously posted,
you failed to load the lme3 package. See ?library.

As for the appropriateness of your modeling, you should do what David
already suggested and post to the r-sig-mixed-models list instead.

-- 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 Wed, Nov 15, 2017 at 5:09 AM, Fix Ace  wrote:

> Hi, Bert,
>
> Sorry about that! David seemed to be able to read the post since he
> replied. Here I just email you the sample code and error message:
>
> > example.3=data.frame(levels=as.numeric(XXX[,c(4)]),
> replicate=rep(c("0","1","2","3","4","5"),3),conditions=c(rep("11",6),rep("12",6),rep(>
> example.3
> levels replicate conditions
> 1  43. 0 11
> 2  42.0942 1 11
> 3  57.8131 2 11
> 4  57.1726 3 11
> 5  77.8678 4 11
> 6  44.7578 5 11
> 7  69.5078 0 12
> 8  52.0581 1 12
> 9  40.0602 2 12
> 10 45.5487 3 12
> 11 43.6201 4 12
> 12 60.4939 5 12
> 13 64.1932 0 13
> 14 53.4055 1 13
> 15 59.6701 2 13
> 16 52.6922 3 13
> 17 53.8712 4 13
> 18 60.2770 5 13
> > m.example.3=lmer(as.numeric(levels)~conditions+(
> conditions|replicate),data=example.3)
> Error in lmer(as.numeric(levels) ~ conditions + (conditions | replicate),
> :
>   could not find function "lmer"
> >
>
> Hopefully you could read it and provide some comments!
>
> Thank you very much for your time.
>
> Kind regards,
>
> Ace
>
>
>
>
> On Tuesday, November 14, 2017 6:12 PM, Bert Gunter 
> wrote:
>
>
> Still a complete mess!
>
> Post in **plain text**. This should be an option in your email software.
> Please seek local help if you cannot figure out how to do this.
>
> -- 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 Tue, Nov 14, 2017 at 12:49 PM, Fix Ace via R-help  > wrote:
>
> Hi, David,
> Thank you very much for getting back to me! Sorry about the messy code
> example. I am re-posting here (including the error message):
> > example.3=data.frame(levels= as.numeric(XXX[,c(4)]),
> replicate=rep(c("0","1","2"," 3","4","5"),3),conditions=c(
> rep("11",6),rep("12",6),rep(" 13",6)))> example.3levels replicate
> conditions1  43. 0 112  42.0942 1 113
> 57.8131 2 114  57.1726 3 115  77.8678
>   4 116  44.7578 5 117  69.5078 0
> 128  52.0581 1 129  40.0602 2 1210 45.5487
> 3 1211 43.6201 4 1212 60.4939 5
> 1213 64.1932 0 1314 53.4055 1 1315
> 59.6701 2 1316 52.6922 3 1317 53.8712
>   4 1318 60.2770 5 13> m.example.3=lmer(as.numeric(
> levels)~conditions+( conditions|replicate),data= example.3)Error: number of
> observations (=18) <= number of random effects (=18) for term (conditions |
> replicate); the random-effects parameters and the residual variance (or
> scale parameter) are probably unidentifiable>
> Please let me know if it is readable this time.
> Again, many thanks for your time and please help me fix the issue.
> Kind regards,
> Ace
>
> On Tuesday, November 14, 2017 12:19 PM, David Winsemius <
> dwinsem...@comcast.net> wrote:
>
>
>
> > On Nov 14, 2017, at 5:13 AM, Fix Ace via R-help 
> wrote:
> >
> > Dear R Community,
> > My data have 3 conditions and each condition has 6 replicates. I am
> trying to fit my data for a linear mixed model using the lmer function from
> lme4 package to find the random effects of the replicates;
>
> Better venue for this question might be SIG-mixed-models. See the link
> avaialble at the bottom of every posting from rhelp:
>
> https://stat.ethz.ch/mailman/ listinfo/r-help
> :
>
>
>
> > however, I got the error message. Here are the example codes:
> >> example.3=data.frame(levels= as.numeric(XXX[,c(4)]),
> replicate=rep(c("0","1","2"," 3","4","5"),3),conditions=c(
> rep("11",6),rep("12",6),rep(" 13",6)))> example.3levels replicate
> conditions1  43.0112  42.09421113
> 57.81312114  57.17263115  77.86784
>   116  44.75785117  69.50780128
> 52.05811129  40.060221210 45.54873
>   1211 43.6201 

Re: [R] ks.test() with 2 samples vs. 1 sample an distr. function

2017-11-15 Thread David L Carlson
In the first example you are performing a one-sample test against a continuous 
cumulative distribution (in this case a normal distribution). In the second 
case you are performing a two-sample test. You drew your values for x 
non-randomly by specifying fixed intervals along a normal distribution, but 
ks.test() just sees that you have provided two samples, not one sample and 
values along a cumulative distribution.


David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77843-4352


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of 
tonja.krue...@web.de
Sent: Wednesday, November 15, 2017 3:47 AM
To: r-help@r-project.org
Subject: [R] ks.test() with 2 samples vs. 1 sample an distr. function

Dear all,
I have a question concerning the ks.test() function. I tryed to calculate the 
example given on the German wikipedia page.
xi <- c(9.41,9.92,11.55,11.6,11.73,12,12.06,13.3)
I get the right results when I calculate: ks.test(xi,pnorm,11,1) Now the 
question: shouldn't I obtain the same or a very similar result if I commpare 
the sample and a calculated sample from the distribution?
p<- c(0.125, 0.250, 0.375, 0.500, 0.625, 0.750, 0.875, 0.) x <- 
qnorm(p,11,1)
ks.test(xi,x)
Why don't I?
Thanks for helping me!
Tonja

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

2017-11-15 Thread William Dunlap via R-help
Your lapply is making the call
   runif(n=3, min=i)
for i in 1:3.  That runif's 3 argument is 'max', with default value 1
so that is equivalent to calling
   runif(n=3, min=i, max=1)
When i>max, outside the domain of the family of uniform distributions,
runif returns NaN's.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Nov 14, 2017 at 5:11 PM, Bert Gunter  wrote:

> Could someone please explain the following? I did check bug reports, but
> did not recognize the issue there. I am reluctant to call it a bug, as it
> is much more likely my misunderstanding. Ergo my request for clarification:
>
> ## As expected:
>
> > lapply(1:3, rnorm, n = 3)
> [[1]]
> [1] 2.481575 1.998182 1.312786
>
> [[2]]
> [1] 2.858383 1.827863 1.699015
>
> [[3]]
> [1] 1.821910 2.530091 3.995677
>
>
> ## Unexpected by me:
>
> > lapply(1:3, runif, n = 3)
> [[1]]
> [1] 1 1 1
>
> [[2]]
> [1] NaN NaN NaN
>
> [[3]]
> [1] NaN NaN NaN
>
> Warning messages:
> 1: In FUN(X[[i]], ...) : NAs produced
> 2: In FUN(X[[i]], ...) : NAs produced
>
>
> ## But note, as expected:
>
> > lapply(1:3, function(x)runif(3))
> [[1]]
> [1] 0.2950459 0.8490556 0.4303680
>
> [[2]]
> [1] 0.5961144 0.5330914 0.2363679
>
> [[3]]
> [1] 0.8079495 0.1431838 0.3671915
>
>
>
> Many thanks for any clarification.
>
> -- Bert
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] Problems installing mice package

2017-11-15 Thread David Winsemius

> On Nov 15, 2017, at 1:08 AM, Jeremie Juste  wrote:
> 
> 
> 
> Hello,
> 
> I tried intalling mice package and got the following error:
> 
> * installing *source* package ‘mice’ ...
> ** package ‘mice’ successfully unpacked and MD5 sums checked
> ** libs
> g++  -I/usr/local/lib/R/include -DNDEBUG  
> -I"/home/djj/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" 
> -I/usr/local/include   -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
> g++  -I/usr/local/lib/R/include -DNDEBUG  
> -I"/home/djj/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" 
> -I/usr/local/include   -fpic  -g -O2  -c match.cpp -o match.o
> g++ -shared -L/usr/local/lib -o mice.so RcppExports.o match.o Welcome to R! 
> Goodbye!

Somehow you have sent an R "welcome message" to the installer script. What was 
the action that started all this? Were you in an R session or was this 
something done from a bash console?

> g++: error: Welcome: No such file or directory
> g++: error: to: No such file or directory
> g++: error: R!: No such file or directory
> g++: error: Goodbye!: No such file or directory
> /usr/local/lib/R/share/make/shlib.mk:6: recipe for target 'mice.so' failed
> make: *** [mice.so] Error 1
> ERROR: compilation failed for package ‘mice’
> * removing ‘/home/djj/R/x86_64-pc-linux-gnu-library/3.4/mice’
> 
> The downloaded source packages are in
>   ‘/tmp/Rtmpgam70t/downloaded_packages’
> Error in library(mice) : there is no package called ‘mice’
> In addition: Warning message:
> In  :

That's a rather strange method for invoking install.packages. Usually it would 
be just:

install.packages("mice", repos = "http://cran.us.r-project.org";)



Your best venue for linux installation questions is probably:

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


>  installation of package ‘mice’ had non-zero exit status
> 
> I'm unable to resolve it. Any help please?
> 
> Best regards,
> 
> Jeremie
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law

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

Re: [R] Autologistic regression in R

2017-11-15 Thread David Winsemius

> On Nov 14, 2017, at 4:39 PM, Mingke Li  wrote:
> 
> Hi,
> 
> I am new to autologistic regression and R. I do have questions when starting 
> a project in which I believe autologistic regression is needed.
> 
> I have a point layer whose attribute table stores the values of the dependent 
> variable and all the independent variables. I hope to to fit an autologistic 
> model to analyze which factors or combinations of factors have effects on the 
> presence/absence of the dependent variable (1 or 0).
> 
> I found other papers which applied autologistic regression in their study 
> almost used a grid system and defined their window sizes. So, my question is 
> do I have to convert my point layer to a grid system if I want to do this 
> analysis with R?
> 
> Also, what should I consider when I generate the grid system? How to 
> determine a proper size of cells? How about the searching window sizes?

Have you read the Posting Guide?

-- 
David.
> 
> Many Thanks.
> 
> Erin
> 
> 
>   [[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

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law

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


[R] R6 object that is a list of referenced object

2017-11-15 Thread Cristina Pascual
Dear community,


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


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

) # Person


I have created:

Person1 <- Particle$new(1,'a',4)

Person2 <- Particle$new(2,'b',5)


and I also have a class Community:


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


I want to create


Community1 = List


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


Community1 <- Community1$add(Person2)


)


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


Can anybody help me?

Thanks in advance,


[[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] R6 object that is a list of referenced object

2017-11-15 Thread Cristina Pascual
Dear community,

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

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

) # Person

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

and I also have a class Community:

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

I want to create

Community1 = List

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

Community1 <- Community1$add(Person2)

)

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

Can anybody help me?

Thanks in advance,



[[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] Problems installing mice package

2017-11-15 Thread Jérémie Juste
Hello,

Many thanks for your time

My mistake was to put  in the .Rprofile.
I've never got any problem with the package installation before though.

Best regards,

Jeremie


On Wed, Nov 15, 2017 at 6:49 PM, David Winsemius 
wrote:

>
> > On Nov 15, 2017, at 1:08 AM, Jeremie Juste 
> wrote:
> >
> >
> >
> > Hello,
> >
> > I tried intalling mice package and got the following error:
> >
> > * installing *source* package ‘mice’ ...
> > ** package ‘mice’ successfully unpacked and MD5 sums checked
> > ** libs
> > g++  -I/usr/local/lib/R/include -DNDEBUG  -I"/home/djj/R/x86_64-pc-
> linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include   -fpic  -g -O2
> -c RcppExports.cpp -o RcppExports.o
> > g++  -I/usr/local/lib/R/include -DNDEBUG  -I"/home/djj/R/x86_64-pc-
> linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include   -fpic  -g -O2
> -c match.cpp -o match.o
> > g++ -shared -L/usr/local/lib -o mice.so RcppExports.o match.o Welcome to
> R! Goodbye!
>
> Somehow you have sent an R "welcome message" to the installer script. What
> was the action that started all this? Were you in an R session or was this
> something done from a bash console?
>
> > g++: error: Welcome: No such file or directory
> > g++: error: to: No such file or directory
> > g++: error: R!: No such file or directory
> > g++: error: Goodbye!: No such file or directory
> > /usr/local/lib/R/share/make/shlib.mk:6: recipe for target 'mice.so'
> failed
> > make: *** [mice.so] Error 1
> > ERROR: compilation failed for package ‘mice’
> > * removing ‘/home/djj/R/x86_64-pc-linux-gnu-library/3.4/mice’
> >
> > The downloaded source packages are in
> >   ‘/tmp/Rtmpgam70t/downloaded_packages’
> > Error in library(mice) : there is no package called ‘mice’
> > In addition: Warning message:
> > In  :
>
> That's a rather strange method for invoking install.packages. Usually it
> would be just:
>
> install.packages("mice", repos = "http://cran.us.r-project.org";)
>
>
>
> Your best venue for linux installation questions is probably:
>
> https://stat.ethz.ch/mailman/listinfo/r-sig-db
>
>
> >  installation of package ‘mice’ had non-zero exit status
> >
> > I'm unable to resolve it. Any help please?
> >
> > Best regards,
> >
> > Jeremie
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius
> Alameda, CA, USA
>
> 'Any technology distinguishable from magic is insufficiently advanced.'
>  -Gehm's Corollary to Clarke's Third Law
>
>
>
>
>
>


-- 
Jérémie Juste

[[alternative HTML version deleted]]

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

[R] Creating a SQL R package

2017-11-15 Thread João Paulo Lemes Machado
Hello everyone. My name is João Paulo I am a
master's student in the course of  omputer
science.

I intend to create a package for the R that
makes the SQL language commands available for use. I know that there are
already some packages that execute SQL commands within R. However, most of
these commands require querys to be passed as a string. I wish SQL commands
could be used more naturally.

For example: If I want to select all the columns
of a dataframe by limiting the first 10 rows I use the following command:
dataframe [1:10,]

In SQL would be: Select * from datarrame limit
10.

My idea is to ease the transition of people
which as I have enough knowledge in SQL, and enable that R can be used as a
mysql workbench to execute querys on databases. What do you think? Any tips on
where to start?

[[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] Rasterize function with maximum in R

2017-11-15 Thread Ashraf Afana via R-help
 
Hi all,

I have some concerns regarding the rasterize option in R and I would like to 
know if the fun=max in rasterize in R provides similar results to the one 
achieved by using "Polygon to Raster using maximum-combined-area" in ArcGIS?

I'm trying to rasterize a habitat layer to a raster of 10m spatial resolution 
using the function 'max' (e.g. r <- rasterize(ht, r, "Priority", fun = 'max') 
and I would like to assign the habitat of the largest overlapping area, which 
is similar to the “maximum-combined-area”. My original layer contains the 
habitat information as a character string values (e.g. K1, K2, I1, I2, I3, 
etc.) of 20 classes. Before resterizing, I have converted these classes to 
numeric (e.g. in my case 1 to 20).
I have my doubts about the validity and type of maximums generated by this 
code. From what I can see, I’m not sure if the use of fun= ‘max’ in Rasterize 
in R implies the use of the absolute maximum or the combined maximum area. My 
point is if I convert the original character string values of Priority to 
numeric, the maximum for the numeric values will have nothing to do with the 
maximum combined area under cover. For example, if we have a pixel which is 
covered by 90% of habitat 1 and 10% of habitat 15, the value of the pixel will 
be assigned to the habitat 15. Does that make any sense? Any suggestion or 
clarification would be appreciated.Regards
 Ashraf, 


[[alternative HTML version deleted]]

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

Re: [R] Creating a SQL R package

2017-11-15 Thread Hasan Diwan
Joao,

On 15 November 2017 at 05:39, João Paulo Lemes Machado <
lemesmach...@gmail.com> wrote:

> I intend to create a package for the R that
> makes the SQL language commands available for use.  What do you think? Any
> tips on
> where to start?
>

https://github.com/ggrothendieck/sqldf seems to be what you're trying to
duplicate. -- H



-- 
OpenPGP: https://sks-keyservers.net/pks/lookup?op=
get&search=0xFEBAD7FFD041BBA1
If you wish to request my time, please do so using http://bit.ly/
hd1ScheduleRequest.
Si vous voudrais faire connnaisance, allez a http://bit.ly/
hd1ScheduleRequest.

Sent
from my mobile device
Envoye de mon portable

[[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] Rasterize function with maximum in R

2017-11-15 Thread Bert Gunter
I believe you should post this on the r-sig-geo list, not here. You are
much more likely to find the relevant expertise 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 Wed, Nov 15, 2017 at 7:13 AM, Ashraf Afana via R-help <
r-help@r-project.org> wrote:

>
> Hi all,
>
> I have some concerns regarding the rasterize option in R and I would like
> to know if the fun=max in rasterize in R provides similar results to the
> one achieved by using "Polygon to Raster using maximum-combined-area" in
> ArcGIS?
>
> I'm trying to rasterize a habitat layer to a raster of 10m spatial
> resolution using the function 'max' (e.g. r <- rasterize(ht, r, "Priority",
> fun = 'max') and I would like to assign the habitat of the largest
> overlapping area, which is similar to the “maximum-combined-area”. My
> original layer contains the habitat information as a character string
> values (e.g. K1, K2, I1, I2, I3, etc.) of 20 classes. Before resterizing, I
> have converted these classes to numeric (e.g. in my case 1 to 20).
> I have my doubts about the validity and type of maximums generated by this
> code. From what I can see, I’m not sure if the use of fun= ‘max’ in
> Rasterize in R implies the use of the absolute maximum or the combined
> maximum area. My point is if I convert the original character string values
> of Priority to numeric, the maximum for the numeric values will have
> nothing to do with the maximum combined area under cover. For example, if
> we have a pixel which is covered by 90% of habitat 1 and 10% of habitat 15,
> the value of the pixel will be assigned to the habitat 15. Does that make
> any sense? Any suggestion or clarification would be appreciated.Regards
>  Ashraf,
>
>
> [[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] Converting a string to variable names

2017-11-15 Thread 刘瑞阳
Hi,

Thanks for your reply.

I just came up with another question about a similar but different thing:

Say I have a bunch of data.frame variables named P1,P2,P3… I want to assign 
them row names according to symbols in the first column, and I want to do this 
using a for loop. How could I accomplish this?


for (test_sample in c(1:10)){
+ x<-as.name(paste(“P",as.character(test_sampel),sep=""))
+ rownames(x)<-get((paste(“P”,as.character(test_sample),sep="")))[,1]
+ }

This would not work probably because x is simply a name instead of a data.frame 
variable(Error: "attempt to set 'rownames' on an object with no dimensions"). 
But I could not find the right way out… How should I solve it?

Thanks!

Ruiyang


> On Nov 14, 2017, at 4:39 PM, Jim Lemon  wrote:
> 
> Hi Ruiyang,
> I think you want "get":
> 
> For (index in seq(1,16)){
> plot(x=(a given set of value),y=get(paste(“PC”,as.character(index),sep=“”)))
> }
> 
> On Wed, Nov 15, 2017 at 7:43 AM, 刘瑞阳  wrote:
>> Hi,
>> Suppose that I want to do a series of plots with the y value for each plot 
>> as PC1, PC2, PC3… How could I accomplish this using a for loop?
>> Suppose the code like this:
>> 
>> For (index in seq(1,16)){
>> plot(x=(a given set of value),y=paste(“PC”,as.character(index),sep=“”)
>> }
>> 
>> But this would not work because y is assigned a string instead of the 
>> variable names. So how could I assign y with a variable name instead of a 
>> string? Your reply would be appreciated!
>> Ruiyang Liu
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/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] Converting a string to variable names

2017-11-15 Thread Jim Lemon
Hi Ruiyang,
In this case you don't want the "get", just the strings produced by "paste":

mydf<-data.frame(col1=LETTERS[1:10],col2=1:10)
rownames(mydf)<-paste("P",mydf$col1,sep="")

Jim

On Thu, Nov 16, 2017 at 9:22 AM, 刘瑞阳  wrote:
> Hi,
>
> Thanks for your reply.
>
> I just came up with another question about a similar but different thing:
>
> Say I have a bunch of data.frame variables named P1,P2,P3… I want to assign 
> them row names according to symbols in the first column, and I want to do 
> this using a for loop. How could I accomplish this?
>
>
> for (test_sample in c(1:10)){
> + x<-as.name(paste(“P",as.character(test_sampel),sep=""))
> + rownames(x)<-get((paste(“P”,as.character(test_sample),sep="")))[,1]
> + }
>
> This would not work probably because x is simply a name instead of a 
> data.frame variable(Error: "attempt to set 'rownames' on an object with no 
> dimensions"). But I could not find the right way out… How should I solve it?
>
> Thanks!
>
> Ruiyang
>
>
>> On Nov 14, 2017, at 4:39 PM, Jim Lemon  wrote:
>>
>> Hi Ruiyang,
>> I think you want "get":
>>
>> For (index in seq(1,16)){
>> plot(x=(a given set of value),y=get(paste(“PC”,as.character(index),sep=“”)))
>> }
>>
>> On Wed, Nov 15, 2017 at 7:43 AM, 刘瑞阳  wrote:
>>> Hi,
>>> Suppose that I want to do a series of plots with the y value for each plot 
>>> as PC1, PC2, PC3… How could I accomplish this using a for loop?
>>> Suppose the code like this:
>>>
>>> For (index in seq(1,16)){
>>> plot(x=(a given set of value),y=paste(“PC”,as.character(index),sep=“”)
>>> }
>>>
>>> But this would not work because y is assigned a string instead of the 
>>> variable names. So how could I assign y with a variable name instead of a 
>>> string? Your reply would be appreciated!
>>> Ruiyang Liu
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/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] NEED HELP : Association in single DTM

2017-11-15 Thread Rahul singh
Hi Boris,

In that case, if I have lot of free text data (let us assume part of an
Election speech) in one single TEXT document, and i want to find the
association of the top 3 most frequently occurring words with the other
words in the speech, what method do I adopt ?

On Wed, Nov 15, 2017 at 7:08 PM, Boris Steipe 
wrote:

> If you consider the definition of a DTM, and that findAssoc() computes
> associations between words as correlations across documents(!), you will
> realize that you can't what you want from a single document. Indeed, what
> kind of an "association" would you even be looking for?
>
> B.
>
>
>
> > On Nov 15, 2017, at 12:40 AM, Rahul singh 
> wrote:
> >
> > I have free text data in a single text document. I create a corpus, and
> > then a document term matrix out of it. I can create a word cloud too.
> >
> > But when I do word association for the same, using "findAssocs(), it
> always
> > returns numeric(0).
> >
> > EX : findAssocs(dtm, "king" ,0.1)
> >
> > I read on stack overflow that it is because I have a single document.
> >
> > What is the workaround for the same ?
> >
> >   [[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] NEED HELP : Association in single DTM

2017-11-15 Thread Bert Gunter
In general, statistical methodology queries, which seems to be your
concern,  are offtopic here.This list is about R programming.  Consider
stats.stackexchange.com  for statistical queries.

However, the CRAN task view on natural language processing might be useful,
so you may wish to check it:

https://cran.r-project.org/web/views/NaturalLanguageProcessing.html

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 Wed, Nov 15, 2017 at 6:17 PM, Rahul singh  wrote:

> Hi Boris,
>
> In that case, if I have lot of free text data (let us assume part of an
> Election speech) in one single TEXT document, and i want to find the
> association of the top 3 most frequently occurring words with the other
> words in the speech, what method do I adopt ?
>
> On Wed, Nov 15, 2017 at 7:08 PM, Boris Steipe 
> wrote:
>
> > If you consider the definition of a DTM, and that findAssoc() computes
> > associations between words as correlations across documents(!), you will
> > realize that you can't what you want from a single document. Indeed, what
> > kind of an "association" would you even be looking for?
> >
> > B.
> >
> >
> >
> > > On Nov 15, 2017, at 12:40 AM, Rahul singh 
> > wrote:
> > >
> > > I have free text data in a single text document. I create a corpus, and
> > > then a document term matrix out of it. I can create a word cloud too.
> > >
> > > But when I do word association for the same, using "findAssocs(), it
> > always
> > > returns numeric(0).
> > >
> > > EX : findAssocs(dtm, "king" ,0.1)
> > >
> > > I read on stack overflow that it is because I have a single document.
> > >
> > > What is the workaround for the same ?
> > >
> > >   [[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.
>

[[alternative HTML version deleted]]

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


Re: [R] NEED HELP : Association in single DTM

2017-11-15 Thread Boris Steipe
No - the CRAN task view is not going to help you at all, since you need to 
think more about the question that you are trying to ask before you can start 
worrying about which packages to pursue it with.

In your case this hinges on the question what you mean by "association". In the 
same phrase? In the same sentence? Adjacent? Or separated by k words? For what 
k?

Once you come clear on that, we can probably show you ways to translate your 
procedure into R code. But - as Bert mentioned - we are not well positioned to 
define the procedure for you.

Boris




> On Nov 15, 2017, at 10:35 PM, Bert Gunter  wrote:
> 
> In general, statistical methodology queries, which seems to be your concern,  
> are offtopic here.This list is about R programming.  Consider 
> stats.stackexchange.com  for statistical queries. 
> 
> However, the CRAN task view on natural language processing might be useful, 
> so you may wish to check it:
> 
> https://cran.r-project.org/web/views/NaturalLanguageProcessing.html
> 
> 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 Wed, Nov 15, 2017 at 6:17 PM, Rahul singh  wrote:
> Hi Boris,
> 
> In that case, if I have lot of free text data (let us assume part of an
> Election speech) in one single TEXT document, and i want to find the
> association of the top 3 most frequently occurring words with the other
> words in the speech, what method do I adopt ?
> 
> On Wed, Nov 15, 2017 at 7:08 PM, Boris Steipe 
> wrote:
> 
> > If you consider the definition of a DTM, and that findAssoc() computes
> > associations between words as correlations across documents(!), you will
> > realize that you can't what you want from a single document. Indeed, what
> > kind of an "association" would you even be looking for?
> >
> > B.
> >
> >
> >
> > > On Nov 15, 2017, at 12:40 AM, Rahul singh 
> > wrote:
> > >
> > > I have free text data in a single text document. I create a corpus, and
> > > then a document term matrix out of it. I can create a word cloud too.
> > >
> > > But when I do word association for the same, using "findAssocs(), it
> > always
> > > returns numeric(0).
> > >
> > > EX : findAssocs(dtm, "king" ,0.1)
> > >
> > > I read on stack overflow that it is because I have a single document.
> > >
> > > What is the workaround for the same ?
> > >
> > >   [[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] R6 object that is a list of referenced object

2017-11-15 Thread Jeff Newmiller

See below.

On Wed, 15 Nov 2017, Cristina Pascual wrote:


Dear community,

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

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


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



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

) # Person

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

and I also have a class Community:

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


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



)
)

I want to create

Community1 = List

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

)

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

Can anybody help me?

Thanks in advance,


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



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


 , name

 , age

 ) {

   self$idPerson <- 
idPerson


   self$name <- name

   self$age <- age

 }
 ) # public
  ) # Person

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

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


, addPerson = function( p ) {

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

  }

)
)

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

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

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

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

#> name: b

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






[[alternative HTML version deleted]]


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




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



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Res