Re: [R] findAssocs in TM package in R help?

2016-07-17 Thread Duncan Murdoch

On 17/07/2016 6:31 PM, Shivi Bhatia wrote:

Hi Team,

Please suggest.

On Sun, Jul 17, 2016 at 2:55 AM, Shivi Bhatia  wrote:


Good Day,

I am working on a text mining assignment and have built the document
matrix using the tm package.


We don't do homework here.  You should ask your instructor for help.

Duncan Murdoch



Now I need to run findAssocs from my dtm with some word say 'like' with a
correlation of 0.70 but  as far as i have been researching it tells it this
function is only viable when we have more than 1 doc however in my case i
only have 1. So please suggest if there is an alternate to this issue.

This is because there are words that correlate to each other in the data I
am dealing with.

Kindly advice.



[[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] means by year, month and day

2016-07-17 Thread jim holtman
Here is an example of using dplyr.  Please provide a reasonable subset of
data.  Your was all for the same date.  Use 'dput' to put in your email.

> x <- read.table(text = " X.YY MM DD hh WDI R.WSP D.GST   PRES  ATMP
DEWP
+   2015  1  1  0 328   3.6   4.5 1028.0   3.8  -3.5
+   2015  1  1  1 300   2.1   2.7 1027.9   3.7  -4.4
+   2015  1  1  2 264   2.4   2.9 1027.7   3.6  -4.5
+   2015  1  1  3 230   4.1   4.5 1027.4   4.2  -3.8
+   2015  1  1  4 242   8.1   9.2 1026.6   4.4  -3.1
+   2015  1  1  5 262   9.3  10.1 1026.6   4.1  -3.8
+   2015  1  1  6 267   8.6   9.6 1026.3   4.2  -3.8
+   2015  1  1  7 264   9.3   9.9 1026.1   3.9  -2.8
+   2015  1  1  8 268   8.2   9.1 1026.1   3.5  -3.0
+   2015  1  1  9 272   8.8   9.6 1025.4   3.2  -3.3
+   2015  2  1  0 328   3.6   4.5 1028.0   3.8  -3.5
+   2015  2  1  1 300   2.1   2.7 1027.9   3.7  -4.4
+   2015  2  1  2 264   2.4   2.9 1027.7   3.6  -4.5
+   2015  2  1  3 230   4.1   4.5 1027.4   4.2  -3.8
+   2015  2  1  4 242   8.1   9.2 1026.6   4.4  -3.1
+   2015  2  1  5 262   9.3  10.1 1026.6   4.1  -3.8
+   2015  2  1  6 267   8.6   9.6 1026.3   4.2  -3.8
+   2015  2  1  7 264   9.3   9.9 1026.1   3.9  -2.8
+   2015  2  1  8 268   8.2   9.1 1026.1   3.5  -3.0
+   2015  2  1  9 272   8.8   9.6 1025.4   3.2  -3.3
+   2015  3  1  0 328   3.6   4.5 1028.0   3.8  -3.5
+   2015  3  1  1 300   2.1   2.7 1027.9   3.7  -4.4
+   2015  3  1  2 264   2.4   2.9 1027.7   3.6  -4.5
+   2015  3  1  3 230   4.1   4.5 1027.4   4.2  -3.8
+   2015  3  1  4 242   8.1   9.2 1026.6   4.4  -3.1
+   2015  3  1  5 262   9.3  10.1 1026.6   4.1  -3.8
+   2015  3  1  6 267   8.6   9.6 1026.3   4.2  -3.8
+   2015  3  1  7 264   9.3   9.9 1026.1   3.9  -2.8
+   2015  3  1  8 268   8.2   9.1 1026.1   3.5  -3.0
+   2015  3  1  9 272   8.8   9.6 1025.4   3.2  -3.3
+  ",
+  header = TRUE,
+  as.is = TRUE)
>
>  library(dplyr)
>  by_year <- x %>%
+ group_by(X.YY) %>%
+ summarise_each(funs(mean))
>
>  by_ym <- x %>%
+ group_by(X.YY, MM ) %>%
+ summarise_each(funs(mean))
>
>  by_ymd <- x %>%
+ group_by(X.YY, MM, DD) %>%
+ summarise_each(funs(mean))
>
> by_year
Source: local data frame [1 x 10]
   X.YYMMDDhh   WDI R.WSP D.GSTPRES  ATMP  DEWP
 
1  2015 2 1   4.5 269.7  6.45  7.21 1026.81  3.86  -3.6
> by_ym
Source: local data frame [3 x 10]
Groups: X.YY [?]
   X.YYMMDDhh   WDI R.WSP D.GSTPRES  ATMP  DEWP
 
1  2015 1 1   4.5 269.7  6.45  7.21 1026.81  3.86  -3.6
2  2015 2 1   4.5 269.7  6.45  7.21 1026.81  3.86  -3.6
3  2015 3 1   4.5 269.7  6.45  7.21 1026.81  3.86  -3.6
> by_ymd
Source: local data frame [3 x 10]
Groups: X.YY, MM [?]
   X.YYMMDDhh   WDI R.WSP D.GSTPRES  ATMP  DEWP
 
1  2015 1 1   4.5 269.7  6.45  7.21 1026.81  3.86  -3.6
2  2015 2 1   4.5 269.7  6.45  7.21 1026.81  3.86  -3.6
3  2015 3 1   4.5 269.7  6.45  7.21 1026.81  3.86  -3.6
>


Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Sun, Jul 17, 2016 at 5:42 PM, Jianling Fan  wrote:

> Hello Tom,
>
> try aggregate() or cast(). Both works.I prefer the latter.
>
>
> library(reshape)
> desc<-melt(mydata, measure.vars=c("WDI","R.WSP", "D.GST", "PRES",
> "ATMP", "DEWP"),
>id.vars=c("X.YY","MM","DD"))
> summary<-cast(desc, X.YY+MM+DD~variable, mean)
>
>
>
>
>
>
>
>
>
> On 17 July 2016 at 06:22, Tom Mosca  wrote:
> > Hello Good Folk,
> >
> > My dataframe looks like this:
> >> mydata
> >  X.YY MM DD hh WDI R.WSP D.GST   PRES  ATMP  DEWP
> > 12015  1  1  0 328   3.6   4.5 1028.0   3.8  -3.5
> > 22015  1  1  1 300   2.1   2.7 1027.9   3.7  -4.4
> > 32015  1  1  2 264   2.4   2.9 1027.7   3.6  -4.5
> > 42015  1  1  3 230   4.1   4.5 1027.4   4.2  -3.8
> > 52015  1  1  4 242   8.1   9.2 1026.6   4.4  -3.1
> > 62015  1  1  5 262   9.3  10.1 1026.6   4.1  -3.8
> > 72015  1  1  6 267   8.6   9.6 1026.3   4.2  -3.8
> > 82015  1  1  7 264   9.3   9.9 1026.1   3.9  -2.8
> > 92015  1  1  8 268   8.2   9.1 1026.1   3.5  -3.0
> > 10   2015  1  1  9 272   8.8   9.6 1025.4   3.2  -3.3 …
> >
> > The first four columns are year, month, day, hour (0 – 23).  I wish to
> take the means of the next six columns (WDIR, WSPD, GST, PRES, ATMP and
> DEWP) by year, month and day.  That is, I want daily averages.
> >
> > Please help.  Thank you.
> >
> > Tom
> >
> > [[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.
>
>
>
> --
> Jianling Fan
> 樊建凌
>
> __

Re: [R] Type III SS and collinearity in R

2016-07-17 Thread Fox, John
Dear Pamela,

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Pamela
> Wong
> Sent: Sunday, July 17, 2016 1:58 AM
> To: r-help@r-project.org
> Subject: [R] Type III SS and collinearity in R
> 
> Hi there
> It appears the Anova() function in the car package cannot compute type
> III SS when there is collinearity in the model. Has anyone else run into
> this problem?

That's right, by default anyway -- when there's *perfect* collinearity -- but 
in that circumstance what would be the point? That is, the SSs for the 
collinear terms are 0. You can force Anova() to (arbitrarily) deal with the 
collinearities

> library(car)
> mod <- lm(prestige ~ income + education + I(income + education), data=Duncan)
> Anova(mod, type="III", singular.ok=TRUE)

Anova Table (Type III tests)

Response: prestige
  Sum Sq Df F valuePr(>F)
(Intercept)360.2  1  2.01540.1631
income4474.2  1 25.0331 1.053e-05 ***
education 5516.1  1 30.8626 1.727e-06 ***
I(income + education) 0  
Residuals 7506.7 42  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' '

But, again, what's the point?

> 
> I would use drop1() to obtain the SS but it does not provide the
> intercept...

Yes, drop1() reports the 0 SSs for all the collinear terms (on 0 df), which is 
better in a sense -- e.g.,

> drop1(mod)
Single term deletions

Model:
prestige ~ income + education + I(income + education)
  Df Sum of SqRSSAIC
 7506.7 236.26
income 0 0 7506.7 236.26
education  0 0 7506.7 236.26
I(income + education)  0 0 7506.7 236.26


Why would it be interesting in this circumstance to know whether the intercept 
is 0? As you can see, Anova() reports the test; you can also get it from 
linearHypothesis():

> linearHypothesis(mod, "(Intercept)", singular.ok=TRUE)
Linear hypothesis test

Hypothesis:
(Intercept) = 0

Model 1: restricted model
Model 2: prestige ~ income + education + I(income + education)

  Res.DfRSS Df Sum of Sq  F Pr(>F)
1 43 7866.9   
2 42 7506.7  1360.22 2.0154 0.1631

I suspect that there's a statistical issue lurking here that's not addressed by 
showing you how to get the tests you're asking for.

Best,
 John

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



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

2016-07-17 Thread Shivi Bhatia
Hi Team,

Please suggest.

On Sun, Jul 17, 2016 at 2:55 AM, Shivi Bhatia  wrote:

> Good Day,
>
> I am working on a text mining assignment and have built the document
> matrix using the tm package.
>
> Now I need to run findAssocs from my dtm with some word say 'like' with a
> correlation of 0.70 but  as far as i have been researching it tells it this
> function is only viable when we have more than 1 doc however in my case i
> only have 1. So please suggest if there is an alternate to this issue.
>
> This is because there are words that correlate to each other in the data I
> am dealing with.
>
> Kindly advice.
>

[[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] means by year, month and day

2016-07-17 Thread Jianling Fan
Hello Tom,

try aggregate() or cast(). Both works.I prefer the latter.


library(reshape)
desc<-melt(mydata, measure.vars=c("WDI","R.WSP", "D.GST", "PRES",
"ATMP", "DEWP"),
   id.vars=c("X.YY","MM","DD"))
summary<-cast(desc, X.YY+MM+DD~variable, mean)









On 17 July 2016 at 06:22, Tom Mosca  wrote:
> Hello Good Folk,
>
> My dataframe looks like this:
>> mydata
>  X.YY MM DD hh WDI R.WSP D.GST   PRES  ATMP  DEWP
> 12015  1  1  0 328   3.6   4.5 1028.0   3.8  -3.5
> 22015  1  1  1 300   2.1   2.7 1027.9   3.7  -4.4
> 32015  1  1  2 264   2.4   2.9 1027.7   3.6  -4.5
> 42015  1  1  3 230   4.1   4.5 1027.4   4.2  -3.8
> 52015  1  1  4 242   8.1   9.2 1026.6   4.4  -3.1
> 62015  1  1  5 262   9.3  10.1 1026.6   4.1  -3.8
> 72015  1  1  6 267   8.6   9.6 1026.3   4.2  -3.8
> 82015  1  1  7 264   9.3   9.9 1026.1   3.9  -2.8
> 92015  1  1  8 268   8.2   9.1 1026.1   3.5  -3.0
> 10   2015  1  1  9 272   8.8   9.6 1025.4   3.2  -3.3 …
>
> The first four columns are year, month, day, hour (0 – 23).  I wish to take 
> the means of the next six columns (WDIR, WSPD, GST, PRES, ATMP and DEWP) by 
> year, month and day.  That is, I want daily averages.
>
> Please help.  Thank you.
>
> Tom
>
> [[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.



-- 
Jianling Fan
樊建凌

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

2016-07-17 Thread Tom Mosca
Hello Good Folk,

My dataframe looks like this:
> mydata
 X.YY MM DD hh WDI R.WSP D.GST   PRES  ATMP  DEWP
12015  1  1  0 328   3.6   4.5 1028.0   3.8  -3.5
22015  1  1  1 300   2.1   2.7 1027.9   3.7  -4.4
32015  1  1  2 264   2.4   2.9 1027.7   3.6  -4.5
42015  1  1  3 230   4.1   4.5 1027.4   4.2  -3.8
52015  1  1  4 242   8.1   9.2 1026.6   4.4  -3.1
62015  1  1  5 262   9.3  10.1 1026.6   4.1  -3.8
72015  1  1  6 267   8.6   9.6 1026.3   4.2  -3.8
82015  1  1  7 264   9.3   9.9 1026.1   3.9  -2.8
92015  1  1  8 268   8.2   9.1 1026.1   3.5  -3.0
10   2015  1  1  9 272   8.8   9.6 1025.4   3.2  -3.3 �

The first four columns are year, month, day, hour (0 � 23).  I wish to take the 
means of the next six columns (WDIR, WSPD, GST, PRES, ATMP and DEWP) by year, 
month and day.  That is, I want daily averages.

Please help.  Thank you.

Tom

[[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] daily means, follow-up

2016-07-17 Thread Tom Mosca
Solved it myself:

aggregate(mydata, by=mydata[c("MM","DD")], FUN=mean)

Thank you.



# -

My dataframe looks like this:
> mydata
 X.YY MM DD hh WDI R.WSP D.GST   PRES  ATMP  DEWP
12015  1  1  0 328   3.6   4.5 1028.0   3.8  -3.5
22015  1  1  1 300   2.1   2.7 1027.9   3.7  -4.4
32015  1  1  2 264   2.4   2.9 1027.7   3.6  -4.5
42015  1  1  3 230   4.1   4.5 1027.4   4.2  -3.8
52015  1  1  4 242   8.1   9.2 1026.6   4.4  -3.1
62015  1  1  5 262   9.3  10.1 1026.6   4.1  -3.8
72015  1  1  6 267   8.6   9.6 1026.3   4.2  -3.8
82015  1  1  7 264   9.3   9.9 1026.1   3.9  -2.8
92015  1  1  8 268   8.2   9.1 1026.1   3.5  -3.0
10   2015  1  1  9 272   8.8   9.6 1025.4   3.2  -3.3 �

The first four columns are year, month, day, hour (0 � 23).  I wish to take the 
means of the next six columns (WDIR, WSPD, GST, PRES, ATMP and DEWP) by day.

[[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] Type III SS and collinearity in R

2016-07-17 Thread Pamela Wong
Hi there
It appears the Anova() function in the car package cannot compute type III SS 
when there is collinearity in the model. Has anyone else run into this problem? 

I would use drop1() to obtain the SS but it does not provide the intercept...
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Troubleshooting Type III SS and drop1()

2016-07-17 Thread Fox, John
Dear Pamela,

It's very hard to tell from your message what you did, but I'm guessing that 
you passed the object produced by Anova() to drop1(). If this is in fact what 
you did, it makes no sense, because Anova() doesn't produce a linear-model 
object but rather takes such an object as its argument.

I hope this helps,
 John

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



> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Pamela
> Wong
> Sent: Saturday, July 16, 2016 1:12 AM
> To: r-help@r-project.org
> Subject: [R] Troubleshooting Type III SS and drop1()
> 
> Hi there
> 
> I am trying to compute Type III SS plus model selection and find that an
> error pops up when I'm trying to use the drop1() function with a model
> output using Anova(). I am looking at effects of four factors and their
> interactions (with unbalanced sample sizes across some factor groups),
> on a continuous variable.
> 
> I get an error that reads: "Error in terms.default(object) : no terms
> component not attribute". I also can't compute an AIC for the model
> outputs.
> 
> I am wondering if there is something I need to do to my data or if there
> is some limitation to the analysis I am trying to do.
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] Matrix

2016-07-17 Thread David Winsemius

> On Jul 16, 2016, at 7:43 PM, Ashta  wrote:
> 
> HI Denes, Duncan,Michael and all,
> 
> Thank you very much  for the helpful suggestion.  Some of my data sets
> were not square matrix, however, Denes's suggestion,"
> as.data.frame.table() ", handled that one.
> 

`as.data.frame.table` should work with any matrix, not just sqaure ones:

m <- matrix(1:12, 3, 4,
   dimnames = list(dimA = letters[1:3],
   dimB = letters[1:4]))
m
#-
dimB
dimA a b c  d
   a 1 4 7 10
   b 2 5 8 11
   c 3 6 9 12
#
 as.data.frame.table(m, responseName = "value")
   dimA dimB value

1 aa 1
2 ba 2
3 ca 3
4 ab 4
5 bb 5
6 cb 6
7 ac 7
8 bc 8
9 cc 9
10ad10
11bd11
12cd12




> Thank you again.
> 
> 
> On Sat, Jul 16, 2016 at 7:27 PM, Dénes Tóth  wrote:
>> 
>> 
>> On 07/17/2016 01:39 AM, Duncan Murdoch wrote:
>>> 
>>> On 16/07/2016 6:25 PM, Ashta wrote:
 Hi all,
 
 I have a large square matrix (60 x 60)  and found it hard to
 visualize. Is it possible to change it  as shown below?
 
 Sample example (3 x 3)
 
A   B   C
 A  3   4   5
 B  4   7   8
 C  5   8   9
 
 Desired output
 A A  3
 A B  4
 A C  5
 B B  7
 B C  8
 C C  9
>>> 
>>> Yes, use matrix indexing.  I don't think the 3600 values are going to be
>>> very easy to read, but here's how to produce them:
>>> 
>>> m <- matrix(1:3600, 60, 60)
>>> indices <- expand.grid(row = 1:60, col = 1:60)
>>> cbind(indices$row, indices$col, m[as.matrix(indices)])
>>> 
>> 
>> Or use as.data.frame.table():
>> 
>> m <- matrix(1:9, 3, 3,
>>dimnames = list(dimA = letters[1:3],
>>dimB = letters[1:3]))
>> m
>> as.data.frame.table(m, responseName = "value")
>> 
>> ---
>> 
>> I do not know what you mean by "visualize", but image() or heatmap() are
>> good starting points if you need a plot of the values. If you really need to
>> inspect the raw values, you can try interactive (scrollable) tables, e.g.:
>> 
>> library(DT)
>> m <- provideDimnames(matrix(1:3600, 60, 60))
>> datatable(m, options = list(pageLength = 60))
>> 
>> 
>> Cheers,
>>  Denes
>> 
>> 
>> 
>> 
>>> Duncan Murdoch
>>> 
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

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

Re: [R] writing a matrix to a file with trailing zeroes

2016-07-17 Thread Duncan Murdoch

On 17/07/2016 11:33 AM, Erin Hodgess wrote:

Hello everyone!

I'm looking at this problem, and I'm sure there is a straightforward
solution.  I have a matrix and some of the values have zeroes to the right
of the decimal point.  When I write these to a file, the zeroes disappear.
The material below is what I have tried so far.




x2

  x  y
[1,] -1.3611521  5.000
[2,] -0.8521120 -1.0512976
[3,] -0.9652820 -0.1306795
[4,] -0.4319187  1.2483199
[5,] -0.7548402  1.3404867
[6,]  6.000  2.500


write.table(sprintf("%.1f",t(x2)),row.name=FALSE,col.name=FALSE,file="")

"-1.4"
"5.0"
"-0.9"
"-1.1"
"-1.0"
"-0.1"
"-0.4"
"1.2"
"-0.8"
"1.3"
"6.0"
"2.5"

write(sprintf("%.1f",t(x2)),file="")

-1.4
5.0
-0.9
-1.1
-1.0
-0.1
-0.4
1.2
-0.8
1.3
6.0
2.5

write(round(t(x2),1),file="")

-1.4 5 -0.9 -1.1 -1
-0.1 -0.4 1.2 -0.8 1.3
6 2.5

write(round(t(x2),1),file="",ncol=2)

-1.4 5
-0.9 -1.1
-1 -0.1
-0.4 1.2
-0.8 1.3
6 2.5





Still no luck.  I need the 5 in the first line to be 5.0 and the 6 in the
last line to be 6.0.

Any suggestions, please?


Your second try comes close.  Why not just add ncol=2 to it, i.e.

write(sprintf("%.1f",t(x2)),file="", ncol=2)

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] Solution to my own question

2016-07-17 Thread Erin Hodgess
write.table(format(x2,drop0trailing=FALSE),file="",col.name=FALSE,row.name
=FALSE,quote=FALSE)

-- 
Erin Hodgess
Associate Professor
Department of Mathematical and Statistics
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

[[alternative HTML version deleted]]

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


[R] writing a matrix to a file with trailing zeroes

2016-07-17 Thread Erin Hodgess
Hello everyone!

I'm looking at this problem, and I'm sure there is a straightforward
solution.  I have a matrix and some of the values have zeroes to the right
of the decimal point.  When I write these to a file, the zeroes disappear.
The material below is what I have tried so far.



> x2
  x  y
[1,] -1.3611521  5.000
[2,] -0.8521120 -1.0512976
[3,] -0.9652820 -0.1306795
[4,] -0.4319187  1.2483199
[5,] -0.7548402  1.3404867
[6,]  6.000  2.500

>write.table(sprintf("%.1f",t(x2)),row.name=FALSE,col.name=FALSE,file="")
"-1.4"
"5.0"
"-0.9"
"-1.1"
"-1.0"
"-0.1"
"-0.4"
"1.2"
"-0.8"
"1.3"
"6.0"
"2.5"
> write(sprintf("%.1f",t(x2)),file="")
-1.4
5.0
-0.9
-1.1
-1.0
-0.1
-0.4
1.2
-0.8
1.3
6.0
2.5
> write(round(t(x2),1),file="")
-1.4 5 -0.9 -1.1 -1
-0.1 -0.4 1.2 -0.8 1.3
6 2.5
> write(round(t(x2),1),file="",ncol=2)
-1.4 5
-0.9 -1.1
-1 -0.1
-0.4 1.2
-0.8 1.3
6 2.5
>


Still no luck.  I need the 5 in the first line to be 5.0 and the 6 in the
last line to be 6.0.

Any suggestions, please?

Thanks,
Erin

-- 
Erin Hodgess
Associate Professor
Department of Mathematical and Statistics
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] newbee Caret load question

2016-07-17 Thread peter dalgaard
The R version was not stated (RStudio is a shell, so you cannot infer the 
version of R from its version number), but the warning messages suggest that it 
is less than 3.2.3. Recent versions of pbkrtest depend on R >= 3.2.3. I happen 
to know that because it led to infelicities which should probably have been 
avoided by not introducing new features in the middle of the 3.2.x series. 

I.e., an upgrade of R is what is called for.

-pd

> On 17 Jul 2016, at 07:50 , Jim Lemon  wrote:
> 
> Hi Lawrence,
> Try installing pbkrtest on its own:
> 
> update.packages("pbkrtest")
> 
> version 0.4.6 is up  on CRAN, so this may allow you to make an end run.
> 
> Jim
> 
> 
> On Sun, Jul 17, 2016 at 2:06 AM, Lawrence A. Janowitch
>  wrote:
>> I'm trying to load the caret package in R-Studio (Version 0.99.902) on a
>> Windows 10 OS using bootcamp windows connection on a MacBook Pro.
>> 
>> I have used caret in the past, with no problems.
>> 
>> 
>> 
>> My issue is I don't understand what this means and what I should do about
>> it.
>> 
>> 
>> 
>> I get:
>> 
>> 
>> 
>>> library(caret)
>> 
>> Loading required package: lattice
>> 
>> Loading required package: ggplot2
>> 
>> Need help? Try the ggplot2 mailing list:
>> http://groups.google.com/group/ggplot2.
>> 
>> Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck =
>> vI[[j]]) :
>> 
>>  namespace 'pbkrtest' 0.4-2 is being loaded, but >= 0.4.4 is required
>> 
>> In addition: Warning messages:
>> 
>> 1: package 'caret' was built under R version 3.2.5
>> 
>> 2: package 'ggplot2' was built under R version 3.2.3
>> 
>> Error: package or namespace load failed for 'caret'
>> 
>> 
>> 
>> Any help would be much appreciated.
>> 
>> Thank you.
>> 
>> 
>>[[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.

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

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