[R] nlm() giving initials as estimates of parameters

2016-04-14 Thread amina

Hi R community

I have written a loglikelihood function which I am minimizing using 
nlm().
nlm() is giving me no results...I mean, I am getting initial values as 
estimates. No iteration.
I have tried many initials value close to true values and far away from 
tru values. But every time I
am getting initial values as estimates and no iteration. Anybody can 
guide why this happens.


Thank You

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Bug in by() function which works for some FUN argument and does not work for others

2016-04-14 Thread Jim Lemon
Hi Dr Singh,
The object mtcars is a data frame and the mean is not defined for a
data frame. If you try it on a component of the data frame for which
mean is defined:

 by(mtcars$mpg,mtcars$am,mean)
mtcars$am: 0
[1] 17.14737

mtcars$am: 1
[1] 24.39231

Jim

On Fri, Apr 15, 2016 at 6:14 AM, Akhilesh Singh
 wrote:
> Dear Sirs,
>
> I am Professor at Indira Gandhi Krishi Vishwavidyalaya, Raipur,
> Chhattisgarh, India.
>
> While taking classes, I found the *by() *function producing following error
> when I use FUN=mean or median and some other functions, however,
> FUN=summary works.
>
> Given below is the output of the example I used on a built-in dataset
> "mtcars", along with error message reproduced herewith:
>
>> by(data=mtcars, INDICES=list(mtcars$am), FUN=mean)
> : 0
> [1] NA
> 
> : 1
> [1] NA
> Warning messages:
> 1: In mean.default(data[x, , drop = FALSE], ...) :
>   argument is not numeric or logical: returning NA
> 2: In mean.default(data[x, , drop = FALSE], ...) :
>   argument is not numeric or logical: returning NA
>
> However, the same by() function works for FUN=summary, given below is the
> output:
>
>> by(data=mtcars, INDICES=list(mtcars$am), FUN=summary)
> : 0
>   mpg cyl disp hp
>  Min.   :10.40   Min.   :4.000   Min.   :120.1   Min.   : 62.0
>  1st Qu.:14.95   1st Qu.:6.000   1st Qu.:196.3   1st Qu.:116.5
>  Median :17.30   Median :8.000   Median :275.8   Median :175.0
>  Mean   :17.15   Mean   :6.947   Mean   :290.4   Mean   :160.3
>  3rd Qu.:19.20   3rd Qu.:8.000   3rd Qu.:360.0   3rd Qu.:192.5
>  Max.   :24.40   Max.   :8.000   Max.   :472.0   Max.   :245.0
>   drat wt qsec vs   am
>
>  Min.   :2.760   Min.   :2.465   Min.   :15.41   Min.   :0.   Min.   :0
>
>  1st Qu.:3.070   1st Qu.:3.438   1st Qu.:17.18   1st Qu.:0.   1st Qu.:0
>
>  Median :3.150   Median :3.520   Median :17.82   Median :0.   Median :0
>
>  Mean   :3.286   Mean   :3.769   Mean   :18.18   Mean   :0.3684   Mean   :0
>
>  3rd Qu.:3.695   3rd Qu.:3.842   3rd Qu.:19.17   3rd Qu.:1.   3rd Qu.:0
>
>  Max.   :3.920   Max.   :5.424   Max.   :22.90   Max.   :1.   Max.   :0
>
>   gearcarb
>  Min.   :3.000   Min.   :1.000
>  1st Qu.:3.000   1st Qu.:2.000
>  Median :3.000   Median :3.000
>  Mean   :3.211   Mean   :2.737
>  3rd Qu.:3.000   3rd Qu.:4.000
>  Max.   :4.000   Max.   :4.000
> 
> : 1
>   mpg cyl disp hp drat
>
>  Min.   :15.00   Min.   :4.000   Min.   : 71.1   Min.   : 52.0   Min.
> :3.54
>  1st Qu.:21.00   1st Qu.:4.000   1st Qu.: 79.0   1st Qu.: 66.0   1st
> Qu.:3.85
>  Median :22.80   Median :4.000   Median :120.3   Median :109.0   Median
> :4.08
>  Mean   :24.39   Mean   :5.077   Mean   :143.5   Mean   :126.8   Mean
> :4.05
>  3rd Qu.:30.40   3rd Qu.:6.000   3rd Qu.:160.0   3rd Qu.:113.0   3rd
> Qu.:4.22
>  Max.   :33.90   Max.   :8.000   Max.   :351.0   Max.   :335.0   Max.
> :4.93
>wt qsec vs   am gear
>
>  Min.   :1.513   Min.   :14.50   Min.   :0.   Min.   :1   Min.   :4.000
>
>  1st Qu.:1.935   1st Qu.:16.46   1st Qu.:0.   1st Qu.:1   1st Qu.:4.000
>
>  Median :2.320   Median :17.02   Median :1.   Median :1   Median :4.000
>
>  Mean   :2.411   Mean   :17.36   Mean   :0.5385   Mean   :1   Mean   :4.385
>
>  3rd Qu.:2.780   3rd Qu.:18.61   3rd Qu.:1.   3rd Qu.:1   3rd Qu.:5.000
>
>  Max.   :3.570   Max.   :19.90   Max.   :1.   Max.   :1   Max.   :5.000
>
>   carb
>  Min.   :1.000
>  1st Qu.:1.000
>  Median :2.000
>  Mean   :2.923
>  3rd Qu.:4.000
>  Max.   :8.000
>>
>
> I am using the latest version of *R-3.2.4 on Windows*, however, this error
> is being generated in the previous version too,
>
> Hope this reporting will get serious attention in debugging.
>
> With best regards,
>
> Dr. A.K. Singh
> Head, Department of Agril. Statistics
> Indira Gandhi Krishi Vishwavidyalaya, Raipur
> Chhattisgarh, India, PIN-492012
> Mobile: +919752620740
> Email: akhileshsingh.i...@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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Unequal column lengths

2016-04-14 Thread Jim Lemon
Hi Tom,
What you want is a list rather than a data frame. So:

df<-read.table(text="  Dat1 Dat2 Dat3
 1154
 2779
 3335
 42   NA  5
 59   NA NA",
 header=TRUE)
dflist<-as.list(df)
na.remove<-function(x) return(x[!is.na(x)])
sapply(dflist,na.remove)

Jim

On Fri, Apr 15, 2016 at 7:33 AM, Tom Mosca  wrote:
> Hello,
>
> I’ve tried several times to learn R, but have never gotten past a particular 
> gate.  My data are organized by column in Excel, with column headers in the 
> first row.  The columns are of unequal lengths.  I export them as CSV, then 
> import the CSV file into R.  I wish to summarize the data by column.  R 
> inserts NA for missing values, then refuses to operate on columns with NA.  R 
> is importing my data into a data frame, and I realize that is inappropriate 
> for what I want to do.
>
> How can I import my data so that I can work on columns of unequal length?  
> The first thing I would like to do is generate a table containing mean, 
> median, mode, standard deviation, min, max and count, all per column.
>
> Thank you, Tom
>
> Example data
>   Dat1 Dat2 Dat3
> 1154
> 2779
> 3335
> 42   NA  5
> 59   NA NA
>
> [[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] Unequal column lengths

2016-04-14 Thread David Winsemius

> On Apr 14, 2016, at 2:33 PM, Tom Mosca  wrote:
> 
> Hello,
> 
> I�ve tried several times to learn R, but have never gotten past a particular 
> gate.  My data are organized by column in Excel, with column headers in the 
> first row.  The columns are of unequal lengths.  I export them as CSV, then 
> import the CSV file into R.  I wish to summarize the data by column.  R 
> inserts NA for missing values, then refuses to operate on columns with NA.  R 
> is importing my data into a data frame, and I realize that is inappropriate 
> for what I want to do.
> 
> How can I import my data so that I can work on columns of unequal length?  
> The first thing I would like to do is generate a table containing mean, 
> median, mode, standard deviation, min, max and count, all per column.
> 

Most of the summary statistic functions have an na.rm options that you should 
set to TRUE.


> Thank you, Tom
> 
> Example data
>  Dat1 Dat2 Dat3
> 1154
> 2779
> 3335
> 42   NA  5
> 59   NA NA

Looks like you have an R dataframe already, so I would try(

colMeans(data, na.rm=TRUE)


> 
>   [[alternative HTML version deleted]]

And do learn to configure your email client to post to r-help in plain text.

> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] Bug in by() function which works for some FUN argument and does not work for others

2016-04-14 Thread Bert Gunter
You're right, but I think this fails to pinpoint the error. The
problem is that FUN's argument is  "applied to (usually data-frame)
subsets of data,"  and the OP has used FUN = mean, which takes a
vector (+ a few other classes), not a data frame, as argument. See
?mean

Morals:

1.  It is rather presumptuous to think that long used, well-tested,
core R functionality like by() have bugs; a (new?) user's first
thought should be to assume it is HIS error, not R's.


2. DO read the Help docs carefully. They are often terse, but usually
they mean what they (appear to) say.

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, Apr 14, 2016 at 2:36 PM, Adrian Dușa  wrote:
> I think you are not using the best function for what your intentions are.
> Try:
>
>> by(data=mtcars, INDICES=list(as.factor(mtcars$am)), FUN=colMeans)
> : 0
> mpg cyldisp  hpdrat  wt
>qsec  vs
>  17.1473684   6.9473684 290.3789474 160.2631579   3.2863158   3.7688947
>  18.1831579   0.3684211
>  amgearcarb
>   0.000   3.2105263   2.7368421
> ---
> : 1
> mpg cyldisp  hpdrat  wt
>qsec  vs
>  24.3923077   5.0769231 143.5307692 126.8461538   4.050   2.411
>  17.360   0.5384615
>  amgearcarb
>   1.000   4.3846154   2.9230769
>
> See the difference between colMeans() and mean() in their respective help
> files.
> Hth,
> Adrian
>
> On Thu, Apr 14, 2016 at 11:14 PM, Akhilesh Singh <
> akhileshsingh.i...@gmail.com> wrote:
>
>> Dear Sirs,
>>
>> I am Professor at Indira Gandhi Krishi Vishwavidyalaya, Raipur,
>> Chhattisgarh, India.
>>
>> While taking classes, I found the *by() *function producing following error
>> when I use FUN=mean or median and some other functions, however,
>> FUN=summary works.
>>
>> Given below is the output of the example I used on a built-in dataset
>> "mtcars", along with error message reproduced herewith:
>>
>> > by(data=mtcars, INDICES=list(mtcars$am), FUN=mean)
>> : 0
>> [1] NA
>> 
>> : 1
>> [1] NA
>> Warning messages:
>> 1: In mean.default(data[x, , drop = FALSE], ...) :
>>   argument is not numeric or logical: returning NA
>> 2: In mean.default(data[x, , drop = FALSE], ...) :
>>   argument is not numeric or logical: returning NA
>>
>> However, the same by() function works for FUN=summary, given below is the
>> output:
>>
>> > by(data=mtcars, INDICES=list(mtcars$am), FUN=summary)
>> : 0
>>   mpg cyl disp hp
>>  Min.   :10.40   Min.   :4.000   Min.   :120.1   Min.   : 62.0
>>  1st Qu.:14.95   1st Qu.:6.000   1st Qu.:196.3   1st Qu.:116.5
>>  Median :17.30   Median :8.000   Median :275.8   Median :175.0
>>  Mean   :17.15   Mean   :6.947   Mean   :290.4   Mean   :160.3
>>  3rd Qu.:19.20   3rd Qu.:8.000   3rd Qu.:360.0   3rd Qu.:192.5
>>  Max.   :24.40   Max.   :8.000   Max.   :472.0   Max.   :245.0
>>   drat wt qsec vs   am
>>
>>  Min.   :2.760   Min.   :2.465   Min.   :15.41   Min.   :0.   Min.   :0
>>
>>  1st Qu.:3.070   1st Qu.:3.438   1st Qu.:17.18   1st Qu.:0.   1st Qu.:0
>>
>>  Median :3.150   Median :3.520   Median :17.82   Median :0.   Median :0
>>
>>  Mean   :3.286   Mean   :3.769   Mean   :18.18   Mean   :0.3684   Mean   :0
>>
>>  3rd Qu.:3.695   3rd Qu.:3.842   3rd Qu.:19.17   3rd Qu.:1.   3rd Qu.:0
>>
>>  Max.   :3.920   Max.   :5.424   Max.   :22.90   Max.   :1.   Max.   :0
>>
>>   gearcarb
>>  Min.   :3.000   Min.   :1.000
>>  1st Qu.:3.000   1st Qu.:2.000
>>  Median :3.000   Median :3.000
>>  Mean   :3.211   Mean   :2.737
>>  3rd Qu.:3.000   3rd Qu.:4.000
>>  Max.   :4.000   Max.   :4.000
>> 
>> : 1
>>   mpg cyl disp hp drat
>>
>>  Min.   :15.00   Min.   :4.000   Min.   : 71.1   Min.   : 52.0   Min.
>> :3.54
>>  1st Qu.:21.00   1st Qu.:4.000   1st Qu.: 79.0   1st Qu.: 66.0   1st
>> Qu.:3.85
>>  Median :22.80   Median :4.000   Median :120.3   Median :109.0   Median
>> :4.08
>>  Mean   :24.39   Mean   :5.077   Mean   :143.5   Mean   :126.8   Mean
>> :4.05
>>  3rd Qu.:30.40   3rd Qu.:6.000   3rd Qu.:160.0   3rd Qu.:113.0   3rd
>> Qu.:4.22
>>  Max.   :33.90   Max.   :8.000   Max.   :351.0   Max.   :335.0   Max.
>> :4.93
>>wt qsec vs   am gear
>>
>>  Min.   :1.513   Min.   :14.50   Min.   :0.   Min.   :1   Min.   :4.000
>>
>>  1st Qu.:1.935   1st Qu.:16.46   1st Qu.:0.   1st Qu.:1   1st Qu.:4.000
>>
>>  Median :2.320   Median :17.02   

[R] Unequal column lengths

2016-04-14 Thread Tom Mosca
Hello,

I�ve tried several times to learn R, but have never gotten past a particular 
gate.  My data are organized by column in Excel, with column headers in the 
first row.  The columns are of unequal lengths.  I export them as CSV, then 
import the CSV file into R.  I wish to summarize the data by column.  R inserts 
NA for missing values, then refuses to operate on columns with NA.  R is 
importing my data into a data frame, and I realize that is inappropriate for 
what I want to do.

How can I import my data so that I can work on columns of unequal length?  The 
first thing I would like to do is generate a table containing mean, median, 
mode, standard deviation, min, max and count, all per column.

Thank you, Tom

Example data
  Dat1 Dat2 Dat3
1154
2779
3335
42   NA  5
59   NA NA

[[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] a replace for subset

2016-04-14 Thread Bert Gunter
A mess!
Please follow the posting guide: post in *plain text*, not 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 Thu, Apr 14, 2016 at 1:14 PM, ch.elahe via R-help
 wrote:
> Hi,I have a data set (mydata), which a part of this is like the following:  
> 'data.frame':   36190 obs. of 16 variables:$ RE: int  38 
> 41 11 67 30 18 38 41 41 30 ...$ LU : int  4200 3330 530 
> 4500 3000 1790 4700 3400 3640 4000 ...$ COUNTRY: Factor w/ 4 levels 
> "DE","FR","JP", "FR"…$Light  : Factor w/2 levels   
> "ON","OFF","ON", ….$OR : Factor w/2 levels   
> "S","T","S",….$PAT  : Factor w/3 levels   "low", "high", 
> "middle",….  Now I want to plot RE vs LU with ggplot2 for all the possible 
> cases, I know how to do subsetting for the data but I want to know is there 
> any shorter way to do that? For example I want to have a plot for RE vs LU 
> for (COUNTRY= FR, Light=off, OR=S, PAT=low) and one for (COUNTRY= FR, 
> Light=on, OR=S, PAT=high) and …., as you see doing subset is time consuming, 
> is there any other way?Thank you for any help.Elahe
> [[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] Bug in by() function which works for some FUN argument and does not work for others

2016-04-14 Thread Adrian Dușa
I think you are not using the best function for what your intentions are.
Try:

> by(data=mtcars, INDICES=list(as.factor(mtcars$am)), FUN=colMeans)
: 0
mpg cyldisp  hpdrat  wt
   qsec  vs
 17.1473684   6.9473684 290.3789474 160.2631579   3.2863158   3.7688947
 18.1831579   0.3684211
 amgearcarb
  0.000   3.2105263   2.7368421
---
: 1
mpg cyldisp  hpdrat  wt
   qsec  vs
 24.3923077   5.0769231 143.5307692 126.8461538   4.050   2.411
 17.360   0.5384615
 amgearcarb
  1.000   4.3846154   2.9230769

See the difference between colMeans() and mean() in their respective help
files.
Hth,
Adrian

On Thu, Apr 14, 2016 at 11:14 PM, Akhilesh Singh <
akhileshsingh.i...@gmail.com> wrote:

> Dear Sirs,
>
> I am Professor at Indira Gandhi Krishi Vishwavidyalaya, Raipur,
> Chhattisgarh, India.
>
> While taking classes, I found the *by() *function producing following error
> when I use FUN=mean or median and some other functions, however,
> FUN=summary works.
>
> Given below is the output of the example I used on a built-in dataset
> "mtcars", along with error message reproduced herewith:
>
> > by(data=mtcars, INDICES=list(mtcars$am), FUN=mean)
> : 0
> [1] NA
> 
> : 1
> [1] NA
> Warning messages:
> 1: In mean.default(data[x, , drop = FALSE], ...) :
>   argument is not numeric or logical: returning NA
> 2: In mean.default(data[x, , drop = FALSE], ...) :
>   argument is not numeric or logical: returning NA
>
> However, the same by() function works for FUN=summary, given below is the
> output:
>
> > by(data=mtcars, INDICES=list(mtcars$am), FUN=summary)
> : 0
>   mpg cyl disp hp
>  Min.   :10.40   Min.   :4.000   Min.   :120.1   Min.   : 62.0
>  1st Qu.:14.95   1st Qu.:6.000   1st Qu.:196.3   1st Qu.:116.5
>  Median :17.30   Median :8.000   Median :275.8   Median :175.0
>  Mean   :17.15   Mean   :6.947   Mean   :290.4   Mean   :160.3
>  3rd Qu.:19.20   3rd Qu.:8.000   3rd Qu.:360.0   3rd Qu.:192.5
>  Max.   :24.40   Max.   :8.000   Max.   :472.0   Max.   :245.0
>   drat wt qsec vs   am
>
>  Min.   :2.760   Min.   :2.465   Min.   :15.41   Min.   :0.   Min.   :0
>
>  1st Qu.:3.070   1st Qu.:3.438   1st Qu.:17.18   1st Qu.:0.   1st Qu.:0
>
>  Median :3.150   Median :3.520   Median :17.82   Median :0.   Median :0
>
>  Mean   :3.286   Mean   :3.769   Mean   :18.18   Mean   :0.3684   Mean   :0
>
>  3rd Qu.:3.695   3rd Qu.:3.842   3rd Qu.:19.17   3rd Qu.:1.   3rd Qu.:0
>
>  Max.   :3.920   Max.   :5.424   Max.   :22.90   Max.   :1.   Max.   :0
>
>   gearcarb
>  Min.   :3.000   Min.   :1.000
>  1st Qu.:3.000   1st Qu.:2.000
>  Median :3.000   Median :3.000
>  Mean   :3.211   Mean   :2.737
>  3rd Qu.:3.000   3rd Qu.:4.000
>  Max.   :4.000   Max.   :4.000
> 
> : 1
>   mpg cyl disp hp drat
>
>  Min.   :15.00   Min.   :4.000   Min.   : 71.1   Min.   : 52.0   Min.
> :3.54
>  1st Qu.:21.00   1st Qu.:4.000   1st Qu.: 79.0   1st Qu.: 66.0   1st
> Qu.:3.85
>  Median :22.80   Median :4.000   Median :120.3   Median :109.0   Median
> :4.08
>  Mean   :24.39   Mean   :5.077   Mean   :143.5   Mean   :126.8   Mean
> :4.05
>  3rd Qu.:30.40   3rd Qu.:6.000   3rd Qu.:160.0   3rd Qu.:113.0   3rd
> Qu.:4.22
>  Max.   :33.90   Max.   :8.000   Max.   :351.0   Max.   :335.0   Max.
> :4.93
>wt qsec vs   am gear
>
>  Min.   :1.513   Min.   :14.50   Min.   :0.   Min.   :1   Min.   :4.000
>
>  1st Qu.:1.935   1st Qu.:16.46   1st Qu.:0.   1st Qu.:1   1st Qu.:4.000
>
>  Median :2.320   Median :17.02   Median :1.   Median :1   Median :4.000
>
>  Mean   :2.411   Mean   :17.36   Mean   :0.5385   Mean   :1   Mean   :4.385
>
>  3rd Qu.:2.780   3rd Qu.:18.61   3rd Qu.:1.   3rd Qu.:1   3rd Qu.:5.000
>
>  Max.   :3.570   Max.   :19.90   Max.   :1.   Max.   :1   Max.   :5.000
>
>   carb
>  Min.   :1.000
>  1st Qu.:1.000
>  Median :2.000
>  Mean   :2.923
>  3rd Qu.:4.000
>  Max.   :8.000
> >
>
> I am using the latest version of *R-3.2.4 on Windows*, however, this error
> is being generated in the previous version too,
>
> Hope this reporting will get serious attention in debugging.
>
> With best regards,
>
> Dr. A.K. Singh
> Head, Department of Agril. Statistics
> Indira Gandhi Krishi Vishwavidyalaya, Raipur
> Chhattisgarh, India, PIN-492012
> Mobile: +919752620740
> Email: akhileshsingh.i...@gmail.com
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and 

[R] a replace for subset

2016-04-14 Thread ch.elahe via R-help
Hi,I have a data set (mydata), which a part of this is like the following:  
'data.frame':   36190 obs. of 16 variables:$ RE                    : int  38 41 
11 67 30 18 38 41 41 30 ...$ LU                     : int  4200 3330 530 4500 
3000 1790 4700 3400 3640 4000 ...$ COUNTRY        : Factor w/ 4 levels 
"DE","FR","JP", "FR"…$Light                  : Factor w/2 levels   
"ON","OFF","ON", ….$OR                     : Factor w/2 levels   
"S","T","S",….$PAT                  : Factor w/3 levels   "low", "high", 
"middle",….  Now I want to plot RE vs LU with ggplot2 for all the possible 
cases, I know how to do subsetting for the data but I want to know is there any 
shorter way to do that? For example I want to have a plot for RE vs LU for 
(COUNTRY= FR, Light=off, OR=S, PAT=low) and one for (COUNTRY= FR, Light=on, 
OR=S, PAT=high) and …., as you see doing subset is time consuming, is there any 
other way?Thank you for any help.Elahe
[[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] DataControl and DCARContControl functions

2016-04-14 Thread Yessile
Hello,
I have some trouble with DataControl and DCARContControl functions. I can use 
the following codes for multivariate normal distribution. 

sigma <- matrix(c(-1, 0, 0, 1), 2, 2)
 dc <- DataControl(size = 100, distribution = rmvnorm, dots = list(sigma = 
sigma))
 cc <- DCARContControl(epsilon = seq(0.05, 0.15, by = 0.05), distribution = 
rmvnorm,dots = list(mean = c(1, -1), sigma = sigma))


But, I want to use the same code for Multivariate Laplace and Multivariate 
Cauchy.  I have used to arrange the code for these two distributions but i 
didn’t succeed. 

I would be glad if you could help. 
Thank you from now…




[[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] Bug in by() function which works for some FUN argument and does not work for others

2016-04-14 Thread Akhilesh Singh
Dear Sirs,

I am Professor at Indira Gandhi Krishi Vishwavidyalaya, Raipur,
Chhattisgarh, India.

While taking classes, I found the *by() *function producing following error
when I use FUN=mean or median and some other functions, however,
FUN=summary works.

Given below is the output of the example I used on a built-in dataset
"mtcars", along with error message reproduced herewith:

> by(data=mtcars, INDICES=list(mtcars$am), FUN=mean)
: 0
[1] NA

: 1
[1] NA
Warning messages:
1: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA
2: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA

However, the same by() function works for FUN=summary, given below is the
output:

> by(data=mtcars, INDICES=list(mtcars$am), FUN=summary)
: 0
  mpg cyl disp hp
 Min.   :10.40   Min.   :4.000   Min.   :120.1   Min.   : 62.0
 1st Qu.:14.95   1st Qu.:6.000   1st Qu.:196.3   1st Qu.:116.5
 Median :17.30   Median :8.000   Median :275.8   Median :175.0
 Mean   :17.15   Mean   :6.947   Mean   :290.4   Mean   :160.3
 3rd Qu.:19.20   3rd Qu.:8.000   3rd Qu.:360.0   3rd Qu.:192.5
 Max.   :24.40   Max.   :8.000   Max.   :472.0   Max.   :245.0
  drat wt qsec vs   am

 Min.   :2.760   Min.   :2.465   Min.   :15.41   Min.   :0.   Min.   :0

 1st Qu.:3.070   1st Qu.:3.438   1st Qu.:17.18   1st Qu.:0.   1st Qu.:0

 Median :3.150   Median :3.520   Median :17.82   Median :0.   Median :0

 Mean   :3.286   Mean   :3.769   Mean   :18.18   Mean   :0.3684   Mean   :0

 3rd Qu.:3.695   3rd Qu.:3.842   3rd Qu.:19.17   3rd Qu.:1.   3rd Qu.:0

 Max.   :3.920   Max.   :5.424   Max.   :22.90   Max.   :1.   Max.   :0

  gearcarb
 Min.   :3.000   Min.   :1.000
 1st Qu.:3.000   1st Qu.:2.000
 Median :3.000   Median :3.000
 Mean   :3.211   Mean   :2.737
 3rd Qu.:3.000   3rd Qu.:4.000
 Max.   :4.000   Max.   :4.000

: 1
  mpg cyl disp hp drat

 Min.   :15.00   Min.   :4.000   Min.   : 71.1   Min.   : 52.0   Min.
:3.54
 1st Qu.:21.00   1st Qu.:4.000   1st Qu.: 79.0   1st Qu.: 66.0   1st
Qu.:3.85
 Median :22.80   Median :4.000   Median :120.3   Median :109.0   Median
:4.08
 Mean   :24.39   Mean   :5.077   Mean   :143.5   Mean   :126.8   Mean
:4.05
 3rd Qu.:30.40   3rd Qu.:6.000   3rd Qu.:160.0   3rd Qu.:113.0   3rd
Qu.:4.22
 Max.   :33.90   Max.   :8.000   Max.   :351.0   Max.   :335.0   Max.
:4.93
   wt qsec vs   am gear

 Min.   :1.513   Min.   :14.50   Min.   :0.   Min.   :1   Min.   :4.000

 1st Qu.:1.935   1st Qu.:16.46   1st Qu.:0.   1st Qu.:1   1st Qu.:4.000

 Median :2.320   Median :17.02   Median :1.   Median :1   Median :4.000

 Mean   :2.411   Mean   :17.36   Mean   :0.5385   Mean   :1   Mean   :4.385

 3rd Qu.:2.780   3rd Qu.:18.61   3rd Qu.:1.   3rd Qu.:1   3rd Qu.:5.000

 Max.   :3.570   Max.   :19.90   Max.   :1.   Max.   :1   Max.   :5.000

  carb
 Min.   :1.000
 1st Qu.:1.000
 Median :2.000
 Mean   :2.923
 3rd Qu.:4.000
 Max.   :8.000
>

I am using the latest version of *R-3.2.4 on Windows*, however, this error
is being generated in the previous version too,

Hope this reporting will get serious attention in debugging.

With best regards,

Dr. A.K. Singh
Head, Department of Agril. Statistics
Indira Gandhi Krishi Vishwavidyalaya, Raipur
Chhattisgarh, India, PIN-492012
Mobile: +919752620740
Email: akhileshsingh.i...@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] help with OR confidence interval using probit link

2016-04-14 Thread Rosa Oliveira
Howdy everyone



I’m trying to get Odds ratio and OR confidence intervals using a probit model, 
but I'm not getting.

 
Do you think you can help me?

 
I’m new with R L

 
naive   = 
summary(glm(pcr.data[,7]~boldBeta_individual+pcr.data$age,family=binomial(link=probit)))

naive_answer= c(naive$coefficients[,1:3])   
#naive estimates for


#alpha (first 4 collumns: intercept; beta_intercept, beta_slope and age) and 


#and SE(last 4 collumns: intercept; beta_intercept, beta_slope and age)

 
OR.naive = exp(1.6*coef(naive))

 
(till here works, the problem is with the confidence interval)

 
I tried to get the Standard error from the variance, but I’m not sure if this 
can be done as I’ve done.

 
 
Var_coef <- 1.6^2*var(coef(naive))

SE_coef <- Var_coef/sqrt(nsample)## I thi k this is 
correct

 
OR.naive.inf <- exp(OR.naive - (1.96 * SE_coef))

OR.naive.sup <- exp(OR.naive + (1.96 * SE_coef))

 
if I used logit link I would get the CI with confint(naïve) command, but with 
probit I don't think so. Is there a way?

 
What should I do?



Atenciosamente,
Rosa Oliveira

-- 




Rosa Celeste dos Santos Oliveira, 

E-mail: rosit...@gmail.com 
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira 


"Many admire, few know"
Hippocrates

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

2016-04-14 Thread Rosa Oliveira
Howdy everyone



I’m trying to get Odds ratio and OR confidence intervals using a probit model, 
but I'm not getting.

 

Do you think you can help me?

 

I’m new with R L

 

naive   = 
summary(glm(pcr.data[,7]~boldBeta_individual+pcr.data$age,family=binomial(link=probit)))

naive_answer= c(naive$coefficients[,1:3])   
#naive estimates for


#alpha (first 4 collumns: intercept; beta_intercept, beta_slope and age) and


#and SE(last 4 collumns: intercept; beta_intercept, beta_slope and age)

 

OR.naive = exp(1.6*coef(naive))

 

(till here works, the problem is with the confidence interval)

 

I tried to get the Standard error from the variance, but I’m not sure if this 
can be done as I’ve done.

 

 

Var_coef <- 1.6^2*var(coef(naive))

SE_coef <- Var_coef/sqrt(nsample)## I thi k this is 
correct

 

OR.naive.inf <- exp(OR.naive - (1.96 * SE_coef))

OR.naive.sup <- exp(OR.naive + (1.96 * SE_coef))

 

if I used logit link I would get the CI with confint(naïve) command, but with 
probit I don't think so. Is there a way?

 

What should I do?

 

 

 


Atenciosamente,
Rosa Oliveira

-- 




Rosa Celeste dos Santos Oliveira, 

E-mail: rosit...@gmail.com 
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira 


"Many admire, few know"
Hippocrates

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

2016-04-14 Thread Adrian Dușa
Thanks Bill, it's very useful to know how parsing and evaluation works.
It seems that quoting is the least complicated solution which is guaranteed
to work.

Best,
Adrian
On 13 Apr 2016 6:04 p.m., "William Dunlap"  wrote:

> %=>% would have precendence ('order of operations') problems also.
>
>A + B %=>% C
>
> is equivalent to
>
>   A + ( B %=>% C)
>
> and I don't think that is what you want.
>
> as.list(quote(A + B %=>% C)) shows the first branch in the parse tree.
> The following function, str.language, shows the entire parse tree, as in
>
>   > str.language(quote(A + B %=>% C))
>   `quote(A + B %=>% C)` call(3): A + B %=>% C
> `` name(1): +
> `` name(1): A
> `` call(3): B %=>% C
>   `` name(1): %=>%
>   `` name(1): B
>   `` name(1): C
>
> str.language <-
> function (object, ..., level = 0, name = myDeparse(substitute(object)))
> {
> abbr <- function(string, maxlen = 25) {
> if (length(string) > 1 || nchar(string) > maxlen)
> paste(substring(string[1], 1, maxlen), "...", sep = "")
> else string
> }
> myDeparse <- function(object) {
> if (!is.environment(object)) {
> deparse(object)
> }
> else {
> ename <- environmentName(object)
> if (ename == "")
> ename <- ""
> paste(sep = "", "<", ename, "> ", paste(collapse = " ",
> objects(object)))
> }
> }
> cat(rep("  ", level), sep = "")
> if (is.null(name))
> name <- ""
> cat(sprintf("`%s` %s(%d): %s\n", abbr(name), class(object),
> length(object), abbr(myDeparse(object
> a <- attributes(object)
> if (is.recursive(object) && !is.environment(object)) {
> object <- as.list(object)
> names <- names(object)
> for (i in seq_along(object)) {
> str.language(object[[i]], ..., level = level + 1,
> name = names[i])
> }
> }
> a$names <- NULL
> if (length(a) > 0) {
> str.language(a, level = level + 1, name = paste("Attributes of",
> abbr(name)))
> }
> }
>
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Tue, Apr 12, 2016 at 11:59 PM, Adrian Dușa 
> wrote:
>
>> I suppose it would work, although "=>" is rather a descriptive symbol and
>> less a function.
>> But choosing between quoting:
>> "A + B => C"
>> and a regular function:
>> A + B %=>% C
>> probably quoting is the most straightforward, as the result of the foo()
>> function has to be a string anyways (which is parsed by other functions).
>>
>> On Tue, Apr 12, 2016 at 6:20 PM, Richard M. Heiberger 
>> wrote:
>>
>> > Would making it regular function %=>%, using "%" instead of quotes,
>> > work for you?
>> >
>> > On Tue, Apr 12, 2016 at 11:09 AM, Adrian Dușa 
>> > wrote:
>> > > On Tue, Apr 12, 2016 at 2:08 PM, Duncan Murdoch <
>> > murdoch.dun...@gmail.com>
>> > > wrote:
>> > >> [...]
>> > >>
>> > >> It never gets to evaluating it.  It is not a legal R statement, so
>> the
>> > > parser signals an error.
>> > >> If you want to pass arbitrary strings to a function, you need to put
>> > them
>> > > in quotes.
>> > >
>> > > I see. I thought it was parsed inside the function, but if it's parsed
>> > > before then quoting is the only option.
>> > >
>> > >
>> > > To Keith: no, I mean it like this "A + B => C" which is translated as:
>> > > "the union of A and B is sufficient for C" in set theoretic language.
>> > >
>> > > The "=>" operator means sufficiency, while "<=" means necessity.
>> Quoting
>> > > the expression is good enough, I was just curious if the quotes could
>> be
>> > > made redundant, somehow.
>> > >
>> > > Thank you both,
>> > > Adrian
>> > >
>> > > --
>> > > Adrian Dusa
>> > > University of Bucharest
>> > > Romanian Social Data Archive
>> > > Soseaua Panduri nr.90
>> > > 050663 Bucharest sector 5
>> > > Romania
>> > >
>> > > [[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.
>> >
>>
>>
>>
>> --
>> Adrian Dusa
>> University of Bucharest
>> Romanian Social Data Archive
>> Soseaua Panduri nr.90
>> 050663 Bucharest sector 5
>> Romania
>>
>> [[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]]


Re: [R] Error messages when start first time R: "You're using a non-UTF8 locale, therefore only ASCII characters will work."

2016-04-14 Thread peter dalgaard

On 14 Apr 2016, at 09:47 , Ole C. Brudvik  wrote:

> Hi!
> I just started this course and just installed R and RStudio but I got this 
> warning/error messages when I open R and RStudio:
> 

This is not a help list for any course...

However, that particular issue is just that the FAQ was edited and it ws 
forgotten to update the warning message. The instructions are in Sec.7 now.

-pd

> During startup - Warning messages:
> 
> 1: Setting LC_CTYPE failed, using "C"
> 
> 2: Setting LC_COLLATE failed, using "C"
> 
> 3: Setting LC_TIME failed, using "C"
> 
> 4: Setting LC_MESSAGES failed, using "C"
> 
> 5: Setting LC_MONETARY failed, using "C"
> 
> [R.app GUI 1.67 (7152) x86_64-apple-darwin13.4.0]
> 
> WARNING: You're using a non-UTF8 locale, therefore only ASCII characters will 
> work.
> 
> Please read R for Mac OS X FAQ (see Help) section 9 and adjust your system 
> preferences accordingly.
> 
> Section 9 is just Acknowledgements so I cant find the help the software refer 
> to.
> 
> Please, can anyone help me with this? It seems important to get this fixed 
> before I do work with RStudio.
> 
> Thanks a lot! Appreciate very much any help.
> 
> Cheers
> 
> Ole
>   [[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.

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

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


Re: [R] Error messages when start first time R: "You're using a non-UTF8 locale, therefore only ASCII characters will work."

2016-04-14 Thread Bert Gunter
1. These are warnings, not error. So you could just ignore them and proceed.

2. However, you may wish to go to the tools -->General menu in RStudio
and set the default text encoding to UTF-8. I think that will get rid
of the warnings.

Happy R-ing. Please make use of R's docs and web resources (especially
tutorials) before posting on this list, as most questions you might
have should be quickly answerable from them.

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, Apr 14, 2016 at 12:47 AM, Ole C. Brudvik  wrote:
> Hi!
> I just started this course and just installed R and RStudio but I got this 
> warning/error messages when I open R and RStudio:
>
> During startup - Warning messages:
>
> 1: Setting LC_CTYPE failed, using "C"
>
> 2: Setting LC_COLLATE failed, using "C"
>
> 3: Setting LC_TIME failed, using "C"
>
> 4: Setting LC_MESSAGES failed, using "C"
>
> 5: Setting LC_MONETARY failed, using "C"
>
> [R.app GUI 1.67 (7152) x86_64-apple-darwin13.4.0]
>
> WARNING: You're using a non-UTF8 locale, therefore only ASCII characters will 
> work.
>
> Please read R for Mac OS X FAQ (see Help) section 9 and adjust your system 
> preferences accordingly.
>
> Section 9 is just Acknowledgements so I cant find the help the software refer 
> to.
>
> Please, can anyone help me with this? It seems important to get this fixed 
> before I do work with RStudio.
>
> Thanks a lot! Appreciate very much any help.
>
> Cheers
>
> Ole
> [[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] R 3.2.5 is released

2016-04-14 Thread Peter Dalgaard
The 3.2.4-revised version turned out to give trouble for some of CRAN's 
subsystems.

Accordingly, a rebadged version 3.2.5 is now released; it only differs in the 
version number and a few clean-up items. If you have a working install of 
3.2.4-revised there should be no reason to upgrade it.

You can get the source code from

http://cran.r-project.org/src/base/R-3/R-3.2.5.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you.

For the R Core Team,

Peter Dalgaard

New md5 sums are

MD5 (AUTHORS) = eb97a5cd38acb1cfc6408988bffef765
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = cd7bfa946b8650cb87807e94e46984c6
MD5 (INSTALL) = 3964b9119adeaab9ceb633773fc94aac
MD5 (NEWS) = 42d76ce7f8e80977d5043bca4234f4c9
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = eb78c4d053ec9c32b815cf0c2ebea801
MD5 (NEWS.2) = e840d32b7ef7a7603455d30d6d54fda7
MD5 (R-latest.tar.gz) = 7b23ee70cfb383be3bd4360e3c71d8c3
MD5 (README) = aece1dfbd18c1760128c3787f5456af6
MD5 (RESOURCES) = 529223fd3ffef95731d0a87353108435
MD5 (THANKS) = ba00f6cc68a823e1741cfa6011f40ccb
MD5 (VERSION-INFO.dcf) = 661c20647b9f0b9fa980297c53438609
MD5 (R-3/R-3.2.5.tar.gz) = 7b23ee70cfb383be3bd4360e3c71d8c3


The relevant NEWS file entries (relative to 3.2.4) are

CHANGES IN R 3.2.5:

  BUG FIXES:

• format.POSIXlt() behaved incorrectly in R 3.2.4.  E.g. the output
  of format(as.POSIXlt(paste0(1940:2000,"-01-01"), tz = "CET"),
  usetz = TRUE) ended in two "CEST" time formats.

• A typo in the Makefile for src/extra/xz prevented builds of
  liblzma.a. (Notice that this will become unbundled in 3.3.0.)



-- 
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-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

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

2016-04-14 Thread Adams, Jean
This is a good place to start ...
https://cran.r-project.org/doc/manuals/R-intro.pdf

Jean

On Thu, Apr 14, 2016 at 5:39 AM, kipkorirfrankli...@gmail.com <
kipkorirfrankli...@gmail.com> wrote:

>
> Hello. I am Franklin from University of Eldoret. I really want to study
> the R package. What should I first of all do?
> [[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] New member

2016-04-14 Thread kipkorirfrankli...@gmail.com

Hello. I am Franklin from University of Eldoret. I really want to study the R 
package. What should I first of all do?
[[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 messages when start first time R: "You're using a non-UTF8 locale, therefore only ASCII characters will work."

2016-04-14 Thread Ole C. Brudvik
Hi!
I just started this course and just installed R and RStudio but I got this 
warning/error messages when I open R and RStudio:

During startup - Warning messages:

1: Setting LC_CTYPE failed, using "C"

2: Setting LC_COLLATE failed, using "C"

3: Setting LC_TIME failed, using "C"

4: Setting LC_MESSAGES failed, using "C"

5: Setting LC_MONETARY failed, using "C"

[R.app GUI 1.67 (7152) x86_64-apple-darwin13.4.0]

WARNING: You're using a non-UTF8 locale, therefore only ASCII characters will 
work.

Please read R for Mac OS X FAQ (see Help) section 9 and adjust your system 
preferences accordingly.

Section 9 is just Acknowledgements so I cant find the help the software refer 
to.

Please, can anyone help me with this? It seems important to get this fixed 
before I do work with RStudio.

Thanks a lot! Appreciate very much any help.

Cheers

Ole
[[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] Microsoft R Server

2016-04-14 Thread Leandro Marino
John,

as I know Microsoft has owned the Revolution Analytics and is continuing
the development of the Revolurion R with a new name Microsoft R. Note that
Microsoft R has an open source stable version. I'm not quite sure which
modifications they are doing on it. I suppose that this modified version of
R is the one they are putting in their servers.

As I could search few weeks ago they inform us that all R packages works
with their version.

Best
Leandro

2016-04-14 9:33 GMT-03:00 John Sorkin :

> Has anyone ever heard of or used Microsoft R server? Does the product
> work? What are requirements for running it? How much does it cost and is it
> supported by the R community?
> Thank you,
> John
> Confidentiality Statement:
> This email message, including any attachments, is for ...{{dropped:13}}

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

2016-04-14 Thread boB Rudis
Yes. Yes. That info is on their site. That info is on their site. They
have paid support for their customers and
non-Microsoft-R-platform-dependent packages will (most likely) still
be answered by the community.

This is just a re-branding and expansion of what was Revolution R
which has been around for ages and a really great supporter and
champion of the R community & ecosystem.

On Thu, Apr 14, 2016 at 8:33 AM, John Sorkin
 wrote:
> Has anyone ever heard of or used Microsoft R server? Does the product work? 
> What are requirements for running it? How much does it cost and is it 
> supported by the R community?
> Thank you,
> John
> Confidentiality Statement:
> This email message, including any attachments, is for ...{{dropped:8}}

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

2016-04-14 Thread John Sorkin
Has anyone ever heard of or used Microsoft R server? Does the product work? 
What are requirements for running it? How much does it cost and is it supported 
by the R community?
Thank you,
John
Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

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

2016-04-14 Thread rubenfcasal

Hola a todos,

Por aportar un poco más...
Yo también empleo el paquete openxlsx especialmente si el nº de 
datos es grande, pero también el XLConnect cuando por ejemplo tengo que 
combinar distintos ficheros y quiero especificar los tipos de las 
variables para evitar problemas (con el parámetro colTypes).


Por si resulta de interés pego el código para abrir (y 
posteriormente combinar) todos los ficheros excel de un subdirectorio:


library(openxlsx)
path <- './subdirectorio'
files <- dir(path, pattern = '*.xlsx')
data.list <- vector(length(files), mode = 'list')
for (i in seq_along(files)) {
data.list[[i]] <- readWorkbook(file.path(path, files[i]))
}
str(data.list)

# Si se quieren combinar...
# Alternativa a combinar con do.call('rbind', data.list):
library(dplyr)
data <- bind_rows(data.list)

Un saludo, Rubén.

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


Re: [R-es] R y Excel - paquete openxlsx

2016-04-14 Thread Isidro Hidalgo Arellano
Tienes razón para la mayoría de veces, pero cuando hay que seleccionar datos de 
unos 100 archivos Excel, me da mucha pereza tirar del portapapeles... En R son 
muy pocas líneas de código.
Un saludo


-Mensaje original-
De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de Jesús Para 
Fernández
Enviado el: jueves, 14 de abril de 2016 9:25
Para: r-help-es@r-project.org
Asunto: Re: [R-es] R y Excel - paquete openxlsx

Para mi lo m�s pr�ctico y r�pido es prescindir de estos paquetes, seleccionar 
los datos que me interesan del excel, copiarlos y en R poner:

datos<-read.table("clipboard",header=T,dec=",",sep="\t",na.strings="")

Y con eso me pega los datos como un data.frame en excel. 

Un saludo
Jes�s


  
[[alternative HTML version deleted]]

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

Re: [R] Adding Two-Headed Arrow in map legend

2016-04-14 Thread Miluji Sb
Hello Jim,

You're amazing. This is what finally worked:

arrows(-1,19,35.6,19,code=3, xpd=T).

Don't know the coordinates were giving so much trouble. Maybe something to
do with maps in rworldmap. Thanks again!

Sincerely,

Milu

On Wed, Apr 13, 2016 at 6:51 AM, Jim Lemon  wrote:

> Hi Milu,
> My fault here. As I don't have the data to make the map and try out my
> suggestions I mixed up the x and y coordinates. Try this:
>
> par(xpd=TRUE)
> arrows(-19.75966,53,33.6,53,code=3)
> par(xpd=FALSE)
>
> Jim
>
> On Tue, Apr 12, 2016 at 10:11 PM, Miluji Sb  wrote:
> > Hello Jim,
> >
> > Thanks again. I am getting the two-headed arrow but I cannot seem to get
> the
> > coordinates right for the arrow to appear beneath the map. These
> coordinates
> > puts the arrow on the left hand side. Thanks again!
> >
> > Sincerely,
> >
> > Milu
> >
> > On Tue, Apr 12, 2016 at 1:15 PM, Jim Lemon  wrote:
> >>
> >> Hi Milu,
> >> There is a two-headed arrow on the image you sent, and it seems to be
> >> where you specified. Did you want it beneath the map, as:
> >>
> >> par(xpd=TRUE)
> >> arrows(-22,54.75,-22,74,code=3)
> >> par(xpd=FALSE)
> >>
> >> Jim
> >>
> >> On Tue, Apr 12, 2016 at 7:58 PM, Miluji Sb  wrote:
> >> > Dear Jim,
> >> >
> >> > Thanks again! I do want the arrows at the bottom (beneath the map).
> This
> >> > is
> >> > what I am doing:
> >> >
> >> > # Draw the map
> >> > eps_europe <- mapCountryData(n, nameColumnToPlot="eps_score",
> >> > mapTitle="EPS
> >> > Score - Europe",colourPalette=colourPalette,
> >> > catMethod="fixedWidth", missingCountryCol = "white",
> mapRegion="Europe",
> >> > addLegend=FALSE)
> >> >
> >> > # ISO3 codes on the map
> >> > text(n, labels="ISO3", cex=0.30)
> >> >
> >> > # Obtain coordinates for the arrow
> >> > par('usr')
> >> >
> >> > # -19.75966  54.75966  33.6  71.4
> >> >
> >> > # Arrows
> >> > par(xpd=TRUE)
> >> > arrows(-19.75966,  54.75966,  33.6,  71.4,code=3)
> >> > par(xpd=FALSE)
> >> >
> >> > As the output shows I cannot seem to get the correct coordinates for
> the
> >> > arrows. Thanks again.
> >> >
> >> > Sincerely,
> >> >
> >> > Milu
> >
> >
>

[[alternative HTML version deleted]]

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


Re: [R] [FORGED] calculate sampel size?

2016-04-14 Thread Rolf Turner

On 14/04/16 19:28, Marna Wagley wrote:

Hi R user,
Can we calculate sample size when only mean and SE are given?
Let say one example,  I have mean with SE is  0.54+-0.0517 (mean+-SE). Is
there any way to find the samples (sample size n) in that condition in R?

i think this question is not related to R, I hope you won't mind.



You're correct, your question is not related to R.

But the answer (short, long or indifferent) to your question is No.

And furthermore, don't be silly.  SE = s/sqrt(n).  If you knew s you 
could solve for n, but you don't.  Full stop.  There's an end to it.

Any further mucking about is unproductive wishful thinking.

cheers,

Rolf Turner

P. S.  See fortune(299).

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

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


Re: [R] calculate sampel size?

2016-04-14 Thread Sarah Goslee
You are right, your question is not related to R, so not appropraie here. I
pasted your question into google instead, and got all sorts of suggestions,
ncluding

https://www.isixsigma.com/tools-templates/sampling-data/how-determine-sample-size-determining-sample-size/

Sarah

On Thursday, April 14, 2016, Marna Wagley  wrote:

> Hi R user,
> Can we calculate sample size when only mean and SE are given?
> Let say one example,  I have mean with SE is  0.54+-0.0517 (mean+-SE). Is
> there any way to find the samples (sample size n) in that condition in R?
>
> i think this question is not related to R, I hope you won't mind.
> Thanks
>
> [[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.
>


-- 
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

[[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] Decision Tree and Random Forrest

2016-04-14 Thread Sarah Goslee
So. Given that the second and third panels of the first figure in the first
link I gave show a decision tree with decision rules at each split and the
number of samples at each direction, what _exactly_ is your problem?



On Wednesday, April 13, 2016, Michael Eugene  wrote:

> I still need the output to match my requiremnt in my original post.  With
> decision rules "clusters" and probability attached to them.  The examples
> are sort of similar.  You just provided links to general info about trees.
>
>
>
> Sent from my Verizon, Samsung Galaxy smartphone
>
>
>  Original message 
> From: Sarah Goslee  >
> Date: 4/13/16 8:04 PM (GMT-06:00)
> To: Michael Artz  >
> Cc: "r-help@r-project.org
> " <
> R-help@r-project.org
> >
> Subject: Re: [R] Decision Tree and Random Forrest
>
>
>
> On Wednesday, April 13, 2016, Michael Artz  > wrote:
>
> Tjats great that you are familiar and thanks for responding.  Have you
> ever done what I am referring to? I have alteady spent time going through
> links and tutorials about decision trees and random forrests and have even
> used them both before.
>
> Then what specifically is your problem? Both of the tutorials I provided
> show worked examples, as does even the help for rpart. If none of those, or
> your extensive reading, work for your project you will have to be a lot
> more specific about why not.
>
> Sarah
>
>
>
> Mike
> On Apr 13, 2016 5:32 PM, "Sarah Goslee"  wrote:
>
> It sounds like you want classification or regression trees. rpart does
> exactly what you describe.
>
> Here's an overview:
> http://www.statmethods.net/advstats/cart.html
>
> But there are a lot of other ways to do the same thing in R, for instance:
> http://www.r-bloggers.com/a-brief-tour-of-the-trees-and-forests/
>
> You can get the same kind of information from random forests, but it's
> less straightforward. If you want a clear set of rules as in your golf
> example, then you need rpart or similar.
>
> Sarah
>
> On Wed, Apr 13, 2016 at 6:02 PM, Michael Artz 
> wrote:
> > Ah yes I will have to use the predict function.  But the predict function
> > will not get me there really.  If I can take the example that I have a
> > model predicting whether or not I will play golf (this is the dependent
> > value), and there are three independent variables Humidity(High, Medium,
> > Low), Pending_Chores(Taxes, None, Laundry, Car Maintenance) and Wind
> (High,
> > Low).  I would like rules like where any record that follows these rules
> > (IF humidity = high AND pending_chores = None AND Wind = High THEN 77%
> > there is probability that play_golf is YES).  I was thinking that random
> > forrest would weight the rules somehow on the collection of trees and
> give
> > a probability.  But if that doesnt make sense, then can you just tell me
> > how to get the decsion rules with one tree and I will work from that.
> >
> > Mike
> >
> > Mike
> >
> > On Wed, Apr 13, 2016 at 4:30 PM, Bert Gunter 
> wrote:
> >
> >> I think you are missing the point of random forests. But if you just
> >> want to predict using the forest, there is a predict() method that you
> >> can use. Other than that, I certainly don't understand what you mean.
> >> Maybe someone else might.
> >>
> >> 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, Apr 13, 2016 at 2:11 PM, Michael Artz 
> >> wrote:
> >> > Ok is there a way to do  it with decision tree?  I just need to make
> the
> >> > decision rules. Perhaps I can pick one of the trees used with Random
> >> > Forrest.  I am somewhat familiar already with Random Forrest with
> >> respective
> >> > to bagging and feature sampling and getting the mode from the leaf
> nodes
> >> and
> >> > it being an ensemble technique of many trees.  I am just working from
> the
> >> > perspective that I need decision rules, and I am working backward form
> >> that,
> >> > and I need to do it in R.
> >> >
> >> > On Wed, Apr 13, 2016 at 4:08 PM, Bert Gunter 
> >> wrote:
> >> >>
> >> >> Nope.
> >> >>
> >> >> Random forests are not decision trees -- they are ensembles (forests)
> >> >> of trees. You need to go back and read up on them so you understand
> >> >> how they work. The Hastie/Tibshirani/Friedman "The Elements of
> >> >> Statistical Learning" has a nice explanation, but I'm sure there are
> >> >> lots of 

[R] calculate sampel size?

2016-04-14 Thread Marna Wagley
Hi R user,
Can we calculate sample size when only mean and SE are given?
Let say one example,  I have mean with SE is  0.54+-0.0517 (mean+-SE). Is
there any way to find the samples (sample size n) in that condition in R?

i think this question is not related to R, I hope you won't mind.
Thanks

[[alternative HTML version deleted]]

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


Re: [R-es] R y Excel - paquete openxlsx

2016-04-14 Thread Jesús Para Fernández
Para mi lo m�s pr�ctico y r�pido es prescindir de estos paquetes, seleccionar 
los datos que me interesan del excel, copiarlos y en R poner:

datos<-read.table("clipboard",header=T,dec=",",sep="\t",na.strings="")

Y con eso me pega los datos como un data.frame en excel. 

Un saludo
Jes�s


  
[[alternative HTML version deleted]]

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

Re: [R] Decision Tree and Random Forrest

2016-04-14 Thread Achim Zeileis

On Thu, 14 Apr 2016, Michael Artz wrote:


Ah yes I will have to use the predict function.  But the predict function
will not get me there really.  If I can take the example that I have a
model predicting whether or not I will play golf (this is the dependent
value), and there are three independent variables Humidity(High, Medium,
Low), Pending_Chores(Taxes, None, Laundry, Car Maintenance) and Wind (High,
Low).  I would like rules like where any record that follows these rules
(IF humidity = high AND pending_chores = None AND Wind = High THEN 77%
there is probability that play_golf is YES).


Although I think that this toy example is not overly useful for practical 
illustrations we have included the standard dataset in the "partykit" 
package:


## data
data("WeatherPlay", package = "partykit")

I was thinking that random forrest would weight the rules somehow on the 
collection of trees and give a probability.  But if that doesnt make 
sense, then can you just tell me how to get the decsion rules with one 
tree and I will work from that.


Then you can learn one tree on this data, e.g., with rpart() or ctree():

## trees
library("rpart")
rp <- rpart(play ~ ., data = WeatherPlay,
  control = rpart.control(minsplit = 5))

library("partykit")
ct <- ctree(play ~ ., data = WeatherPlay,
  minsplit = 5, mincriterion = 0.1)

## visualize via partykit
pr <- as.party(rp)
plot(pr)
plot(ct)

And the partykit package also includes a function to generate a text 
representation of the rules although this is currently not exported:


partykit:::.list.rules.party(pr)
##"outlook %in% c(\"overcast\")"
## 4
##  "outlook %in% c(\"sunny\", \"rainy\") & humidity < 82.5"
## 5
## "outlook %in% c(\"sunny\", \"rainy\") & humidity >= 82.5"

partykit:::.list.rules.party(ct)
##23
## "humidity <= 80"  "humidity > 80"

If you do not want a text representation but something else you can 
compute on, then look at the source code of partykit:::.list.rules.party() 
and try to adapt it to your needs.



On Wed, Apr 13, 2016 at 4:30 PM, Bert Gunter  wrote:


I think you are missing the point of random forests. But if you just
want to predict using the forest, there is a predict() method that you
can use. Other than that, I certainly don't understand what you mean.
Maybe someone else might.

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, Apr 13, 2016 at 2:11 PM, Michael Artz 
wrote:

Ok is there a way to do  it with decision tree?  I just need to make the
decision rules. Perhaps I can pick one of the trees used with Random
Forrest.  I am somewhat familiar already with Random Forrest with

respective

to bagging and feature sampling and getting the mode from the leaf nodes

and

it being an ensemble technique of many trees.  I am just working from the
perspective that I need decision rules, and I am working backward form

that,

and I need to do it in R.

On Wed, Apr 13, 2016 at 4:08 PM, Bert Gunter 

wrote:


Nope.

Random forests are not decision trees -- they are ensembles (forests)
of trees. You need to go back and read up on them so you understand
how they work. The Hastie/Tibshirani/Friedman "The Elements of
Statistical Learning" has a nice explanation, but I'm sure there are
lots of good web resources, too.

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, Apr 13, 2016 at 1:40 PM, Michael Artz 
wrote:

Hi I'm trying to get the top decision rules from a decision tree.
Eventually I will like to do this with R and Random Forrest.  There

has

to
be a way to output the decsion rules of each leaf node in an easily
readable way. I am looking at the randomforrest and rpart packages

and I

dont see anything yet.
Mike

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



__