[R] effects package x axis labels

2017-11-10 Thread Andras Farkas via R-help
Dear All,

probably a simple enough solution but don;t seem to be able to get my head 
around it...example based on a publicly available data set:

mydata <- read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv";)
mylogit <- glm(admit ~ gre + gpa + rank, data = mydata, family = "binomial")
library(effects)
plot(allEffects(mylogit)
     ,axes=list(y=list(lab="Prob(xyz)"))
)

axes=list(y=list(lab="Prob(xyz)")) changes the y axis labels for all 3 plots... 
Any thoughts on how I could change the x axis labels to let say 'black' (plot 
1), 'white' (plot 2) and 'green' (plot 3) for the 3 respective plots produced? 


appreciate the help...

Andras 

__
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] update R version in windows

2017-11-10 Thread Jeff Newmiller
That only works if you use apt-get for all package installs... I don't even 
know if that is possible. Use of install.packages within R works the same on 
all platforms... that is, upgrading R by a minor version (3.3 to 3.4) causes R 
to go looking for user-installed packages in a new library directory, while 
patchlevel upgrades (3.4.1 to 3.4.2) keep using the same library directory 
(read the R Installation and Administration Manual).
-- 
Sent from my phone. Please excuse my brevity.

On November 10, 2017 10:33:49 AM PST, "Bond, Stephen"  
wrote:
>This issue does not exist on Linux. My Ubuntu updates both R and all
>packages.
>
>Stephen B
>
>
>-Original Message-
>From: J C Nash [mailto:profjcn...@gmail.com] 
>Sent: Friday, November 10, 2017 1:19 PM
>To: r-help; RICHARD M. HEIBERGER; Bond, Stephen
>Subject: Re: [R] update R version in windows
>
>However, trying this on Linux Mint gave
>
>  package ‘installr’ is not available (for R version 3.4.2)
>
>Has the package not been updated yet?
>
>
>JN
>
>
>Try the installr package. It was designed for this purpose.
>
>On Fri, Nov 10, 2017 at 11:49 AM, Bond, Stephen cibc.com> wrote:
>> Is there a utility which will allow me to upgrade my R version and
>update all packages from the old version?
>> If I manually upgrade, then I have to manually re-install 50
>packages.
>> Thank you.
>>
>> Stephen B
>>
>>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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

Re: [R] R and LINGO?

2017-11-10 Thread Jeff Newmiller
That is interesting that you are having difficulty. Well, not really... please 
read the Posting Guide:

a) No homework questions. Use the resources offered in your educational 
environment (school, MOOC, etc.).

b) If this is not homework then frame your question with example R code... this 
is a forum about R, not about finance (or other domain-specific concepts). You 
don't have to know the answer to ask it, but you have to show us which R skill 
or function you need help with, using example data and some attempt at a 
solution.

c) LINGO appears to be commercial software that offers an interface for R... 
the use of LINGO is definitely off topic here... we expect to be able to run 
your code examples using R and CRAN resources to be relevant to all R users. 
-- 
Sent from my phone. Please excuse my brevity.

On November 10, 2017 8:04:10 AM PST, "Jan Olsen Røyland" 
 wrote:
>Hei
>Im struggling with this problem:
>b) Another company wants to compose the optimal project portfolio based
>on the following 5-
>year project proposals. In the table, the cash flow for each project in
>each year is shown.
>Project 1 Project 2 Project 3 Project 4 Project 5 Project 6
>1st year of the project -58 -32 -18 -31 -33 -39
>2nd year of the project 17 17 11 4 21 30
>3rd year of the project 26 30 13 19 20 9
>4th year of the project 18 7 4 7 22 13
>5th year of the project 40 6 7 17 6 13
>In this case, the company can also choose which year each project
>should commence. These six
>candidate projects can begin either in 2018, in 2019 or in 2020, or not
>at all.
>The current proposal is to undertake project 1, 2, 3 and 5, with
>project 3 and 5 starting in 2018,
>project 2 in 2019 and project 1 in 2020. Available funds by the end of
>year 2017 will be 70 mill.
>The resulting cash flow is given in the following table:
>Project 1 Project 2 Project 3 Project 5
>Total cash flow
>from projects
>Available
>funds
>2017 70
>2018 -18 -33 -51 19
>2019 -32 11 21 0 19
>2020 -58 17 13 20 -8 11
>2021 17 30 4 22 73 84
>2022 26 7 7 6 46 130
>2023 18 6 24 154
>2024 40 40 194
>Formulate an optimization model in LINGO to determine which projects to
>undertake, and in which
>years. The goal is to maximize available funds by the end of year 2024,
>while making sure that
>available funds are always non-negative throughout the planning
>horizon. How much can the
>improve compared to the current proposal? (For simplicity, assume zero
>discount rate.)
>
>Med Vennelig Hilsen
>Jan Olsen R�yland
>
>
>   [[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] update R version in windows

2017-11-10 Thread Bond, Stephen
Thanks Caitlin and Richard MH. Works great.

Stephen

From: Caitlin [mailto:bioprogram...@gmail.com]
Sent: Friday, November 10, 2017 12:33 PM
To: Bond, Stephen
Subject: Re: [R] update R version in windows

install.packages("installr")

updateR()

rather...

On Friday, November 10, 2017, Bond, Stephen 
mailto:stephen.b...@cibc.com>> wrote:
Is there a utility which will allow me to upgrade my R version and update all 
packages from the old version?
If I manually upgrade, then I have to manually re-install 50 packages.
Thank you.

Stephen B


[[alternative HTML version deleted]]

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

[[alternative HTML version deleted]]

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


Re: [R] R and LINGO?

2017-11-10 Thread Marc Schwartz
Hi,

A few comments:

1. You appear to be replying to a post on the R-Help list from 2010:

  https://stat.ethz.ch/pipermail/r-help/2010-June/242714.html


2. Nothing that you have below appears to be directly related to R, but to 
LINGO:

  http://www.lindo.com/index.php/products/lingo-and-optimization-modeling

which appears to be a commercial product based upon a Google search.


3. If you need assistance with LINGO, contact them for support.


4. To the extent R is at all relevant to your problem, they appear to have an 
interface to R, which is also a commercial product:

  
http://www.lindo.com/index.php/ls-downloads?catid=82&id=106:r-lingo-resource-page

You should contact them for support with the product.


5. Even if this was related to R, this appears to be a homework problem of some 
type and the R lists do not assist with homework.


Regards,

Marc Schwartz



> On Nov 10, 2017, at 11:04 AM, Jan Olsen Røyland  
> wrote:
> 
> Hei
> Im struggling with this problem:
> b) Another company wants to compose the optimal project portfolio based on 
> the following 5-
> year project proposals. In the table, the cash flow for each project in each 
> year is shown.
> Project 1 Project 2 Project 3 Project 4 Project 5 Project 6
> 1st year of the project -58 -32 -18 -31 -33 -39
> 2nd year of the project 17 17 11 4 21 30
> 3rd year of the project 26 30 13 19 20 9
> 4th year of the project 18 7 4 7 22 13
> 5th year of the project 40 6 7 17 6 13
> In this case, the company can also choose which year each project should 
> commence. These six
> candidate projects can begin either in 2018, in 2019 or in 2020, or not at 
> all.
> The current proposal is to undertake project 1, 2, 3 and 5, with project 3 
> and 5 starting in 2018,
> project 2 in 2019 and project 1 in 2020. Available funds by the end of year 
> 2017 will be 70 mill.
> The resulting cash flow is given in the following table:
> Project 1 Project 2 Project 3 Project 5
> Total cash flow
> from projects
> Available
> funds
> 2017 70
> 2018 -18 -33 -51 19
> 2019 -32 11 21 0 19
> 2020 -58 17 13 20 -8 11
> 2021 17 30 4 22 73 84
> 2022 26 7 7 6 46 130
> 2023 18 6 24 154
> 2024 40 40 194
> Formulate an optimization model in LINGO to determine which projects to 
> undertake, and in which
> years. The goal is to maximize available funds by the end of year 2024, while 
> making sure that
> available funds are always non-negative throughout the planning horizon. How 
> much can the
> improve compared to the current proposal? (For simplicity, assume zero 
> discount rate.)
> 
> Med Vennelig Hilsen
> Jan Olsen R�yland
> 

__
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] update R version in windows

2017-11-10 Thread Bond, Stephen
This issue does not exist on Linux. My Ubuntu updates both R and all packages.

Stephen B


-Original Message-
From: J C Nash [mailto:profjcn...@gmail.com] 
Sent: Friday, November 10, 2017 1:19 PM
To: r-help; RICHARD M. HEIBERGER; Bond, Stephen
Subject: Re: [R] update R version in windows

However, trying this on Linux Mint gave

  package ‘installr’ is not available (for R version 3.4.2)

Has the package not been updated yet?


JN


Try the installr package. It was designed for this purpose.

On Fri, Nov 10, 2017 at 11:49 AM, Bond, Stephen  
wrote:
> Is there a utility which will allow me to upgrade my R version and update all 
> packages from the old version?
> If I manually upgrade, then I have to manually re-install 50 packages.
> Thank you.
>
> Stephen B
>
>
__
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] update R version in windows

2017-11-10 Thread Richard M. Heiberger
installr is Windows-specific.  From the DESCRIPTION
OS_type:windows

I would guess that some of it would work on other OS, but you would
have to check.
If it looks useful elsewhere you should tell Tal
Maintainer:Tal Galili 

Rich

On Fri, Nov 10, 2017 at 1:18 PM, J C Nash  wrote:
> However, trying this on Linux Mint gave
>
>   package ‘installr’ is not available (for R version 3.4.2)
>
> Has the package not been updated yet?
>
>
> JN
>
>
> Try the installr package. It was designed for this purpose.
>
> On Fri, Nov 10, 2017 at 11:49 AM, Bond, Stephen  
> wrote:
>> Is there a utility which will allow me to upgrade my R version and update 
>> all packages from the old version?
>> If I manually upgrade, then I have to manually re-install 50 packages.
>> Thank you.
>>
>> Stephen B
>>
>>

__
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] update R version in windows

2017-11-10 Thread J C Nash
However, trying this on Linux Mint gave

  package ‘installr’ is not available (for R version 3.4.2)

Has the package not been updated yet?


JN


Try the installr package. It was designed for this purpose.

On Fri, Nov 10, 2017 at 11:49 AM, Bond, Stephen  
wrote:
> Is there a utility which will allow me to upgrade my R version and update all 
> packages from the old version?
> If I manually upgrade, then I have to manually re-install 50 packages.
> Thank you.
>
> Stephen B
>
>

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

Re: [R] R and LINGO?

2017-11-10 Thread Jan Olsen Røyland
Hei
Im struggling with this problem:
b) Another company wants to compose the optimal project portfolio based on the 
following 5-
year project proposals. In the table, the cash flow for each project in each 
year is shown.
Project 1 Project 2 Project 3 Project 4 Project 5 Project 6
1st year of the project -58 -32 -18 -31 -33 -39
2nd year of the project 17 17 11 4 21 30
3rd year of the project 26 30 13 19 20 9
4th year of the project 18 7 4 7 22 13
5th year of the project 40 6 7 17 6 13
In this case, the company can also choose which year each project should 
commence. These six
candidate projects can begin either in 2018, in 2019 or in 2020, or not at all.
The current proposal is to undertake project 1, 2, 3 and 5, with project 3 and 
5 starting in 2018,
project 2 in 2019 and project 1 in 2020. Available funds by the end of year 
2017 will be 70 mill.
The resulting cash flow is given in the following table:
Project 1 Project 2 Project 3 Project 5
Total cash flow
from projects
Available
funds
2017 70
2018 -18 -33 -51 19
2019 -32 11 21 0 19
2020 -58 17 13 20 -8 11
2021 17 30 4 22 73 84
2022 26 7 7 6 46 130
2023 18 6 24 154
2024 40 40 194
Formulate an optimization model in LINGO to determine which projects to 
undertake, and in which
years. The goal is to maximize available funds by the end of year 2024, while 
making sure that
available funds are always non-negative throughout the planning horizon. How 
much can the
improve compared to the current proposal? (For simplicity, assume zero discount 
rate.)

Med Vennelig Hilsen
Jan Olsen R�yland


[[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] update R version in windows

2017-11-10 Thread Richard M. Heiberger
Try the installr package. It was designed for this purpose.

On Fri, Nov 10, 2017 at 11:49 AM, Bond, Stephen  wrote:
> Is there a utility which will allow me to upgrade my R version and update all 
> packages from the old version?
> If I manually upgrade, then I have to manually re-install 50 packages.
> Thank you.
>
> Stephen B
>
>
> [[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] update R version in windows

2017-11-10 Thread Bert Gunter
?update.packages

Should take care of packages. Manually reinstalling R binaries seems
straightforward enough that it isn't much of a burden; but installing from
source may be a different story, depending on your OS.

The RStudio interface automates much of this, but it may not be enough for
you or what you want.

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 Fri, Nov 10, 2017 at 8:49 AM, Bond, Stephen 
wrote:

> Is there a utility which will allow me to upgrade my R version and update
> all packages from the old version?
> If I manually upgrade, then I have to manually re-install 50 packages.
> Thank you.
>
> Stephen B
>
>
> [[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] update R version in windows

2017-11-10 Thread Michael Dewey

Dear Stephen

Does section 2.8 in the Windows FAQ help you?

Michael

On 10/11/2017 16:49, Bond, Stephen wrote:

Is there a utility which will allow me to upgrade my R version and update all 
packages from the old version?
If I manually upgrade, then I have to manually re-install 50 packages.
Thank you.

Stephen B


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



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

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


[R] update R version in windows

2017-11-10 Thread Bond, Stephen
Is there a utility which will allow me to upgrade my R version and update all 
packages from the old version?
If I manually upgrade, then I have to manually re-install 50 packages.
Thank you.

Stephen B


[[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] Calculating frequencies of multiple values in 200 colomns

2017-11-10 Thread William Dunlap via R-help
Use table(factor(x, levels=your3values))

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Nov 10, 2017 at 1:32 AM, Allaisone 1  wrote:

>
>
> Thank you for your effort Bert..,
>
>
> I knew what is the problem now, the values (1,2,3) were only an example.
> The values I have are 0 , 1, 2 . Tabulate () function seem to ignore
> calculating the frequency of 0 values and this is my exact problem as the
> frequency of 0 values should also be calculated for the maf to be
> calculated correctly.
>
> 
> From: Bert Gunter 
> Sent: 09 November 2017 23:51:35
> To: Allaisone 1; R-help
> Subject: Re: [R] Calculating frequencies of multiple values in 200 colomns
>
> [[elided Hotmail spam]]
>
> "For example, if I have the values : 1 , 2 , 3 in each column, applying
> Tabulate () would calculate the frequency of 1 and 2 without 3"
>
> Huh??
>
> > x <- sample(1:3,10,TRUE)
> > x
>  [1] 1 3 1 1 1 3 2 3 2 1
> > tabulate(x)
> [1] 5 2 3
>
> 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, Nov 9, 2017 at 3:44 PM, Allaisone 1  mailto:allaiso...@hotmail.com>> wrote:
>
> Thank you so much for your replay
>
>
> Actually, I tried apply() function but struggled with the part of writing
> the appropriate function inside it which calculate the frequency of the 3
> values. Tabulate () function is a good start but the problem is that this
> calculates the frequency of two values only per column which means that
> when I apply maf () function , maf value will be calculated using the
> frequency of these 2 values only without considering the frequency of the
> 3rd value. For example, if I have the values : 1 , 2 , 3 in each column,
> applying Tabulate () would calculate the frequency of 1 and 2 without 3 . I
> need a way to calculate the frequencies of all of the 3 values so the
> calculation of maf will be correct as it will consider all the 3
> frequencies but not only 2 .
>
>
> Regards
>
> Allahisone
>
> 
> From: Bert Gunter mailto:bgunter.4...@gmail.com>>
> Sent: 09 November 2017 20:56:39
> To: Allaisone 1
> Cc: r-help@R-project.org
> Subject: Re: [R] Calculating frequencies of multiple values in 200 colomns
>
> This is not a good way to do things! R has many powerful built in
> functions to do this sort of thing for you. Searching  -- e.g. at
> rseek.org or even a plain old google search -- can help
> you find them. Also, it looks like you need to go through a tutorial or two
> to learn more about R's basic functionality.
>
> In this case, something like (no reproducible example given, so can't
> confirm):
>
> apply(Values, 2, function(x)maf(tabulate(x)))
>
> should be close to what you want .
>
>
> 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, Nov 9, 2017 at 11:44 AM, Allaisone 1  mailto:allaiso...@hotmail.com>> wrote:
>
> Hi All
>
>
> I have a dataset of 200 columns and 1000 rows , there are 3 repeated
> values under each column (7,8,10). I wanted to calculate the frequency of
> each value under each column and then apply the function maf () given that
> the frequency of each value is known. I can do the analysis step by step
> like this :-
>
>
> > Values
>
>
>  A   B   C   ... 200
>
> 1  7   10  7
>
> 2  7   87
>
> 3  10 87
>
> 4   8  7 10
>
> .
>
> .
>
> .
>
>
>
>
> For column A : I calculate the frequency for the 3 values as follows :
>
>  count7 <- length(which(Values$A == 7))
>
> count8 <- length(which(Values$A == 8))
>
> count10 <- length(which(Values$A == 10))
>
>
> count7 = 2, count8 = 1 , count10= 1.
>
>
> Then, I create a vector  and type the frequencies manually :
>
>
>  Freq<- c( count7=2  ,count8= 1,count10=1)
>
>
> Then I apply the function maf ()  :-
>
> maf(Freq)
>
>
> This gives me the result I need for column A , could you please help me
>
> to perform the analysis for all of the 200 columns at once ?
>
>
> Regards
>
> Allahisone
>
>
> [[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/
> p

Re: [R] Calculating frequencies of multiple values in 200 colomns

2017-11-10 Thread Eric Berger
How about this workaround - add 1 to the vector
x <- c(1,0,2,1,0,2,2,0,2,1)
tabulate(x)
# [1] 3 4
tabulate(x+1)
#[1] 3 3 4


On Fri, Nov 10, 2017 at 4:34 PM, Marc Schwartz  wrote:

> Hi,
>
> To clarify the default behavior that Boris is referencing below, note the
> definition of the 'bin' argument to the tabulate() function:
>
> bin: a numeric vector ***(of positive integers)***, or a factor. Long
> vectors are supported.
>
> I added the asterisks for emphasis.
>
> This is also noted in the examples used for the function in ?tabulate at
> the bottom of the help page.
>
> The second argument, 'nbins', which defaults to max(1, bin, na.rm = TRUE),
> also affects the output:
>
> > tabulate(c(2, 3, 5))
> [1] 0 1 1 0 1
>
> In this case, with each element in the returned vector indicating how many
> 1's, 2's, 3's, 4's and 5's are present in the source vector.
>
> Compare that to:
>
> > tabulate(c(2, 3, 5), nbins = 3)
> [1] 0 1 1
>
> In the above example, 5 is ignored.
>
> Note also that tabulate(), unlike table(), does not return a named vector,
> just the frequencies.
>
> While tabulate() is used within the table() function, reviewing the code
> for the latter reveals how the default behavior of tabulate() is modified
> and preceded/wrapped in other code for use there.
>
> Regards,
>
> Marc Schwartz
>
>
> > On Nov 10, 2017, at 8:43 AM, Boris Steipe 
> wrote:
> >
> > |> x <- sample(0:2, 10, replace = TRUE)
> > |> x
> > [1] 1 0 2 1 0 2 2 0 2 1
> > |> tabulate(x)
> > [1] 3 4
> > |> table(x)
> > x
> > 0 1 2
> > 3 3 4
> >
> >
> >
> > B.
> >
> >
> >
> >> On Nov 10, 2017, at 4:32 AM, Allaisone 1 
> wrote:
> >>
> >>
> >>
> >> Thank you for your effort Bert..,
> >>
> >>
> >> I knew what is the problem now, the values (1,2,3) were only an
> example. The values I have are 0 , 1, 2 . Tabulate () function seem to
> ignore calculating the frequency of 0 values and this is my exact problem
> as the frequency of 0 values should also be calculated for the maf to be
> calculated correctly.
> >>
> >> 
> >> From: Bert Gunter 
> >> Sent: 09 November 2017 23:51:35
> >> To: Allaisone 1; R-help
> >> Subject: Re: [R] Calculating frequencies of multiple values in 200
> colomns
> >>
> >> [[elided Hotmail spam]]
> >>
> >> "For example, if I have the values : 1 , 2 , 3 in each column, applying
> Tabulate () would calculate the frequency of 1 and 2 without 3"
> >>
> >> Huh??
> >>
> >>> x <- sample(1:3,10,TRUE)
> >>> x
> >> [1] 1 3 1 1 1 3 2 3 2 1
> >>> tabulate(x)
> >> [1] 5 2 3
> >>
> >> 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, Nov 9, 2017 at 3:44 PM, Allaisone 1  mailto:allaiso...@hotmail.com>> wrote:
> >>
> >> Thank you so much for your replay
> >>
> >>
> >> Actually, I tried apply() function but struggled with the part of
> writing the appropriate function inside it which calculate the frequency of
> the 3 values. Tabulate () function is a good start but the problem is that
> this calculates the frequency of two values only per column which means
> that when I apply maf () function , maf value will be calculated using the
> frequency of these 2 values only without considering the frequency of the
> 3rd value. For example, if I have the values : 1 , 2 , 3 in each column,
> applying Tabulate () would calculate the frequency of 1 and 2 without 3 . I
> need a way to calculate the frequencies of all of the 3 values so the
> calculation of maf will be correct as it will consider all the 3
> frequencies but not only 2 .
> >>
> >>
> >> Regards
> >>
> >> Allahisone
> >>
> >> 
> >> From: Bert Gunter mailto:bgunter.4...@gmail.com
> >>
> >> Sent: 09 November 2017 20:56:39
> >> To: Allaisone 1
> >> Cc: r-help@R-project.org
> >> Subject: Re: [R] Calculating frequencies of multiple values in 200
> colomns
> >>
> >> This is not a good way to do things! R has many powerful built in
> functions to do this sort of thing for you. Searching  -- e.g. at
> rseek.org or even a plain old google search -- can help
> you find them. Also, it looks like you need to go through a tutorial or two
> to learn more about R's basic functionality.
> >>
> >> In this case, something like (no reproducible example given, so can't
> confirm):
> >>
> >> apply(Values, 2, function(x)maf(tabulate(x)))
> >>
> >> should be close to what you want .
> >>
> >>
> >> 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, Nov 9, 2017 at 11:44 AM, Allaisone 1  mailto:allaiso...@hotmail.com>> wrote:
> >>
> >> Hi All
> >>
> >>
> >> I have a dataset of 200 columns and 1000 rows , there are 3

Re: [R] [R-pkgs] Release of ess 0.0.1

2017-11-10 Thread Jorge Cimentada
Hi Martin,

This makes a lot of sense. Once I update the package I will add it. Could
the authors of the 'ESSR' package also add a similar note to their
DESCRIPTION file once the R part of ESS is released?

  This package 'ESSR' is named to match the Emacs Speaks Statistics (ESS)
project.
  It is unrelated to the 'ess' package, designed to download data from the
European
  Social Survey available at http://www.europeansocialsurvey.org

Thanks for raising these thoughts.



---


Jorge Cimentada
*https://cimentadaj.github.io/ *


On Fri, Nov 10, 2017 at 3:12 PM, Martin Maechler  wrote:

> > Jorge Cimentada 
> > on Fri, 10 Nov 2017 14:31:43 +0100 writes:
>
> > Thanks to all. Will consider this change in future releases.
> > ---
>
>
> > Jorge Cimentada
> > *https://cimentadaj.github.io/ *
>
>
> > On Fri, Nov 10, 2017 at 12:41 PM, Rainer Krug <
> rainer_k...@icloud.com>
> > wrote:
>
> >> On 9 Nov 2017, at 15:57, Sam Steingold  wrote:
> >>
> >> * Jorge Cimentada  [2017-11-09 00:02:53
> +0100]:
> >>
> >> I'm happy to announce the release of ess 0.0.1 a package designed to
> >> download data from the European Social Survey
> >>
> >>
> >> Given the existence of ESS (Emacs Speaks Statistics -
> >> https://ess.r-project.org/) the package name "ess" seems
> unfortunate.
> >>
> >>
> >> Agreed. I would suggest to rename the package to avoid conflicts
> (ESS
> >> includes some R code, And I wouldn’t wonder if they would like to
> include
> >> it in a package?).
>
> As a matter of fact, we (the ESS core developers) have e-chatted
> about this and came to the conclusion that we could get along fine with
> an unrelated R package called 'ess', notably as the acronym also
> makes sense for the European Social Survey.
>
> We'd like to ask the 'ess' package authors to add something like the
> following to their ess/DESCRIPTION file:
>
>   This package ess is named to match the European Social Survey (ESS).
>   It is unrelated to the Emacs Speaks Statistics (ESS) project, an
>   emacs-based Integrated Development Environment hosted at
>   https://ess.r-project.org
>
> and last but not least we have thought of 'reserving'  ESSR  as
> the name of a CRAN package that we'd consider using for the R
> part of ESS (there are others, considerably less used, notably
> Julia, Stata and SAS).
>
> Martin Maechler, ETH Zurich
> for ESS core developers
>
>

[[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] Calculating frequencies of multiple values in 200 colomns

2017-11-10 Thread Marc Schwartz
Hi,

To clarify the default behavior that Boris is referencing below, note the 
definition of the 'bin' argument to the tabulate() function:

bin: a numeric vector ***(of positive integers)***, or a factor. Long vectors 
are supported.

I added the asterisks for emphasis.

This is also noted in the examples used for the function in ?tabulate at the 
bottom of the help page.

The second argument, 'nbins', which defaults to max(1, bin, na.rm = TRUE), also 
affects the output:

> tabulate(c(2, 3, 5))
[1] 0 1 1 0 1

In this case, with each element in the returned vector indicating how many 1's, 
2's, 3's, 4's and 5's are present in the source vector.

Compare that to:

> tabulate(c(2, 3, 5), nbins = 3)
[1] 0 1 1

In the above example, 5 is ignored.

Note also that tabulate(), unlike table(), does not return a named vector, just 
the frequencies.

While tabulate() is used within the table() function, reviewing the code for 
the latter reveals how the default behavior of tabulate() is modified and 
preceded/wrapped in other code for use there.

Regards,

Marc Schwartz


> On Nov 10, 2017, at 8:43 AM, Boris Steipe  wrote:
> 
> |> x <- sample(0:2, 10, replace = TRUE)
> |> x
> [1] 1 0 2 1 0 2 2 0 2 1
> |> tabulate(x)
> [1] 3 4
> |> table(x)
> x
> 0 1 2 
> 3 3 4 
> 
> 
> 
> B.
> 
> 
> 
>> On Nov 10, 2017, at 4:32 AM, Allaisone 1  wrote:
>> 
>> 
>> 
>> Thank you for your effort Bert..,
>> 
>> 
>> I knew what is the problem now, the values (1,2,3) were only an example. The 
>> values I have are 0 , 1, 2 . Tabulate () function seem to ignore calculating 
>> the frequency of 0 values and this is my exact problem as the frequency of 0 
>> values should also be calculated for the maf to be calculated correctly.
>> 
>> 
>> From: Bert Gunter 
>> Sent: 09 November 2017 23:51:35
>> To: Allaisone 1; R-help
>> Subject: Re: [R] Calculating frequencies of multiple values in 200 colomns
>> 
>> [[elided Hotmail spam]]
>> 
>> "For example, if I have the values : 1 , 2 , 3 in each column, applying 
>> Tabulate () would calculate the frequency of 1 and 2 without 3"
>> 
>> Huh??
>> 
>>> x <- sample(1:3,10,TRUE)
>>> x
>> [1] 1 3 1 1 1 3 2 3 2 1
>>> tabulate(x)
>> [1] 5 2 3
>> 
>> 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, Nov 9, 2017 at 3:44 PM, Allaisone 1 
>> mailto:allaiso...@hotmail.com>> wrote:
>> 
>> Thank you so much for your replay
>> 
>> 
>> Actually, I tried apply() function but struggled with the part of writing 
>> the appropriate function inside it which calculate the frequency of the 3 
>> values. Tabulate () function is a good start but the problem is that this 
>> calculates the frequency of two values only per column which means that when 
>> I apply maf () function , maf value will be calculated using the frequency 
>> of these 2 values only without considering the frequency of the 3rd value. 
>> For example, if I have the values : 1 , 2 , 3 in each column, applying 
>> Tabulate () would calculate the frequency of 1 and 2 without 3 . I need a 
>> way to calculate the frequencies of all of the 3 values so the calculation 
>> of maf will be correct as it will consider all the 3 frequencies but not 
>> only 2 .
>> 
>> 
>> Regards
>> 
>> Allahisone
>> 
>> 
>> From: Bert Gunter mailto:bgunter.4...@gmail.com>>
>> Sent: 09 November 2017 20:56:39
>> To: Allaisone 1
>> Cc: r-help@R-project.org
>> Subject: Re: [R] Calculating frequencies of multiple values in 200 colomns
>> 
>> This is not a good way to do things! R has many powerful built in functions 
>> to do this sort of thing for you. Searching  -- e.g. at 
>> rseek.org or even a plain old google search -- can help 
>> you find them. Also, it looks like you need to go through a tutorial or two 
>> to learn more about R's basic functionality.
>> 
>> In this case, something like (no reproducible example given, so can't 
>> confirm):
>> 
>> apply(Values, 2, function(x)maf(tabulate(x)))
>> 
>> should be close to what you want .
>> 
>> 
>> 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, Nov 9, 2017 at 11:44 AM, Allaisone 1 
>> mailto:allaiso...@hotmail.com>> wrote:
>> 
>> Hi All
>> 
>> 
>> I have a dataset of 200 columns and 1000 rows , there are 3 repeated values 
>> under each column (7,8,10). I wanted to calculate the frequency of each 
>> value under each column and then apply the function maf () given that the 
>> frequency of each value is known. I can do the analysis step by step like 
>> this :-
>> 
>> 
>>> Values
>> 
>> 
>>A   B   C   ... 200
>> 
>> 1  7   10  

Re: [R] [R-pkgs] Release of ess 0.0.1

2017-11-10 Thread Martin Maechler
> Jorge Cimentada 
> on Fri, 10 Nov 2017 14:31:43 +0100 writes:

> Thanks to all. Will consider this change in future releases.
> ---


> Jorge Cimentada
> *https://cimentadaj.github.io/ *


> On Fri, Nov 10, 2017 at 12:41 PM, Rainer Krug 
> wrote:

>> On 9 Nov 2017, at 15:57, Sam Steingold  wrote:
>> 
>> * Jorge Cimentada  [2017-11-09 00:02:53 +0100]:
>> 
>> I'm happy to announce the release of ess 0.0.1 a package designed to
>> download data from the European Social Survey
>> 
>> 
>> Given the existence of ESS (Emacs Speaks Statistics -
>> https://ess.r-project.org/) the package name "ess" seems unfortunate.
>> 
>> 
>> Agreed. I would suggest to rename the package to avoid conflicts (ESS
>> includes some R code, And I wouldn’t wonder if they would like to include
>> it in a package?).

As a matter of fact, we (the ESS core developers) have e-chatted
about this and came to the conclusion that we could get along fine with
an unrelated R package called 'ess', notably as the acronym also
makes sense for the European Social Survey.

We'd like to ask the 'ess' package authors to add something like the
following to their ess/DESCRIPTION file:

  This package ess is named to match the European Social Survey (ESS).
  It is unrelated to the Emacs Speaks Statistics (ESS) project, an
  emacs-based Integrated Development Environment hosted at
  https://ess.r-project.org

and last but not least we have thought of 'reserving'  ESSR  as
the name of a CRAN package that we'd consider using for the R
part of ESS (there are others, considerably less used, notably
Julia, Stata and SAS).

Martin Maechler, ETH Zurich
for ESS core developers

__
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] Calculating frequencies of multiple values in 200 colomns

2017-11-10 Thread Boris Steipe
|> x <- sample(0:2, 10, replace = TRUE)
|> x
 [1] 1 0 2 1 0 2 2 0 2 1
|> tabulate(x)
[1] 3 4
|> table(x)
x
0 1 2 
3 3 4 



B.



> On Nov 10, 2017, at 4:32 AM, Allaisone 1  wrote:
> 
> 
> 
> Thank you for your effort Bert..,
> 
> 
> I knew what is the problem now, the values (1,2,3) were only an example. The 
> values I have are 0 , 1, 2 . Tabulate () function seem to ignore calculating 
> the frequency of 0 values and this is my exact problem as the frequency of 0 
> values should also be calculated for the maf to be calculated correctly.
> 
> 
> From: Bert Gunter 
> Sent: 09 November 2017 23:51:35
> To: Allaisone 1; R-help
> Subject: Re: [R] Calculating frequencies of multiple values in 200 colomns
> 
> [[elided Hotmail spam]]
> 
> "For example, if I have the values : 1 , 2 , 3 in each column, applying 
> Tabulate () would calculate the frequency of 1 and 2 without 3"
> 
> Huh??
> 
>> x <- sample(1:3,10,TRUE)
>> x
> [1] 1 3 1 1 1 3 2 3 2 1
>> tabulate(x)
> [1] 5 2 3
> 
> 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, Nov 9, 2017 at 3:44 PM, Allaisone 1 
> mailto:allaiso...@hotmail.com>> wrote:
> 
> Thank you so much for your replay
> 
> 
> Actually, I tried apply() function but struggled with the part of writing the 
> appropriate function inside it which calculate the frequency of the 3 values. 
> Tabulate () function is a good start but the problem is that this calculates 
> the frequency of two values only per column which means that when I apply maf 
> () function , maf value will be calculated using the frequency of these 2 
> values only without considering the frequency of the 3rd value. For example, 
> if I have the values : 1 , 2 , 3 in each column, applying Tabulate () would 
> calculate the frequency of 1 and 2 without 3 . I need a way to calculate the 
> frequencies of all of the 3 values so the calculation of maf will be correct 
> as it will consider all the 3 frequencies but not only 2 .
> 
> 
> Regards
> 
> Allahisone
> 
> 
> From: Bert Gunter mailto:bgunter.4...@gmail.com>>
> Sent: 09 November 2017 20:56:39
> To: Allaisone 1
> Cc: r-help@R-project.org
> Subject: Re: [R] Calculating frequencies of multiple values in 200 colomns
> 
> This is not a good way to do things! R has many powerful built in functions 
> to do this sort of thing for you. Searching  -- e.g. at 
> rseek.org or even a plain old google search -- can help you 
> find them. Also, it looks like you need to go through a tutorial or two to 
> learn more about R's basic functionality.
> 
> In this case, something like (no reproducible example given, so can't 
> confirm):
> 
> apply(Values, 2, function(x)maf(tabulate(x)))
> 
> should be close to what you want .
> 
> 
> 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, Nov 9, 2017 at 11:44 AM, Allaisone 1 
> mailto:allaiso...@hotmail.com>> wrote:
> 
> Hi All
> 
> 
> I have a dataset of 200 columns and 1000 rows , there are 3 repeated values 
> under each column (7,8,10). I wanted to calculate the frequency of each value 
> under each column and then apply the function maf () given that the frequency 
> of each value is known. I can do the analysis step by step like this :-
> 
> 
>> Values
> 
> 
> A   B   C   ... 200
> 
> 1  7   10  7
> 
> 2  7   87
> 
> 3  10 87
> 
> 4   8  7 10
> 
> .
> 
> .
> 
> .
> 
> 
> 
> 
> For column A : I calculate the frequency for the 3 values as follows :
> 
> count7 <- length(which(Values$A == 7))
> 
> count8 <- length(which(Values$A == 8))
> 
> count10 <- length(which(Values$A == 10))
> 
> 
> count7 = 2, count8 = 1 , count10= 1.
> 
> 
> Then, I create a vector  and type the frequencies manually :
> 
> 
> Freq<- c( count7=2  ,count8= 1,count10=1)
> 
> 
> Then I apply the function maf ()  :-
> 
> maf(Freq)
> 
> 
> This gives me the result I need for column A , could you please help me
> 
> to perform the analysis for all of the 200 columns at once ?
> 
> 
> Regards
> 
> Allahisone
> 
> 
>[[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 UNSUBSC

Re: [R] [R-pkgs] Release of ess 0.0.1

2017-11-10 Thread Rainer Krug


> On 9 Nov 2017, at 15:57, Sam Steingold  wrote:
> 
>> * Jorge Cimentada  [2017-11-09 00:02:53 +0100]:
>> 
>> I'm happy to announce the release of ess 0.0.1 a package designed to
>> download data from the European Social Survey
> 
> Given the existence of ESS (Emacs Speaks Statistics -
> https://ess.r-project.org/) the package name "ess" seems unfortunate.

Agreed. I would suggest to rename the package to avoid conflicts (ESS includes 
some R code, And I wouldn’t wonder if they would like to include it in a 
package?).


> 
> -- 
> Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1504
> http://steingoldpsychology.com http://www.childpsy.net http://iris.org.il
> http://mideasttruth.com http://thereligionofpeace.com https://jihadwatch.org
> MS Windows: error: the operation completed successfully.
> 
> __
> 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.

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, 
UCT), Dipl. Phys. (Germany)

University of Zürich

Cell:   +41 (0)78 630 66 57
email:  rai...@krugs.de
Skype:  RMkrug

PGP: 0x0F52F982




[[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] Calculating frequencies of multiple values in 200 colomns

2017-11-10 Thread Allaisone 1


Thank you for your effort Bert..,


I knew what is the problem now, the values (1,2,3) were only an example. The 
values I have are 0 , 1, 2 . Tabulate () function seem to ignore calculating 
the frequency of 0 values and this is my exact problem as the frequency of 0 
values should also be calculated for the maf to be calculated correctly.


From: Bert Gunter 
Sent: 09 November 2017 23:51:35
To: Allaisone 1; R-help
Subject: Re: [R] Calculating frequencies of multiple values in 200 colomns

[[elided Hotmail spam]]

"For example, if I have the values : 1 , 2 , 3 in each column, applying 
Tabulate () would calculate the frequency of 1 and 2 without 3"

Huh??

> x <- sample(1:3,10,TRUE)
> x
 [1] 1 3 1 1 1 3 2 3 2 1
> tabulate(x)
[1] 5 2 3

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, Nov 9, 2017 at 3:44 PM, Allaisone 1 
mailto:allaiso...@hotmail.com>> wrote:

Thank you so much for your replay


Actually, I tried apply() function but struggled with the part of writing the 
appropriate function inside it which calculate the frequency of the 3 values. 
Tabulate () function is a good start but the problem is that this calculates 
the frequency of two values only per column which means that when I apply maf 
() function , maf value will be calculated using the frequency of these 2 
values only without considering the frequency of the 3rd value. For example, if 
I have the values : 1 , 2 , 3 in each column, applying Tabulate () would 
calculate the frequency of 1 and 2 without 3 . I need a way to calculate the 
frequencies of all of the 3 values so the calculation of maf will be correct as 
it will consider all the 3 frequencies but not only 2 .


Regards

Allahisone


From: Bert Gunter mailto:bgunter.4...@gmail.com>>
Sent: 09 November 2017 20:56:39
To: Allaisone 1
Cc: r-help@R-project.org
Subject: Re: [R] Calculating frequencies of multiple values in 200 colomns

This is not a good way to do things! R has many powerful built in functions to 
do this sort of thing for you. Searching  -- e.g. at 
rseek.org or even a plain old google search -- can help you 
find them. Also, it looks like you need to go through a tutorial or two to 
learn more about R's basic functionality.

In this case, something like (no reproducible example given, so can't confirm):

apply(Values, 2, function(x)maf(tabulate(x)))

should be close to what you want .


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, Nov 9, 2017 at 11:44 AM, Allaisone 1 
mailto:allaiso...@hotmail.com>> wrote:

Hi All


I have a dataset of 200 columns and 1000 rows , there are 3 repeated values 
under each column (7,8,10). I wanted to calculate the frequency of each value 
under each column and then apply the function maf () given that the frequency 
of each value is known. I can do the analysis step by step like this :-


> Values


 A   B   C   ... 200

1  7   10  7

2  7   87

3  10 87

4   8  7 10

.

.

.




For column A : I calculate the frequency for the 3 values as follows :

 count7 <- length(which(Values$A == 7))

count8 <- length(which(Values$A == 8))

count10 <- length(which(Values$A == 10))


count7 = 2, count8 = 1 , count10= 1.


Then, I create a vector  and type the frequencies manually :


 Freq<- c( count7=2  ,count8= 1,count10=1)


Then I apply the function maf ()  :-

maf(Freq)


This gives me the result I need for column A , could you please help me

to perform the analysis for all of the 200 columns at once ?


Regards

Allahisone


[[alternative HTML version deleted]]

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



[[alternative HTML version deleted]]

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


Re: [R] [R-pkgs] Release of ess 0.0.1

2017-11-10 Thread Jorge Cimentada
Thanks to all. Will consider this change in future releases.

---


Jorge Cimentada
*https://cimentadaj.github.io/ *


On Fri, Nov 10, 2017 at 12:41 PM, Rainer Krug 
wrote:

>
>
> On 9 Nov 2017, at 15:57, Sam Steingold  wrote:
>
> * Jorge Cimentada  [2017-11-09 00:02:53 +0100]:
>
> I'm happy to announce the release of ess 0.0.1 a package designed to
> download data from the European Social Survey
>
>
> Given the existence of ESS (Emacs Speaks Statistics -
> https://ess.r-project.org/) the package name "ess" seems unfortunate.
>
>
> Agreed. I would suggest to rename the package to avoid conflicts (ESS
> includes some R code, And I wouldn’t wonder if they would like to include
> it in a package?).
>
>
>
> --
> Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1504
> http://steingoldpsychology.com http://www.childpsy.net http://iris.org.il
> http://mideasttruth.com http://thereligionofpeace.com
> https://jihadwatch.org
> MS Windows: error: the operation completed successfully.
>
> __
> 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.
>
>
> --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
> Biology, UCT), Dipl. Phys. (Germany)
>
> University of Zürich
>
> Cell:   +41 (0)78 630 66 57 <+41%2078%20630%2066%2057>
> email:  rai...@krugs.de 
> Skype:  RMkrug
>
> PGP: 0x0F52F982
>
>
>
>

[[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] How to create separate legend for each plot in the function of facet_wrap in ggplot2?

2017-11-10 Thread Dominik Schneider
That's not the point of facet_wrap so check out the cowplot package for
combining multiple ggplot objects (with legends) into one figure.

On Fri, Nov 10, 2017 at 10:21 AM, Marna Wagley 
wrote:

> Hi R users,
> I need to create more than 20 figures (one for each group) in one page. I
> have a  common  legend for 20 figures using the facet_wrap. However the
> range of the values among the groups are very wide. For example one group
> has the value of 0 to 3, but the values of some of the groups has ranged
> from 0 to 20 so that when I used a single common legend for all 20 figures,
> I could not display the contrast of the values in some of the figures.
> Therefore I wanted to create the figures with *a separate legend*.In this
> way, I can display the gradient of the values in each figure.  Any
> suggestions on how I can create it.
>
> The example is given below, *I wanted to create a separate legend with
> keeping legend inside of each of the figure*.
>
> library(ggplot2)
>
> dat<-structure(list(X = c(289.6, 289.7, 289.8, 289.9, 290, 290.1,
>
> 927.8, 927.9, 928, 928.1, 928.2, 928.3), Y = c(789.1, 789.2,
>
> 789.3, 789.4, 789.5, 789.6, 171.1, 171.2, 171.3, 171.4, 171.5,
>
> 171.6), value = c(0.05, 0.06, 0.07, 0.09, 0.1, 0.11, 0.06, 0.05,
>
> 0.05, 0.06, 0.1, 1.5), group = structure(c(1L, 1L, 1L, 1L, 1L,
>
> 1L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("A", "B"), class = "factor")),
> .Names = c("X",
>
> "Y", "value", "group"), class = "data.frame", row.names = c(NA,
>
> -12L))
>
>
> AB<-ggplot(data = dat, aes(x = X, y = Y, color =  value)) +
> geom_point(size
> =2) +
>
> coord_equal() +  theme_bw()+ scale_color_gradientn(colours =
> terrain.colors(
> 7))
>
> AB+facet_wrap(~group,  scales="free")+theme(strip.text = element_text(size
> = 8))
>
>
>
>
> Thanks
>
>
> MW
>
> [[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] How to create separate legend for each plot in the function of facet_wrap in ggplot2?

2017-11-10 Thread Marna Wagley
Hi R users,
I need to create more than 20 figures (one for each group) in one page. I
have a  common  legend for 20 figures using the facet_wrap. However the
range of the values among the groups are very wide. For example one group
has the value of 0 to 3, but the values of some of the groups has ranged
from 0 to 20 so that when I used a single common legend for all 20 figures,
I could not display the contrast of the values in some of the figures.
Therefore I wanted to create the figures with *a separate legend*.In this
way, I can display the gradient of the values in each figure.  Any
suggestions on how I can create it.

The example is given below, *I wanted to create a separate legend with
keeping legend inside of each of the figure*.

library(ggplot2)

dat<-structure(list(X = c(289.6, 289.7, 289.8, 289.9, 290, 290.1,

927.8, 927.9, 928, 928.1, 928.2, 928.3), Y = c(789.1, 789.2,

789.3, 789.4, 789.5, 789.6, 171.1, 171.2, 171.3, 171.4, 171.5,

171.6), value = c(0.05, 0.06, 0.07, 0.09, 0.1, 0.11, 0.06, 0.05,

0.05, 0.06, 0.1, 1.5), group = structure(c(1L, 1L, 1L, 1L, 1L,

1L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("A", "B"), class = "factor")),
.Names = c("X",

"Y", "value", "group"), class = "data.frame", row.names = c(NA,

-12L))


AB<-ggplot(data = dat, aes(x = X, y = Y, color =  value)) +  geom_point(size
=2) +

coord_equal() +  theme_bw()+ scale_color_gradientn(colours = terrain.colors(
7))

AB+facet_wrap(~group,  scales="free")+theme(strip.text = element_text(size
= 8))




Thanks


MW

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