Re: [R] HISTOGRAM

2018-11-09 Thread Rick Bilonick
First, a histogram would not be appropriate (your data appear to be
categorical - a histogram is for continuous numeric vales) - you would need
a bar plot. You should make two vectors (one for the category names and the
other for the frequencies) and use the barplot function.

On Fri, Nov 9, 2018 at 1:46 PM Medic  wrote:

> What would be the correct code (simplest version) (without gplot())
> for histogram (with 7 bars), which would include 7 names of bars under
> the X-axis. The data are:
>
> name number
> ds6277
> lk 24375
> ax46049
> dd70656
> az216544
> df 220620
> gh641827
>
> (I'm attaching mydata.r, making with dput.)
>
> My attempt is:
>
> options(scipen=999)
> with (mydata, hist(number))
>
> P.S. I can't understand how the column "name" to include in a code
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-helpdata=02%7C01%7Crab45%40pitt.edu%7C55f2571738b246f9dc1e08d646739b27%7C9ef9f489e0a04eeb87cc3a526112fd0d%7C1%7C0%7C636773859721875419sdata=haHuxll2%2FO0Dci0fSpd0evjfi0MTmLi0JoghvHxlz3o%3Dreserved=0
> PLEASE do read the posting guide
> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.R-project.org%2Fposting-guide.htmldata=02%7C01%7Crab45%40pitt.edu%7C55f2571738b246f9dc1e08d646739b27%7C9ef9f489e0a04eeb87cc3a526112fd0d%7C1%7C0%7C636773859721875419sdata=aL6arSyKx4m9LBdOMhdhSpsdJmGCHubfdI%2Fns4Rgytw%3Dreserved=0
> 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] Read

2018-11-09 Thread Rui Barradas

Hello,

I've just tested Jeff's solution, it works but the second code line 
should be


dsh <- sh[ , -length( sh ) ]


(dsh doesn't exist yet.)

Hope this helps,

Rui Barradas

Às 02:46 de 10/11/2018, Jeff Newmiller escreveu:
Your file has 5 commas in the first data row, but only 4 in the header. 
R interprets this to mean your first column is intended to be row names 
(has no corresponding column label) rather than data. (Row names are 
"outside" the data frame... use str(dsh) to get a better picture.)


Basically, your file does not conform to consistent practices for csv 
files of having the same number of commas in every row. If at all 
possible I would eliminate the extra comma. If you have many of these 
broken files, you might need to read the data in pieces... e.g.


dsh <- read.csv( "dat.csv", header=FALSE, skip=1 )
dsh <- dsh[ , -length( dsh ) ]
dshh <- read.csv( "dat.csv", header=TRUE, nrow=1)
names( dsh ) <- names( dshh )

On Fri, 9 Nov 2018, Val wrote:


HI all,
I am trying to read a csv file, but  have a problem in the row names.
After reading, the name of the first column is now "row.names" and
all other column names are shifted to the right. The value of the last
column become all NAs( as an extra column).

My sample data looks like as follow,
filename = dat.csv
The first row has a missing value at column 3 and 5. The last row has
a missing value at column 1 and  5
x1,x2,x3,x4,x5
12,13,,14,,
22,23,24,25,26
,33,34,34,
To read the file I used this

dsh<-read.csv(file="dat.csv",sep=",",row.names=NULL,fill=TRUE,header=TRUE,comment.char 


= "", quote = "", stringsAsFactors = FALSE)

The output  from the above  is
dsh

row.names x1 x2 x3 x4 x5
1    12 13 NA 14 NA  NA
2    22 23 24 25 26  NA
3 33 34 34 NA  NA

The name of teh frist column is row,banes and all values of last 
columns is NAs



However, the desired output should be
x1 x2 x3 x4 x5
12 13 NA 14 NA
22 23 24 25 26
NA 33 34 34 NA


How can I fix this?
Thank you in advance

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

and provide commented, minimal, self-contained, reproducible code.



---
Jeff Newmiller    The .   .  Go Live...
DCN:    Basics: ##.#.   ##.#.  Live Go...
   Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries    O.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

__
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] Read

2018-11-09 Thread Jeff Newmiller
Your file has 5 commas in the first data row, but only 4 in the header. R 
interprets this to mean your first column is intended to be row names (has 
no corresponding column label) rather than data. (Row names are "outside" 
the data frame... use str(dsh) to get a better picture.)


Basically, your file does not conform to consistent practices for csv 
files of having the same number of commas in every row. If at all possible 
I would eliminate the extra comma. If you have many of these broken files, 
you might need to read the data in pieces... e.g.


dsh <- read.csv( "dat.csv", header=FALSE, skip=1 )
dsh <- dsh[ , -length( dsh ) ]
dshh <- read.csv( "dat.csv", header=TRUE, nrow=1)
names( dsh ) <- names( dshh )

On Fri, 9 Nov 2018, Val wrote:


HI all,
I am trying to read a csv file, but  have a problem in the row names.
After reading, the name of the first column is now "row.names" and
all other column names are shifted to the right. The value of the last
column become all NAs( as an extra column).

My sample data looks like as follow,
filename = dat.csv
The first row has a missing value at column 3 and 5. The last row has
a missing value at column 1 and  5
x1,x2,x3,x4,x5
12,13,,14,,
22,23,24,25,26
,33,34,34,
To read the file I used this

dsh<-read.csv(file="dat.csv",sep=",",row.names=NULL,fill=TRUE,header=TRUE,comment.char
= "", quote = "", stringsAsFactors = FALSE)

The output  from the above  is
dsh

row.names x1 x2 x3 x4 x5
112 13 NA 14 NA  NA
222 23 24 25 26  NA
3 33 34 34 NA  NA

The name of teh frist column is row,banes and all values of last columns is NAs


However, the desired output should be
x1 x2 x3 x4 x5
12 13 NA 14 NA
22 23 24 25 26
NA 33 34 34 NA


How can I fix this?
Thank you in advance

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



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

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


[ESS] makeinfo error in MacOS

2018-11-09 Thread Cyrus Harmon via ESS-help
When I try to build ESS on MacOS (mojave, 10.14.1) (and other systems as I’ve 
seen this for a while now), I see the following error:

...
making Info documentation...
LC_ALL=C LANG=en makeinfo ess.texi
/Users/sly/.emacs.d/site-lisp/ESS/doc//newfeat.texi:42: warning: `.' or `,' 
must follow @xref, not `f'.
/Users/sly/.emacs.d/site-lisp/ESS/doc//newfeat.texi:76: warning: `.' or `,' 
must follow @xref, not `@'.
/Users/sly/.emacs.d/site-lisp/ESS/doc//newfeat.texi:135: Unknown command `ESS:'.
ess.texi:3060: warning: `.' or `,' must follow @xref, not `f'.
/Users/sly/.emacs.d/site-lisp/ESS/doc//installation.texi:117: `Check 
Installation' has no Up field (perhaps incorrect sectioning?).
/Users/sly/.emacs.d/site-lisp/ESS/doc//installation.texi:79: `Activating and 
Loading ESS' has no Up field (perhaps incorrect sectioning?).
/Users/sly/.emacs.d/site-lisp/ESS/doc//installation.texi:34: `Installing from 
source' has no Up field (perhaps incorrect sectioning?).
/Users/sly/.emacs.d/site-lisp/ESS/doc//installation.texi:16: `Installing from a 
third-party repository' has no Up field (perhaps incorrect sectioning?).
makeinfo: Removing output file `/Users/sly/.emacs.d/site-lisp/ESS/doc/ess.info' 
due to errors; use --force to preserve.
make[1]: [info/ess.info] Error 1 (ignored)
mv -f ess.info info/
mv: rename ess.info to info/ess.info: No such file or directory
make[1]: *** [info/ess.info] Error 1
make: *** [all] Error 2

I’m sure I could have some wonky makeinfo installed by homebrew but I figured 
I’d ask here to see if anyone has seen this.

thanks,

Cyrus

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


[R] Read

2018-11-09 Thread Val
HI all,
I am trying to read a csv file, but  have a problem in the row names.
After reading, the name of the first column is now "row.names" and
all other column names are shifted to the right. The value of the last
column become all NAs( as an extra column).

My sample data looks like as follow,
filename = dat.csv
The first row has a missing value at column 3 and 5. The last row has
a missing value at column 1 and  5
x1,x2,x3,x4,x5
12,13,,14,,
22,23,24,25,26
,33,34,34,
To read the file I used this

dsh<-read.csv(file="dat.csv",sep=",",row.names=NULL,fill=TRUE,header=TRUE,comment.char
= "", quote = "", stringsAsFactors = FALSE)

The output  from the above  is
dsh

 row.names x1 x2 x3 x4 x5
112 13 NA 14 NA  NA
222 23 24 25 26  NA
3 33 34 34 NA  NA

The name of teh frist column is row,banes and all values of last columns is NAs


However, the desired output should be
 x1 x2 x3 x4 x5
 12 13 NA 14 NA
 22 23 24 25 26
 NA 33 34 34 NA


How can I fix this?
Thank you in advance

__
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] list contingency tables

2018-11-09 Thread Bert Gunter
Yes, exactly (heh, heh).

?fisher.test

is probably what is wanted.

For arbitrary rxc tables with fixed marginals, this is a difficult problem.
Mehta's efficient network algorithm to solve it can be found by a web
search on "algorithm for Fisher exact test."

-- Bert



On Fri, Nov 9, 2018 at 12:36 PM David Winsemius 
wrote:

> Seems like you are trying to recreate the calculations needed to perform
> an exact test. Why not look at the code for that or even easier, just
> use the function.
>
> --
>
> David.
>
> On 11/8/18 8:05 PM, li li wrote:
> > Hi all,
> >I am trying to list all the 4 by 2 tables with some fixed margins.
> >For example, consider 4 by 2 tables with row margins 1,2,2,1 and
> > column margins 3,3. I was able to do it using the code below. However,
> > as seen below, I had to first count the total number of tables with
> > the specific row margins and column margins in order to create space
> > to store the tables.
> > Is there a way to skip the step of counting the number of tables?
> >Also, wanted to avoid for loops as much as possible since it can be
> > extremely slow and inefficient.
> > Thanks so much in advance for you insight and help.
> > Hanna
> >
> >
> >
> >> library(gtools)
> >> A <- permutations(n=4,r=2,v=0:3, repeats.allowed=TRUE)
> >> B <- apply(A, 1, sum)
> >> rmg <- c(1,2,2,1)
> >> cmg <- c(3,3)
> >> m1 <- t(A[which(B==1),])
> >> m2 <- t(A[which(B==2),])
> >> m3 <- t(A[which(B==2),])
> >>
> >> ##count number of tables with row margins 1,2,2,1 and column margins
> 3,3.
> >> num <- 0
> >> for (i in 1:ncol(m1)){
> > + for (j in 1:ncol(m2)){
> > + for (k in 1:ncol(m3)){
> > + M <- t(cbind(m1[,i], m2[,j], m3[,k]))
> > + M1 <- rbind(M, cmg-apply(M,2,sum))
> > + num <- num+(sum(M1[4,] < 0) == 0)
> > + }}}
> >>
> >> #create space to store the tables
> >> C <- array(NA, dim=c(4,2,num))
> >>
> >> # list all the tables with fixed margins
> >> num <- 0
> >> for (i in 1:ncol(m1)){
> > + for (j in 1:ncol(m2)){
> > + for (k in 1:ncol(m3)){
> > + M <- t(cbind(m1[,i], m2[,j], m3[,k]))
> > + M1 <- rbind(M,cmg-apply(M,2,sum))
> > + if (sum(M1[4,] < 0) == 0) {
> > + num <- num+1
> > +C[,,num] <- M1
> > + }
> > + }}}
> >> C
> > , , 1
> >
> >   [,1] [,2]
> > [1,]01
> > [2,]02
> > [3,]20
> > [4,]10
> >
> > , , 2
> >
> >   [,1] [,2]
> > [1,]01
> > [2,]11
> > [3,]11
> > [4,]10
> >
> > , , 3
> >
> >   [,1] [,2]
> > [1,]01
> > [2,]11
> > [3,]20
> > [4,]01
> >
> > , , 4
> >
> >   [,1] [,2]
> > [1,]01
> > [2,]20
> > [3,]02
> > [4,]10
> >
> > , , 5
> >
> >   [,1] [,2]
> > [1,]01
> > [2,]20
> > [3,]11
> > [4,]01
> >
> > , , 6
> >
> >   [,1] [,2]
> > [1,]10
> > [2,]02
> > [3,]11
> > [4,]10
> >
> > , , 7
> >
> >   [,1] [,2]
> > [1,]10
> > [2,]02
> > [3,]20
> > [4,]01
> >
> > , , 8
> >
> >   [,1] [,2]
> > [1,]10
> > [2,]11
> > [3,]02
> > [4,]10
> >
> > , , 9
> >
> >   [,1] [,2]
> > [1,]10
> > [2,]11
> > [3,]11
> > [4,]01
> >
> > , , 10
> >
> >   [,1] [,2]
> > [1,]10
> > [2,]20
> > [3,]02
> > [4,]01
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] list contingency tables

2018-11-09 Thread David Winsemius
Seems like you are trying to recreate the calculations needed to perform 
an exact test. Why not look at the code for that or even easier, just 
use the function.


--

David.

On 11/8/18 8:05 PM, li li wrote:

Hi all,
   I am trying to list all the 4 by 2 tables with some fixed margins.
   For example, consider 4 by 2 tables with row margins 1,2,2,1 and
column margins 3,3. I was able to do it using the code below. However,
as seen below, I had to first count the total number of tables with
the specific row margins and column margins in order to create space
to store the tables.
Is there a way to skip the step of counting the number of tables?
   Also, wanted to avoid for loops as much as possible since it can be
extremely slow and inefficient.
Thanks so much in advance for you insight and help.
Hanna




library(gtools)
A <- permutations(n=4,r=2,v=0:3, repeats.allowed=TRUE)
B <- apply(A, 1, sum)
rmg <- c(1,2,2,1)
cmg <- c(3,3)
m1 <- t(A[which(B==1),])
m2 <- t(A[which(B==2),])
m3 <- t(A[which(B==2),])

##count number of tables with row margins 1,2,2,1 and column margins 3,3.
num <- 0
for (i in 1:ncol(m1)){

+ for (j in 1:ncol(m2)){
+ for (k in 1:ncol(m3)){
+ M <- t(cbind(m1[,i], m2[,j], m3[,k]))
+ M1 <- rbind(M, cmg-apply(M,2,sum))
+ num <- num+(sum(M1[4,] < 0) == 0)
+ }}}


#create space to store the tables
C <- array(NA, dim=c(4,2,num))

# list all the tables with fixed margins
num <- 0
for (i in 1:ncol(m1)){

+ for (j in 1:ncol(m2)){
+ for (k in 1:ncol(m3)){
+ M <- t(cbind(m1[,i], m2[,j], m3[,k]))
+ M1 <- rbind(M,cmg-apply(M,2,sum))
+ if (sum(M1[4,] < 0) == 0) {
+ num <- num+1
+C[,,num] <- M1
+ }
+ }}}

C

, , 1

  [,1] [,2]
[1,]01
[2,]02
[3,]20
[4,]10

, , 2

  [,1] [,2]
[1,]01
[2,]11
[3,]11
[4,]10

, , 3

  [,1] [,2]
[1,]01
[2,]11
[3,]20
[4,]01

, , 4

  [,1] [,2]
[1,]01
[2,]20
[3,]02
[4,]10

, , 5

  [,1] [,2]
[1,]01
[2,]20
[3,]11
[4,]01

, , 6

  [,1] [,2]
[1,]10
[2,]02
[3,]11
[4,]10

, , 7

  [,1] [,2]
[1,]10
[2,]02
[3,]20
[4,]01

, , 8

  [,1] [,2]
[1,]10
[2,]11
[3,]02
[4,]10

, , 9

  [,1] [,2]
[1,]10
[2,]11
[3,]11
[4,]01

, , 10

  [,1] [,2]
[1,]10
[2,]20
[3,]02
[4,]01

__
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] list contingency tables

2018-11-09 Thread Jeff Newmiller
Don't give up on for loops entirely... some of the largest time savings in 
optimizing loops are achieved by managing memory effectively. [1]

[1] https://www.r-bloggers.com/r-tip-use-vectormode-list-to-pre-allocate-lists


On November 8, 2018 8:05:39 PM PST, li li  wrote:
>Hi all,
>  I am trying to list all the 4 by 2 tables with some fixed margins.
>  For example, consider 4 by 2 tables with row margins 1,2,2,1 and
>column margins 3,3. I was able to do it using the code below. However,
>as seen below, I had to first count the total number of tables with
>the specific row margins and column margins in order to create space
>to store the tables.
>Is there a way to skip the step of counting the number of tables?
>  Also, wanted to avoid for loops as much as possible since it can be
>extremely slow and inefficient.
>   Thanks so much in advance for you insight and help.
>   Hanna
>
>
>
>> library(gtools)
>> A <- permutations(n=4,r=2,v=0:3, repeats.allowed=TRUE)
>> B <- apply(A, 1, sum)
>> rmg <- c(1,2,2,1)
>> cmg <- c(3,3)
>> m1 <- t(A[which(B==1),])
>> m2 <- t(A[which(B==2),])
>> m3 <- t(A[which(B==2),])
>>
>> ##count number of tables with row margins 1,2,2,1 and column margins
>3,3.
>> num <- 0
>> for (i in 1:ncol(m1)){
>+ for (j in 1:ncol(m2)){
>+ for (k in 1:ncol(m3)){
>+ M <- t(cbind(m1[,i], m2[,j], m3[,k]))
>+ M1 <- rbind(M, cmg-apply(M,2,sum))
>+ num <- num+(sum(M1[4,] < 0) == 0)
>+ }}}
>>
>>
>> #create space to store the tables
>> C <- array(NA, dim=c(4,2,num))
>>
>> # list all the tables with fixed margins
>> num <- 0
>> for (i in 1:ncol(m1)){
>+ for (j in 1:ncol(m2)){
>+ for (k in 1:ncol(m3)){
>+ M <- t(cbind(m1[,i], m2[,j], m3[,k]))
>+ M1 <- rbind(M,cmg-apply(M,2,sum))
>+ if (sum(M1[4,] < 0) == 0) {
>+ num <- num+1
>+C[,,num] <- M1
>+ }
>+ }}}
>>
>> C
>, , 1
>
> [,1] [,2]
>[1,]01
>[2,]02
>[3,]20
>[4,]10
>
>, , 2
>
> [,1] [,2]
>[1,]01
>[2,]11
>[3,]11
>[4,]10
>
>, , 3
>
> [,1] [,2]
>[1,]01
>[2,]11
>[3,]20
>[4,]01
>
>, , 4
>
> [,1] [,2]
>[1,]01
>[2,]20
>[3,]02
>[4,]10
>
>, , 5
>
> [,1] [,2]
>[1,]01
>[2,]20
>[3,]11
>[4,]01
>
>, , 6
>
> [,1] [,2]
>[1,]10
>[2,]02
>[3,]11
>[4,]10
>
>, , 7
>
> [,1] [,2]
>[1,]10
>[2,]02
>[3,]20
>[4,]01
>
>, , 8
>
> [,1] [,2]
>[1,]10
>[2,]11
>[3,]02
>[4,]10
>
>, , 9
>
> [,1] [,2]
>[1,]10
>[2,]11
>[3,]11
>[4,]01
>
>, , 10
>
> [,1] [,2]
>[1,]10
>[2,]20
>[3,]02
>[4,]01
>
>__
>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.

-- 
Sent from my phone. Please excuse my brevity.

__
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] HISTOGRAM

2018-11-09 Thread Rui Barradas

Hello,

You probably want a bar plot, not a histogram.

old.sci <- options(scipen=999)
with(mydata, barplot(number, space = 0, names.arg = name, beside = TRUE))
options(scipen = old.sci)


#-

mydata <- read.table(text = "
name number
ds6277
lk 24375
ax46049
dd70656
az216544
df 220620
gh641827
", header = TRUE)
mydata


Hope this helps,

Rui Barradas

Às 18:45 de 09/11/2018, Medic escreveu:

What would be the correct code (simplest version) (without gplot())
for histogram (with 7 bars), which would include 7 names of bars under
the X-axis. The data are:

name number
ds6277
lk 24375
ax46049
dd70656
az216544
df 220620
gh641827

(I'm attaching mydata.r, making with dput.)

My attempt is:

options(scipen=999)
with (mydata, hist(number))

P.S. I can't understand how the column "name" to include in a code
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



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


Re: [ESS] ESS R code evaluation in package

2018-11-09 Thread Cyrus Harmon via ESS-help



On 11/8/18 2:32 PM, Vitalie Spinu via ESS-help wrote:


Namespaced evaluation should work for R code as described above. If not, it's a
bug.


These probably aren't bugs but now that I've gotten things to a somewhat 
more manageable state my next problem is getting things working with 
polymode. When I'm editing an Rmd file and have ```{r ...} blocks 
polymode does the right thing and allows me and C-c C-r blocks of code 
and mostly the right thing happens. The problem is that I don't see the 
[pkg:...] line on the emacs status bar and my code seems to be evaluated 
in an undexpected environment. I'm not sure if this is a polymode or an 
ESS problem but is there someway to specify the pkg in which ESS should 
be evaluating code? Presumably when editing R code it's finding the 
nearest NAMESPACE file and using that but there could be some other 
mechanism. Should I be asking in some polymode forum or here?


I'm missing lisp's (in-package ...) forms that make it relatively clear 
in which context code is supposed to be evaluated. The NAMESPACE thing 
is a rather blunt instrument.


thanks,

Cyrus

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


[R-es] Data frame: eliminar caracteres raros y convertir 2 columnas a formato numerico

2018-11-09 Thread Sebastian Kruk
Estimados usuarios de R:

Muy buenas tardes.

Hace días que estoy dando vueltas con un data frame de 28 observaciones con
3 variables llamado data que lo obtuve de transformar unas tablas html.

La primer y segunda variable tienen 28 niveles y la tercera 25 niveles.

¿Hay alguna forma de dejarlo sin factores?

Tiene tres columnas, en la primera están los productos, en la segunda la
cantidad vendida y en la tercera la plata.

Por medio de la siguiente sentencia elimino los Â:

data <- apply(data, 2, function(y) gsub("Â*", "", y))

Tiene como problema que hace que se me convierta en una lista el data frame.

En la variable ventas y plata tengo algunas celdas vacías y el separador de
miles es la coma y a su vez no tengo decimales.

Para resolver lo anterior aplico:

data[,2:3] <- apply(data[,2:3], 2, function(y) gsub(",", "", y))

Finalmente quiero pasar a formato numérico las últimas dos columnas usando:

data[,2:3] <- apply(data[,2:3], 2, as.numeric)

Pero no tiene efecto.

¿Me pueden dar alguna ayuda u orientar?

Gracias,

Sebastián.

[[alternative HTML version deleted]]

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


[R] HISTOGRAM

2018-11-09 Thread Medic
What would be the correct code (simplest version) (without gplot())
for histogram (with 7 bars), which would include 7 names of bars under
the X-axis. The data are:

name number
ds6277
lk 24375
ax46049
dd70656
az216544
df 220620
gh641827

(I'm attaching mydata.r, making with dput.)

My attempt is:

options(scipen=999)
with (mydata, hist(number))

P.S. I can't understand how the column "name" to include in a 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] randomForrest-imputation

2018-11-09 Thread Dénes Tóth

Hi,

The missRanger package performs predictive mean matching which should 
generate positive values if the non-missing values are positive.


Regards,
Denes


On 11/09/2018 01:11 PM, Rebecca Bingert wrote:

Hi!

How can I generate only positive data with randomForrest-imputation? I'm
working with laboratory values which are always positive.

Can anybody help out?

Thanks!

(P.S.: I needed to send this request again because there were problems 
by delivering it)


__
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] randomForrest-imputation

2018-11-09 Thread Rebecca Bingert

Hi!

How can I generate only positive data with randomForrest-imputation? I'm
working with laboratory values which are always positive.

Can anybody help out?

Thanks!

(P.S.: I needed to send this request again because there were problems by 
delivering it)

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


[R] [R-pkgs] New Package pgsc

2018-11-09 Thread Philip Barrett
Dear all,

I am pleased to announce a new CRAN package, "pgsc" version 1.0.0 <
https://cran.r-project.org/package=pgsc>.

This package implements the extension of the synthetic control method to
allow for continuous and time-varying treatments described in Powell (2017)
.  Functions for both estimation and general hypothesis
testing are provided.

The vignette presents an extended example where panel regression suffers
from omitted variables bias -- even with time and unit fixed effects -- and
shows how the generalized synthetic control method produces unbiased
estimates of treatment effects.  The vignette can be found at <
https://cran.r-project.org/web/packages/pgsc/vignettes/pgsc_vignette.pdf>.

Suggestions and comments much appreciated,

Philip Barrett

Email: pobarrett at gmail dot com
Github: https://github.com/philipbarrett/pgsc

[[alternative HTML version deleted]]

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

__
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] Visualizar grandes volumenes de datos

2018-11-09 Thread Jesús Para Fernández
Gracias chicos

Jesús

De: Carlos Ortega 
Enviado: jueves, 8 de noviembre de 2018 22:05
Para: Jesús Para Fernández
Cc: Lista R
Asunto: Re: [R-es] Visualizar grandes volumenes de datos

Otra opción es esta:

https://db.rstudio.com/dbplot/

Que es un paquete que ha creado Edgar Ruiz (RStudio) justo para representar 
gráficamente grandes volúmenes de datos y que está integrado con "sparklyr".
Incluye funciones para histogramas y representación raster de gráficos 
bivariados, me parece que esto último es lo que quieres hacer.

Saludos,
Carlos Ortega
www.qualityexcellence.es


El jue., 8 nov. 2018 a las 16:06, Eric 
(mailto:ericconchamu...@gmail.com>>) escribió:
Hola Jesus, dando una mirada por internet veo algunas paginas que te
podrian ayudar:


https://cran.r-project.org/web/packages/tabplot/vignettes/tabplot-vignette.html

http://geog.uoregon.edu/bartlein/courses/geog490/week08-visualizing.html

https://stackoverflow.com/questions/10945707/speed-up-plot-function-for-large-dataset


Saludos !!

Eric.


On 08/11/2018 09:13, Jesús Para Fernández wrote:
> Buenas,
>
> He probado a intentar graficar mas de 700.000 puntos y es una locura. No doy 
> con una libreria que consiga graficar grandes volumenes de datos. �Existe 
> alguna en R?
>
> Gracias
> 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

[[alternative HTML version deleted]]

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


--
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

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