Re: [R] two difficult loop

2016-06-12 Thread greg holly
Hi Bert;

I do appreciate for this. I need check your codes on task2 tomorrow at my
office on the real data as I have difficulty (because a technical issue) to
remote connection. I am sure it will work well.

I am sorry that I was not able to explain my first question. Basically

Values in ref data represent the region of chromosome. I need choose these
regions in map (all regions values in ref data are exist in map data in the
first column -column map$reg). And then summing up the column "map$rate and
count the numbers that gives >0.85. For example, consider  the first row in
data ref. They are 29220   and  63933. After sorting the first column in
map then summing column "map$rate" only between 29220   to  63933 in sorted
map and cut off at >0.85. Then count how many rows in sorted map gives
>0.85. For example consider there are 38 rows between 29220   in  63933 in 
>sorted
map$reg and only summing first 12 of them  gives>0.85. Then my answer is
going to be 12 for 29220   -  63933 in ref.

Thanks I lot for your patience.

Cheers,
Greg

On Sun, Jun 12, 2016 at 10:35 PM, greg holly <mak.hho...@gmail.com> wrote:

> Hi Bert;
>
> I do appreciate for this. I need check your codes on task2 tomorrow at my
> office on the real data as I have difficulty (because a technical issue) to
> remote connection. I am sure it will work well.
>
> I am sorry that I was not able to explain my first question. Basically
>
> Values in ref data represent the region of chromosome. I need choose these
> regions in map (all regions values in ref data are exist in map data in the
> first column -column map$reg). And then summing up the column "map$rate and
> count the numbers that gives >0.85. For example, consider  the first row in
> data ref. They are 29220   and  63933. After sorting the first column in
> map then summing column "map$rate" only between 29220   to  63933 in
> sorted map and cut off at >0.85. Then count how many rows in sorted map
> gives >0.85. For example consider there are 38 rows between 29220   in
>  63933 in sorted map$reg and only summing first 12 of them  gives>0.85.
> Then my answer is going to be 12 for 29220   -  63933 in ref.
>
> Thanks I lot for your patience.
>
> Cheers,
> Greg
>
> On Sun, Jun 12, 2016 at 6:36 PM, Bert Gunter <bgunter.4...@gmail.com>
> wrote:
>
>> Greg:
>>
>> I was not able to understand your task 1. Perhaps others can.
>>
>> My understanding of your task 2 is that for each row of ref, you wish
>> to find all rows,of map such that the reg values in those rows fall
>> between the reg1 and reg2 values in ref (inclusive change <= to < if
>> you don't want the endpoints), and then you want the minimum map$p
>> values of all those rows. If that is correct, I believe this will do
>> it (but caution, untested, as you failed to provide data in a
>> convenient form, e.g. using dput() )
>>
>> task2 <- with(map,vapply(seq_len(nrow(ref)),function(i)
>> min(p[ref[i,1]<=reg & reg <= ref[i,2] ]),0))
>>
>>
>> If my understanding is incorrect, please ignore both the above and the
>> following:
>>
>>
>> The "solution" I have given above seems inefficient, so others may be
>> able to significantly improve it if you find that it takes too long.
>> OTOH, my understanding of your specification is that you need to
>> search for all rows in map data frame that meet the criterion for each
>> row of ref, and without further information, I don't know how to do
>> this without just repeating the search 560 times.
>>
>>
>> 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 Sun, Jun 12, 2016 at 1:14 PM, greg holly <mak.hho...@gmail.com> wrote:
>> > Dear all;
>> >
>> >
>> >
>> > I have two data sets, data=map and data=ref). A small part of each data
>> set
>> > are given below. Data map has more than 27 million and data ref has
>> about
>> > 560 rows. Basically I need run two different task. My R codes for these
>> > task are given below but they do not work properly.
>> >
>> > I sincerely do appreciate your helps.
>> >
>> >
>> > Regards,
>> >
>> > Greg
>> >
>> >
>> >
>> > Task 1)
>> >
>> > For example, the first and second columns for row 1 in data ref are
>> 29220
>> > 63933. So I 

Re: [R] two difficult loop

2016-06-12 Thread greg holly
Hi Jim;

Thanks so much for this info. I did not know this as I am very much new in
R, So do you think that, rather than using unique !duplicated would be
better to use?

Thanks in advance,

Greg

On Sun, Jun 12, 2016 at 7:06 PM, Jim Lemon <drjimle...@gmail.com> wrote:

> Hi Greg,
> You've got a problem that you don't seem to have identified. Your
> "reg" field in the "map" data frame can define at most 10 unique
> values. This means that each value will be repeated about 270 times.
> Unless there are constraints you haven't mentioned, we would expect
> that in 135 cases for each value, the values in each "ref" row will be
> in the reverse order and the spans may overlap. I notice that you may
> have tried to get around this by sorting the "map" data frame, but
> then the order of the rows is different, and the number of rows
> "between" any two values changes. Apart from this, it is almost
> certain that the number of values of "p > 0.85" in the multiple runs
> between each set of "ref" values will be different. It is possible to
> perform both tasks that you mention, but only the second will yield an
> unique or tied value for all of the cases. So your result data frame
> will have an unspecified number of values for each row in "ref" for
> the first task.
>
> Jim
>
>
> On Mon, Jun 13, 2016 at 6:14 AM, greg holly <mak.hho...@gmail.com> wrote:
> > Dear all;
> >
> >
> >
> > I have two data sets, data=map and data=ref). A small part of each data
> set
> > are given below. Data map has more than 27 million and data ref has about
> > 560 rows. Basically I need run two different task. My R codes for these
> > task are given below but they do not work properly.
> >
> > I sincerely do appreciate your helps.
> >
> >
> > Regards,
> >
> > Greg
> >
> >
> >
> > Task 1)
> >
> > For example, the first and second columns for row 1 in data ref are 29220
> > 63933. So I need write an R code normally first look the first row in ref
> > (which they are 29220 and 63933) than summing the column of "map$rate"
> and
> > give the number of rows that >0.85. Then do the same for the second,
> > thirdin ref. At the end I would like a table gave below (the results
> I
> > need). Please notice the all value specified in ref data file are exist
> in
> > map$reg column.
> >
> >
> >
> > Task2)
> >
> > Again example, the first and second columns for row 1 in data ref are
> 29220
> > 63933. So I need write an R code give the minimum map$p for the 29220
> > -63933 intervals in map file. Than
> >
> > do the same for the second, thirdin ref.
> >
> >
> >
> >
> > #my attempt for the first question
> >
> > temp<-map[order(map$reg, map$p),]
> >
> > count<-1
> >
> > temp<-unique(temp$reg
> >
> > for(i in 1:length(ref) {
> >
> >   for(j in 1:length(ref)
> >
> >   {
> >
> > temp1<-if (temp[pos[i]==ref[ref$reg1,] & (temp[pos[j]==ref[ref$reg2,]
> > & temp[cumsum(temp$rate)
> >>0.70,])
> >
> > count=count+1
> >
> > }
> >
> > }
> >
> > #my attempt for the second question
> >
> >
> >
> > temp<-map[order(map$reg, map$p),]
> >
> > count<-1
> >
> > temp<-unique(temp$reg
> >
> > for(i in 1:length(ref) {
> >
> >   for(j in 1:length(ref)
> >
> >   {
> >
> > temp2<-if (temp[pos[i]==ref[ref$reg1,] & (temp[pos[j]==ref[ref$reg2,])
> >
> > output<-temp2[temp2$p==min(temp2$p),]
> >
> > }
> >
> > }
> >
> >
> >
> > Data sets
> >
> >
> >   Data= map
> >
> >   reg   p  rate
> >
> >  10276 0.700  3.867e-18
> >
> >  71608 0.830  4.542e-16
> >
> >  29220 0.430  1.948e-15
> >
> >  99542 0.220  1.084e-15
> >
> >  26441 0.880  9.675e-14
> >
> >  95082 0.090  7.349e-13
> >
> >  36169 0.480  9.715e-13
> >
> >  55572 0.500  9.071e-12
> >
> >  65255 0.300  1.688e-11
> >
> >  51960 0.970  1.163e-10
> >
> >  55652 0.388  3.750e-10
> >
> >  63933 0.250  9.128e-10
> >
> >  35170 0.720  7.355e-09
> >
> >  06491 0.370  1.634e-08
> >
> >  85508 0.470  1.057e-07
> >
> >  8 0.580  7.862e-07
> >
> >  04758 0.810  9.501e-07
> >
&

[R] two difficult loop

2016-06-12 Thread greg holly
Dear all;



I have two data sets, data=map and data=ref). A small part of each data set
are given below. Data map has more than 27 million and data ref has about
560 rows. Basically I need run two different task. My R codes for these
task are given below but they do not work properly.

I sincerely do appreciate your helps.


Regards,

Greg



Task 1)

For example, the first and second columns for row 1 in data ref are 29220
63933. So I need write an R code normally first look the first row in ref
(which they are 29220 and 63933) than summing the column of "map$rate" and
give the number of rows that >0.85. Then do the same for the second,
thirdin ref. At the end I would like a table gave below (the results I
need). Please notice the all value specified in ref data file are exist in
map$reg column.



Task2)

Again example, the first and second columns for row 1 in data ref are 29220
63933. So I need write an R code give the minimum map$p for the 29220
-63933 intervals in map file. Than

do the same for the second, thirdin ref.




#my attempt for the first question

temp<-map[order(map$reg, map$p),]

count<-1

temp<-unique(temp$reg

for(i in 1:length(ref) {

  for(j in 1:length(ref)

  {

temp1<-if (temp[pos[i]==ref[ref$reg1,] & (temp[pos[j]==ref[ref$reg2,]
& temp[cumsum(temp$rate)
>0.70,])

count=count+1

}

}

#my attempt for the second question



temp<-map[order(map$reg, map$p),]

count<-1

temp<-unique(temp$reg

for(i in 1:length(ref) {

  for(j in 1:length(ref)

  {

temp2<-if (temp[pos[i]==ref[ref$reg1,] & (temp[pos[j]==ref[ref$reg2,])

output<-temp2[temp2$p==min(temp2$p),]

}

}



Data sets


  Data= map

  reg   p  rate

 10276 0.700  3.867e-18

 71608 0.830  4.542e-16

 29220 0.430  1.948e-15

 99542 0.220  1.084e-15

 26441 0.880  9.675e-14

 95082 0.090  7.349e-13

 36169 0.480  9.715e-13

 55572 0.500  9.071e-12

 65255 0.300  1.688e-11

 51960 0.970  1.163e-10

 55652 0.388  3.750e-10

 63933 0.250  9.128e-10

 35170 0.720  7.355e-09

 06491 0.370  1.634e-08

 85508 0.470  1.057e-07

 8 0.580  7.862e-07

 04758 0.810  9.501e-07

 06169 0.440  1.104e-06

 63933 0.750  2.624e-06

 41838 0.960  8.119e-06


 data=ref

  reg1 reg2

  29220 63933

  26441 41838

  06169 10276

  74806 92643

  73732 82451

  86042 93502

  85508 95082



   the results I need

 reg1  reg2 n

   29220   63933  12

   26441   41838   78

   06169 10276  125

   74806 92643   11

   73732 82451   47

   86042 93502   98

   85508 95082  219

[[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] two difficult loop

2016-06-13 Thread greg holly
Hi Jim;

I do apologize if bothering. I have run on the real data and here is the
error message I got:

Thanks,

Greg

start  end
Error in regrange[1]:regrange[2] : result would be too long a vector
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

On Mon, Jun 13, 2016 at 10:28 AM, greg holly <mak.hho...@gmail.com> wrote:

> Hi Jim;
>
> I do apologize if bothering. I have run on the real data and here is the
> error message I got:
>
> Thanks,
>
> Greg
>
> start  end
> Error in regrange[1]:regrange[2] : result would be too long a vector
> In addition: Warning messages:
> 1: In min(x) : no non-missing arguments to min; returning Inf
> 2: In max(x) : no non-missing arguments to max; returning -Inf
>
>
> On Mon, Jun 13, 2016 at 3:19 AM, Jim Lemon <drjimle...@gmail.com> wrote:
>
>> Hi Greg,
>> Okay, I have a better idea now of what you want. The problem of
>> multiple matches is still there, but here is a start:
>>
>> # this data frame actually contains all the values in ref in the "reg"
>> field
>> map<-read.table(text="reg p rate
>>  10276 0.700  3.867e-18
>>  71608 0.830  4.542e-16
>>  29220 0.430  1.948e-15
>>  99542 0.220  1.084e-15
>>  26441 0.880  9.675e-14
>>  95082 0.090  7.349e-13
>>  36169 0.480  9.715e-13
>>  55572 0.500  9.071e-12
>>  65255 0.300  1.688e-11
>>  51960 0.970  1.163e-10
>>  55652 0.388  3.750e-10
>>  63933 0.250  9.128e-10
>>  35170 0.720  7.355e-09
>>  06491 0.370  1.634e-08
>>  85508 0.470  1.057e-07
>>  8 0.580  7.862e-07
>>  04758 0.810  9.501e-07
>>  06169 0.440  1.104e-06
>>  63933 0.750  2.624e-06
>>  41838 0.960  8.119e-06
>>  74806 0.810  9.501e-07
>>  92643 0.470  1.057e-07
>>  73732 0.090  7.349e-13
>>  82451 0.960  8.119e-06
>>  86042 0.480  9.715e-13
>>  93502 0.500  9.071e-12
>>  85508 0.370  1.634e-08
>>  95082 0.830  4.542e-16",
>>  header=TRUE)
>> # same as in your example
>> ref<-read.table(text="reg1 reg2
>>  29220 63933
>>  26441 41838
>>  06169 10276
>>  74806 92643
>>  73732 82451
>>  86042 93502
>>  85508 95082",
>>  header=TRUE)
>> # sort the "map" data frame
>> map2<-map[order(map$reg),]
>> # get a field for the counts
>> ref$n<-NA
>> # and a field for the minimum p values
>> ref$min_p<-NA
>> # get the number of rows in "ref"
>> nref<-dim(ref)[1]
>> for(i in 1:nref) {
>>  start<-which(map2$reg==ref$reg1[i])
>>  end<-which(map2$reg==ref$reg2[i])
>>  cat("start",start,"end",end,"\n")
>>  # get the range of matches
>>  regrange<-range(c(start,end))
>>  # convert this to a sequence spanning all matches
>>  allreg<-regrange[1]:regrange[2]
>>  ref$n[i]<-sum(map2$p[allreg] > 0.85)
>>  ref$min_p[i]<-min(map2$p[allreg])
>> }
>>
>> This example uses the span from the first match of "reg1" to the last
>> match of "reg2". This may not be what you want, so let me know if
>> there are further constraints.
>>
>> Jim
>>
>> On Mon, Jun 13, 2016 at 12:35 PM, greg holly <mak.hho...@gmail.com>
>> wrote:
>> > Hi Bert;
>> >
>> > I do appreciate for this. I need check your codes on task2 tomorrow at
>> my
>> > office on the real data as I have difficulty (because a technical
>> issue) to
>> > remote connection. I am sure it will work well.
>> >
>> > I am sorry that I was not able to explain my first question. Basically
>> >
>> > Values in ref data represent the region of chromosome. I need choose
>> these
>> > regions in map (all regions values in ref data are exist in map data in
>> the
>> > first column -column map$reg). And then summing up the column "map$rate
>> and
>> > count the numbers that gives >0.85. For example, consider  the first
>> row in
>> > data ref. They are 29220   and  63933. After sorting the first column in
>> > map then summing column "map$rate" only between 29220   to  63933 in
>> sorted
>> > map and cut off at >0.85. Then count how many rows in sorted map gives
>> >>0.85. For example consider there are 38 rows between 29220   in  63933
>> in sorted
>> > map$reg and only summing first 12 of them  gives>0.85. Then my answer is
>> > going to be 12 f

Re: [R] two difficult loop

2016-06-14 Thread greg holly
Thanks a lot Jim. I am struggling to solve the problem.I do appreciate for
your helps and advice.

Greg

On Tue, Jun 14, 2016 at 3:39 AM, Jim Lemon <drjimle...@gmail.com> wrote:

> Hi Greg,
> This is obviously a problem with the data. The first error indicates
> that the sequence of integers regrange[1]:regrange[2] is too long to
> be allocated. Most likely this is because one or both of the endpoints
> are infinite. Maybe if you can find where the NAs are you can fix it.
>
> Jim
>
> On Tue, Jun 14, 2016 at 12:29 AM, greg holly <mak.hho...@gmail.com> wrote:
> > Hi Jim;
> >
> > I do apologize if bothering. I have run on the real data and here is the
> > error message I got:
> >
> > Thanks,
> >
> > Greg
> >
> > start  end
> > Error in regrange[1]:regrange[2] : result would be too long a vector
> > In addition: Warning messages:
> > 1: In min(x) : no non-missing arguments to min; returning Inf
> > 2: In max(x) : no non-missing arguments to max; returning -Inf
> >
> > On Mon, Jun 13, 2016 at 10:28 AM, greg holly <mak.hho...@gmail.com>
> wrote:
> >>
> >> Hi Jim;
> >>
> >> I do apologize if bothering. I have run on the real data and here is the
> >> error message I got:
> >>
> >> Thanks,
> >>
> >> Greg
> >>
> >> start  end
> >> Error in regrange[1]:regrange[2] : result would be too long a vector
> >> In addition: Warning messages:
> >> 1: In min(x) : no non-missing arguments to min; returning Inf
> >> 2: In max(x) : no non-missing arguments to max; returning -Inf
> >>
> >>
> >> On Mon, Jun 13, 2016 at 3:19 AM, Jim Lemon <drjimle...@gmail.com>
> wrote:
> >>>
> >>> Hi Greg,
> >>> Okay, I have a better idea now of what you want. The problem of
> >>> multiple matches is still there, but here is a start:
> >>>
> >>> # this data frame actually contains all the values in ref in the "reg"
> >>> field
> >>> map<-read.table(text="reg p rate
> >>>  10276 0.700  3.867e-18
> >>>  71608 0.830  4.542e-16
> >>>  29220 0.430  1.948e-15
> >>>  99542 0.220  1.084e-15
> >>>  26441 0.880  9.675e-14
> >>>  95082 0.090  7.349e-13
> >>>  36169 0.480  9.715e-13
> >>>  55572 0.500  9.071e-12
> >>>  65255 0.300  1.688e-11
> >>>  51960 0.970  1.163e-10
> >>>  55652 0.388  3.750e-10
> >>>  63933 0.250  9.128e-10
> >>>  35170 0.720  7.355e-09
> >>>  06491 0.370  1.634e-08
> >>>  85508 0.470  1.057e-07
> >>>  8 0.580  7.862e-07
> >>>  04758 0.810  9.501e-07
> >>>  06169 0.440  1.104e-06
> >>>  63933 0.750  2.624e-06
> >>>  41838 0.960  8.119e-06
> >>>  74806 0.810  9.501e-07
> >>>  92643 0.470  1.057e-07
> >>>  73732 0.090  7.349e-13
> >>>  82451 0.960  8.119e-06
> >>>  86042 0.480  9.715e-13
> >>>  93502 0.500  9.071e-12
> >>>  85508 0.370  1.634e-08
> >>>  95082 0.830  4.542e-16",
> >>>  header=TRUE)
> >>> # same as in your example
> >>> ref<-read.table(text="reg1 reg2
> >>>  29220 63933
> >>>  26441 41838
> >>>  06169 10276
> >>>  74806 92643
> >>>  73732 82451
> >>>  86042 93502
> >>>  85508 95082",
> >>>  header=TRUE)
> >>> # sort the "map" data frame
> >>> map2<-map[order(map$reg),]
> >>> # get a field for the counts
> >>> ref$n<-NA
> >>> # and a field for the minimum p values
> >>> ref$min_p<-NA
> >>> # get the number of rows in "ref"
> >>> nref<-dim(ref)[1]
> >>> for(i in 1:nref) {
> >>>  start<-which(map2$reg==ref$reg1[i])
> >>>  end<-which(map2$reg==ref$reg2[i])
> >>>  cat("start",start,"end",end,"\n")
> >>>  # get the range of matches
> >>>  regrange<-range(c(start,end))
> >>>  # convert this to a sequence spanning all matches
> >>>  allreg<-regrange[1]:regrange[2]
> >>>  ref$n[i]<-sum(map2$p[allreg] > 0.85)
> >>>  ref$min_p[i]<-min(map2$p[allreg])
> >>> }
> >>>
> >>> This example uses the span from the first match of "reg1" to the last
> >>> m

[R] help for fine mappting

2016-06-15 Thread greg holly
dear all;


I am sorry for this posting. I have got help from Jim, Bert, Jeff and PIKAL
on similar issue before. I tried to modify Jim`s code to the real data but
it did not work. Now I am posting first two rows the imitation of real data
using dput() format (please see at the bottom).  I have two data sets,
data=map and data=ref. The first to rows of each data set are given below.
Data map has more than 27 million and data ref has about 560 rows.
Basically I need run two different tasks. My R codes for these task are
given below but they do not work properly. I sincerely do appreciate your
helps.



Regards,

Greg



Task 1)

For example, the first and second columns for row 1 in data ref are chr1,
6457839 and 6638389. So I need write an R code normally first look the
first row in ref (which they are chre1 6457839  and 6638389) than summing
the column of "map$post_prob" and give the number of map$snp falls between
6457839  and 6638389 that  their cumulative sum is >0.85. Then do the same
for the second, thirdin ref. At the end I would like a table gave below
(need_ouput). Please notice the all value specified info in ref data file
are exist in map$CHR and map$POS columns.



Task2)

Again example, the first and second columns for row 1 in data ref are chr1,
6457839 and 6638389. So I need that R gives me the minimum map$p for the 2
chr1, 6457839 and 6638389 (as there are many snps between these regions and
would like choose the smallest one in those regions. Than do the same for
the second, thirdrows in ref.



Then put the results of Task1 and Task2 into need_ouput file




#R codes modified from Jim


map2<-map[order(map$CHR, map$POS, -map$post_prob),]



# get a field for the counts

 ref$n<-NA



# and a field for the minimum p values

 ref$min_p<-NA



# get the number of rows in "ref"

 nref<-dim(ref)[1]

 for(i in 1:nref) {

  CHR<- which(map2$CHR==ref$CHR[i])

  POS_start<-which(map2$POS==ref$POS_start[i])

  POS_end<-which(map2$POS==ref$POS_end[i])

  cat("CHR", "CHR"," POS_start",POS_start,"POS_end",POS_end,"\n")



# get the range of matches

  POSrange<-range(c(CHR,POS_start,POS_end))



# convert this to a sequence spanning all matches

  allPOS<-POSrange[1]:POSrange[2]

  ref$n[i]<-sum(map2$post_prob[allPOS] > 0.99)

  ref$min_p[i]<-min(map2$p[allPOS])

 }





  dput(map)

  structure(list(CHR = structure(c(1L, 1L), .Label = "chr1", class =
"factor"),

  snp = structure(1:2, .Label = c("rs4747841", "rs4749917"), class
= "factor"),

  Allel1 = structure(1:2, .Label = c("A", "T"), class = "factor"),

  Allel2 = structure(c(2L, 1L), .Label = c("C", "G"), class =
"factor"),

  fr = c(0.551, 0.436), effec = c(-0.0011, 0.0011), SE = c(0.0029,

  0.0029), p = c(0.7, 0.7), POS = c(9960129L, 9960259L), post_prob
= c(1.248817e-158,

  1.248817e-158)), .Names = c("CHR", "snp", "Allel1", "Allel2",

  "fr", "effec", "SE", "p", "POS", "post_prob"), class = "data.frame",
row.names = c(NA,

  -2L))





 dput(ref)

 structure(list(CHR = structure(1:2, .Label = c("chr10", "chr14"

 ), class = "factor"), POS_start = c(6457839L, 21005246L), POS_end =
c(6638389L,

 21550658L)), .Names = c("CHR", "POS_start", "POS_end"), class =
"data.frame", row.names = c(NA,

-2L))





dput(need_output)

structure(list(CHR = structure(1:2, .Label = c("chr1", "chr22"

), class = "factor"), POS = c(312127953L, 46487552L), POS_start =
c(32036927L,

45766451L), POS_end = c(3232240262, 46801601), snp = structure(1:2, .Label
= c("rs1143427",

"rs55958907"), class = "factor"), alle1l = structure(1:2, .Label = c("G",

"T"), class = "factor"), allel2 = structure(1:2, .Label = c("A",

"G"), class = "factor"), fr = c(0.278, 0.974), effec = c(0.6,

0.106), SE = c(0.015, 0.027), P = c(0.000156, 7.63e-05), post_prob =
c(0.229,

0.125), n = c(612L, 4218L)), .Names = c("CHR", "POS", "POS_start",

"POS_end", "snp", "alle1l", "allel2", "fr", "effec", "SE", "P",

"post_prob", "n"), class = "data.frame", row.names = c(NA, -2L

))

[[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] Fwd: help for fine mappting

2016-06-15 Thread greg holly
Dear all;


Unfortunately I did not get any response for my  following questions. It is
time sensitive job. I would be greatly appreciate if you give help soon.


Regards,

Greg



I am sorry for this posting. I have got help from Jim, Bert, Jeff and PIKAL
on similar issue before. I tried to modify Jim`s code to the real data but
it did not work. Now I am posting first two rows the imitation of real data
using dput() format (please see at the bottom).  I have two data sets,
data=map and data=ref. The first to rows of each data set are given below.
Data map has more than 27 million and data ref has about 560 rows.
Basically I need run two different tasks. My R codes for these task are
given below but they do not work properly. I sincerely do appreciate your
helps.



Regards,

Greg



Task 1)

For example, the first and second columns for row 1 in data ref are chr1,
6457839 and 6638389. So I need write an R code normally first look the
first row in ref (which they are chre1 6457839  and 6638389) than summing
the column of "map$post_prob" and give the number of map$snp falls between
6457839  and 6638389 that  their cumulative sum is >0.85. Then do the same
for the second, thirdin ref. At the end I would like a table gave below
(need_ouput). Please notice the all value specified info in ref data file
are exist in map$CHR and map$POS columns.



Task2)

Again example, the first and second columns for row 1 in data ref are chr1,
6457839 and 6638389. So I need that R gives me the minimum map$p for the 2
chr1, 6457839 and 6638389 (as there are many snps between these regions and
would like choose the smallest one in those regions. Than do the same for
the second, thirdrows in ref.



Then put the results of Task1 and Task2 into need_ouput file




#R codes modified from Jim


map2<-map[order(map$CHR, map$POS, -map$post_prob),]



# get a field for the counts

 ref$n<-NA



# and a field for the minimum p values

 ref$min_p<-NA



# get the number of rows in "ref"

 nref<-dim(ref)[1]

 for(i in 1:nref) {

  CHR<- which(map2$CHR==ref$CHR[i])

  POS_start<-which(map2$POS==ref$POS_start[i])

  POS_end<-which(map2$POS==ref$POS_end[i])

  cat("CHR", "CHR"," POS_start",POS_start,"POS_end",POS_end,"\n")



# get the range of matches

  POSrange<-range(c(CHR,POS_start,POS_end))



# convert this to a sequence spanning all matches

  allPOS<-POSrange[1]:POSrange[2]

  ref$n[i]<-sum(map2$post_prob[allPOS] > 0.99)

  ref$min_p[i]<-min(map2$p[allPOS])

 }





  dput(map)

  structure(list(CHR = structure(c(1L, 1L), .Label = "chr1", class =
"factor"),

  snp = structure(1:2, .Label = c("rs4747841", "rs4749917"), class
= "factor"),

  Allel1 = structure(1:2, .Label = c("A", "T"), class = "factor"),

  Allel2 = structure(c(2L, 1L), .Label = c("C", "G"), class =
"factor"),

  fr = c(0.551, 0.436), effec = c(-0.0011, 0.0011), SE = c(0.0029,

  0.0029), p = c(0.7, 0.7), POS = c(9960129L, 9960259L), post_prob
= c(1.248817e-158,

  1.248817e-158)), .Names = c("CHR", "snp", "Allel1", "Allel2",

  "fr", "effec", "SE", "p", "POS", "post_prob"), class = "data.frame",
row.names = c(NA,

  -2L))





 dput(ref)

 structure(list(CHR = structure(1:2, .Label = c("chr10", "chr14"

 ), class = "factor"), POS_start = c(6457839L, 21005246L), POS_end =
c(6638389L,

 21550658L)), .Names = c("CHR", "POS_start", "POS_end"), class =
"data.frame", row.names = c(NA,

-2L))





dput(need_output)

structure(list(CHR = structure(1:2, .Label = c("chr1", "chr22"

), class = "factor"), POS = c(312127953L, 46487552L), POS_start =
c(32036927L,

45766451L), POS_end = c(3232240262, 46801601), snp = structure(1:2, .Label
= c("rs1143427",

"rs55958907"), class = "factor"), alle1l = structure(1:2, .Label = c("G",

"T"), class = "factor"), allel2 = structure(1:2, .Label = c("A",

"G"), class = "factor"), fr = c(0.278, 0.974), effec = c(0.6,

0.106), SE = c(0.015, 0.027), P = c(0.000156, 7.63e-05), post_prob =
c(0.229,

0.125), n = c(612L, 4218L)), .Names = c("CHR", "POS", "POS_start",

"POS_end", "snp", "alle1l", "allel2", "fr", "effec", "SE", "P",

"post_prob", "n"), class = "data.frame", row.names = c(NA, -2L

))

[[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] looping problem

2017-02-01 Thread greg holly
Hi all;

I have 22 directories named chr1, chr2,,chr22. Each directory has a
file named "Z-score.imputed". I would like to combine  Z-score.imputed
files into one. I wrote the following loop but did not get any results.
Your helps are highly appreciated.

regards,

Greg

temp<-c()

for(i in 1:22) {
infile<-paste("chr",i,"/Z-score.imputed",sep="")
psT<-read.table(as.character(infile),header=T,as.is=T,sep="\t")
ps<-psT[psT$Var>0.6,]
ratio=nrow(ps)/nrow(psT)
print(ratio)
}

[[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] looping problem

2017-02-02 Thread greg holly
Hi Rui;

Is there any way to insert the chr ids in numeric as 1,2..,22 in the
final output. Here is output from str(temp). So I need also chr ids in a
column.
1  rs58108140 10583 G A -0.070438 0.059903
2 rs189107123 10611 C G -0.044916 0.085853

Regards,
Greg


On Wed, Feb 1, 2017 at 1:32 PM, Rui Barradas <ruipbarra...@sapo.pt> wrote:

> Hello,
>
> If what you want is to combine the files into one data.frame then there
> are 2 things you should see:
>
> 1) You create a variable named 'temp' and don't ever use it.
> 2) You never combine the data.frames you read in.
>
> Try instead the following.
>
> temp <- data.frame()
> for(i in 1:22) {
> infile<-paste("chr",i,"/Z-score.imputed",sep="")
> psT<-read.table(infile,header=T,as.is=T,sep="\t")
> temp <- rbind(temp, psT)
> }
>
> str(temp)  # to see what you have
>
> Hope this helps,
>
> Rui Barradas
>
>
>
>
> Em 01-02-2017 17:25, greg holly escreveu:
>
>> Hi all;
>>
>> I have 22 directories named chr1, chr2,,chr22. Each directory has a
>> file named "Z-score.imputed". I would like to combine  Z-score.imputed
>> files into one. I wrote the following loop but did not get any results.
>> Your helps are highly appreciated.
>>
>> regards,
>>
>> Greg
>>
>> temp<-c()
>>
>> for(i in 1:22) {
>> infile<-paste("chr",i,"/Z-score.imputed",sep="")
>> psT<-read.table(as.character(infile),header=T,as.is=T,sep="\t")
>> ps<-psT[psT$Var>0.6,]
>> ratio=nrow(ps)/nrow(psT)
>> print(ratio)
>> }
>>
>> [[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/posti
>> ng-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] looping problem

2017-02-02 Thread greg holly
Thanks so much for this. Unfortunately, cbind did not work. Basically, I
like to put an extra column named "chr" in the combined file from 22 chr.
So chr colum will be "1" for the portion of chr1 in the combined file, 2
for the portion of chr2 in the combined file and so on.

Regards,

Greg

On Thu, Feb 2, 2017 at 9:39 AM, Rui Barradas <ruipbarra...@sapo.pt> wrote:

> Hello,
>
> If I understand correctly, just use ?cbind.
>
> Rui Barradas
>
> Em 02-02-2017 13:33, greg holly escreveu:
>
>> Hi Rui;
>>
>> Is there any way to insert the chr ids in numeric as 1,2..,22 in the
>> final output. Here is output from str(temp). So I need also chr ids in a
>> column.
>> 1  rs58108140 10583 G A -0.070438 0.059903
>> 2 rs189107123 10611 C G -0.044916 0.085853
>>
>> Regards,
>> Greg
>>
>>
>> On Wed, Feb 1, 2017 at 1:32 PM, Rui Barradas <ruipbarra...@sapo.pt
>> <mailto:ruipbarra...@sapo.pt>> wrote:
>>
>> Hello,
>>
>> If what you want is to combine the files into one data.frame then
>> there are 2 things you should see:
>>
>> 1) You create a variable named 'temp' and don't ever use it.
>> 2) You never combine the data.frames you read in.
>>
>> Try instead the following.
>>
>> temp <- data.frame()
>> for(i in 1:22) {
>>  infile<-paste("chr",i,"/Z-score.imputed",sep="")
>>  psT<-read.table(infile,header=T,as.is <http://as.is>=T,sep="\t")
>>  temp <- rbind(temp, psT)
>> }
>>
>> str(temp)  # to see what you have
>>
>> Hope this helps,
>>
>> Rui Barradas
>>
>>
>>
>>
>> Em 01-02-2017 17:25, greg holly escreveu:
>>
>> Hi all;
>>
>> I have 22 directories named chr1, chr2,,chr22. Each
>> directory has a
>> file named "Z-score.imputed". I would like to combine
>> Z-score.imputed
>> files into one. I wrote the following loop but did not get any
>> results.
>> Your helps are highly appreciated.
>>
>> regards,
>>
>> Greg
>>
>> temp<-c()
>>
>> for(i in 1:22) {
>> infile<-paste("chr",i,"/Z-score.imputed",sep="")
>> psT<-read.table(as.character(infile),header=T,as.is
>> <http://as.is>=T,sep="\t")
>> ps<-psT[psT$Var>0.6,]
>> ratio=nrow(ps)/nrow(psT)
>> print(ratio)
>> }
>>
>>  [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org <mailto:R-help@r-project.org> mailing list
>> -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> <https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> <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] looping problem

2017-02-02 Thread greg holly
Thanks so much Peter. I do appreciate for this.

Greg

On Thu, Feb 2, 2017 at 10:28 AM, PIKAL Petr <petr.pi...@precheza.cz> wrote:

> Hi.
>
> Your messages are rather confusing. Well, if you could get correct final
> data.frame in loop why not just add inside of loop new column(s) by
>
> psT$chr <- i
>
> Maybe it is time to read R intro as good source for starting with R. It
> has about 100 pages, but you can pick as start only pages 2-40 which are
> basic for data input and manipulation.
>
> Cheers
> Petr
>
>
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of greg
> holly
> > Sent: Thursday, February 2, 2017 4:13 PM
> > To: Rui Barradas <ruipbarra...@sapo.pt>
> > Cc: r-help mailing list <r-help@r-project.org>
> > Subject: Re: [R] looping problem
> >
> > Thanks so much for this. Unfortunately, cbind did not work. Basically, I
> like to
> > put an extra column named "chr" in the combined file from 22 chr.
> > So chr colum will be "1" for the portion of chr1 in the combined file, 2
> for the
> > portion of chr2 in the combined file and so on.
> >
> > Regards,
> >
> > Greg
> >
> > On Thu, Feb 2, 2017 at 9:39 AM, Rui Barradas <ruipbarra...@sapo.pt>
> wrote:
> >
> > > Hello,
> > >
> > > If I understand correctly, just use ?cbind.
> > >
> > > Rui Barradas
> > >
> > > Em 02-02-2017 13:33, greg holly escreveu:
> > >
> > >> Hi Rui;
> > >>
> > >> Is there any way to insert the chr ids in numeric as 1,2..,22 in
> > >> the final output. Here is output from str(temp). So I need also chr
> > >> ids in a column.
> > >> 1  rs58108140 10583 G A -0.070438 0.059903
> > >> 2 rs189107123 10611 C G -0.044916 0.085853
> > >>
> > >> Regards,
> > >> Greg
> > >>
> > >>
> > >> On Wed, Feb 1, 2017 at 1:32 PM, Rui Barradas <ruipbarra...@sapo.pt
> > >> <mailto:ruipbarra...@sapo.pt>> wrote:
> > >>
> > >> Hello,
> > >>
> > >> If what you want is to combine the files into one data.frame then
> > >> there are 2 things you should see:
> > >>
> > >> 1) You create a variable named 'temp' and don't ever use it.
> > >> 2) You never combine the data.frames you read in.
> > >>
> > >> Try instead the following.
> > >>
> > >> temp <- data.frame()
> > >> for(i in 1:22) {
> > >>  infile<-paste("chr",i,"/Z-score.imputed",sep="")
> > >>  psT<-read.table(infile,header=T,as.is <http://as.is
> >=T,sep="\t")
> > >>  temp <- rbind(temp, psT)
> > >> }
> > >>
> > >> str(temp)  # to see what you have
> > >>
> > >> Hope this helps,
> > >>
> > >> Rui Barradas
> > >>
> > >>
> > >>
> > >>
> > >> Em 01-02-2017 17:25, greg holly escreveu:
> > >>
> > >> Hi all;
> > >>
> > >> I have 22 directories named chr1, chr2,,chr22. Each
> > >> directory has a
> > >> file named "Z-score.imputed". I would like to combine
> > >> Z-score.imputed
> > >> files into one. I wrote the following loop but did not get any
> > >> results.
> > >> Your helps are highly appreciated.
> > >>
> > >> regards,
> > >>
> > >> Greg
> > >>
> > >> temp<-c()
> > >>
> > >> for(i in 1:22) {
> > >> infile<-paste("chr",i,"/Z-score.imputed",sep="")
> > >> psT<-read.table(as.character(infile),header=T,as.is
> > >> <http://as.is>=T,sep="\t")
> > >> ps<-psT[psT$Var>0.6,]
> > >> ratio=nrow(ps)/nrow(psT)
> > >> print(ratio)
> > >> }
> > >>
> > >>  [[alternative HTML version deleted]]
> > >>
> > >> __
> > >> R-help@r-project.org <mailto:R-help@r-project.org> mailing
&g

Re: [R] looping problem

2017-02-01 Thread greg holly
Hi Rui;

I do appreciate for this. Thanks so much. I will try ASAP.

Regards,

Greg

On Wed, Feb 1, 2017 at 1:32 PM, Rui Barradas <ruipbarra...@sapo.pt> wrote:

> Hello,
>
> If what you want is to combine the files into one data.frame then there
> are 2 things you should see:
>
> 1) You create a variable named 'temp' and don't ever use it.
> 2) You never combine the data.frames you read in.
>
> Try instead the following.
>
> temp <- data.frame()
> for(i in 1:22) {
> infile<-paste("chr",i,"/Z-score.imputed",sep="")
> psT<-read.table(infile,header=T,as.is=T,sep="\t")
> temp <- rbind(temp, psT)
> }
>
> str(temp)  # to see what you have
>
> Hope this helps,
>
> Rui Barradas
>
>
>
>
> Em 01-02-2017 17:25, greg holly escreveu:
>
>> Hi all;
>>
>> I have 22 directories named chr1, chr2,,chr22. Each directory has a
>> file named "Z-score.imputed". I would like to combine  Z-score.imputed
>> files into one. I wrote the following loop but did not get any results.
>> Your helps are highly appreciated.
>>
>> regards,
>>
>> Greg
>>
>> temp<-c()
>>
>> for(i in 1:22) {
>> infile<-paste("chr",i,"/Z-score.imputed",sep="")
>> psT<-read.table(as.character(infile),header=T,as.is=T,sep="\t")
>> ps<-psT[psT$Var>0.6,]
>> ratio=nrow(ps)/nrow(psT)
>> print(ratio)
>> }
>>
>> [[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/posti
>> ng-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] lines those not started with "rs"

2017-01-30 Thread greg holly
Hi all;

I have a file which has about 3.000.000 lines. Most of the lines at first
column start with "rs", for example, rs1056, rs1076 and so on. I
would like to get the lines which do not start with "rs" . Your helps
highly appreciated.

Regards,

Greg

[[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] lines those not started with "rs"

2017-01-30 Thread greg holly
Hi Robert;

I do appreciate your advice. Only the first column of the data is text. The
rest columns are numeric.

Regards,

Greg

On Mon, Jan 30, 2017 at 9:36 AM, Robert Sherry <rsher...@comcast.net> wrote:

> Greg,
>
> I am assuming that your data is in a text file. R is a good tool but not
> the tool I would use for this job. The tool I would
> use is grep. The following command should get you want you want:
>  grep -v "^rs" 
>
> Bob
>
>
> On 1/30/2017 9:23 AM, greg holly wrote:
>
>> Hi all;
>>
>> I have a file which has about 3.000.000 lines. Most of the lines at first
>> column start with "rs", for example, rs1056, rs1076 and so on. I
>> would like to get the lines which do not start with "rs" . Your helps
>> highly appreciated.
>>
>> Regards,
>>
>> Greg
>>
>> [[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/posti
>> ng-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/posti
> ng-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] ggplot

2016-11-09 Thread greg holly
Dear all;

I can not get legend position at the top when using the following code. It
does give at the right.


Your help is greatly appreciated.

p3 <- ggplot(a,

 aes(x = SUPER.PATHWAY,  y = SI)) +

#theme_classic()

theme_classic(legend.position="top",  axis.text=element_text(size = 16))

(p4 <- p3 + geom_point(aes(color = SUPER.PATHWAY),

   alpha = 1,

   size = 2.5,

   position = position_jitter(width = 1, height = 0.5)))

[[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 in Summary.factor(c(24L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, :

2016-11-12 Thread greg holly
Dear all;

I am getting the following error message when I run maSigPro package by
using

make.design.matrix commend. I could not figure out why this error happens.
Thanks for your help

Greg

Error in Summary.factor(c(24L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L,  :
  ‘min’ not meaningful for factors

[[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] Error in Summary.factor(c(24L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, :

2016-11-12 Thread greg holly
Hi Duncan;


Thanks for this. I used followed command. In command line: blood is the
name of the data file, degree=11 because I have 12-time point. I need to
create the design matrix of dummies (named des_blood) for fitting time
series micorarray gene expression experiments using maSigPro program.


des_blood=make.design.matrix(blood, degree=11)

On Sat, Nov 12, 2016 at 7:54 PM, Duncan Murdoch <murdoch.dun...@gmail.com>
wrote:

> On 12/11/2016 7:33 PM, greg holly wrote:
>
>> Dear all;
>>
>> I am getting the following error message when I run maSigPro package by
>> using
>>
>> make.design.matrix commend. I could not figure out why this error happens.
>> Thanks for your help
>>
>> Greg
>>
>> Error in Summary.factor(c(24L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L,  :
>>   ‘min’ not meaningful for factors
>>
>>
> You'll need to give a minimal reproducible example (i.e. something others
> can run, but not containing a lot of unnecessary stuff) if you want help
> with this.
>
> Duncan Murdoch
>
>

[[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] CONFUSSING WITH select[!miss] <- 1:sum(!miss)

2016-12-06 Thread greg holly
Dear All;

I am very new in R and try to understand the logic for a program has been
run sucessfully. Here select[!miss] <- 1:sum(!miss) par is confussing me. I
need to understandand the logic behind this commend line.

Thanks in advance for your help,

Greg


miss <- apply(is.na(ph[,c("M1","X1","X2","X3")]),1, any)
select <- integer(nrow(ph))
select[!miss] <- 1:sum(!miss)

[[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] CONFUSSING WITH select[!miss] <- 1:sum(!miss)

2016-12-07 Thread greg holly
Hi Jim, Rui and William;

I do appreciate for your explanations and help. These are very helpful.
Regards,

Hayrettin

On Tue, Dec 6, 2016 at 4:06 PM, Jim Lemon <drjimle...@gmail.com> wrote:

> Hi Greg,
> What is happening is easy to see:
>
>  ph<-matrix(sample(1:100,40),ncol=4)
>  colnames(ph)<-c("M1","X1","X2","X3")
>  ph[sample(1:10,3),1]<-NA
>  ph
>M1 X1 X2 X3
>  [1,]  34 98  3 35
>  [2,]  13 66 74 68
>  [3,]  NA 22 99 79
>  [4,]  94  6 80 36
>  [5,]  18  9 16 65
>  [6,]  NA 29 56 90
>  [7,]  41 23  7 55
>  [8,] 100 93 71 70
>  [9,]  NA 61  8 57
> [10,]  25  4 47 60
> # get a logical vector showing which rows contain NA
>  miss <- apply(is.na(ph[,c("M1","X1","X2","X3")]),1, any)
>  miss
>  [1] FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE
> # create a vector of zeros the length of the number of rows
>  select <- integer(nrow(ph))
>  select
>  [1] 0 0 0 0 0 0 0 0 0 0
> # get the indices for the rows that do _not_ have NAs
>  select[!miss] <- 1:sum(!miss)
>  select
>  [1] 1 2 0 3 4 0 5 6 0 7
>
> If this is to select the rows without NAs, it may be easier to do:
>
> which(!miss)
> [1]  1  2  4  5  7  8 10
>
> Jim
>
>
>
> On Wed, Dec 7, 2016 at 5:18 AM, greg holly <mak.hho...@gmail.com> wrote:
> > Dear All;
> >
> > I am very new in R and try to understand the logic for a program has been
> > run sucessfully. Here select[!miss] <- 1:sum(!miss) par is confussing
> me. I
> > need to understandand the logic behind this commend line.
> >
> > Thanks in advance for your help,
> >
> > Greg
> >
> >
> > miss <- apply(is.na(ph[,c("M1","X1","X2","X3")]),1, any)
> > select <- integer(nrow(ph))
> > select[!miss] <- 1:sum(!miss)
> >
> > [[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] heat maps with qplot

2017-03-10 Thread greg holly
Thanks Ulrik for this, This is my first experience in heat maps. Yours
advise for the theme would be appreciated.

Greg

On Fri, Mar 10, 2017 at 10:08 AM, Ulrik Stervbo <ulrik.ster...@gmail.com>
wrote:

> Hi Greg,
>
> ?theme
>
> You can use the axis.text and axis.title if y and x are to be identical,
> or axis.text.x, axis.text.y, axis.title.x, axis.title.y if you need
> different font size.
>
> HTH
> Ulrik
>
> On Fri, 10 Mar 2017 at 15:47 greg holly <mak.hho...@gmail.com> wrote:
>
>>  Hi all;
>>
>> The followings are my R codes for heat maps in ggplot2. I need to specify
>> the font size for the y-axis (x-axis works) as well as font size for label
>> y and x too. Your help highly appreciated.
>>
>> Thanks,
>>
>> Greg
>>
>> qplot(x=Var1, y=Var2, data=melt(cor(a, use="p")), fill=value,
>> geom="tile") +
>>  scale_fill_gradient2(limits=c(-1, 1))+
>>  ylab('Super pathways') +
>>  xlab('Significant Metabolites in Super pathways for DI') +
>>  theme(axis.text.x = element_text(angle = 90, hjust = 1, size=6))
>>
>> [[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] heat maps with qplot

2017-03-10 Thread greg holly
 Hi all;

The followings are my R codes for heat maps in ggplot2. I need to specify
the font size for the y-axis (x-axis works) as well as font size for label
y and x too. Your help highly appreciated.

Thanks,

Greg

qplot(x=Var1, y=Var2, data=melt(cor(a, use="p")), fill=value, geom="tile") +
 scale_fill_gradient2(limits=c(-1, 1))+
 ylab('Super pathways') +
 xlab('Significant Metabolites in Super pathways for DI') +
 theme(axis.text.x = element_text(angle = 90, hjust = 1, size=6))

[[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] legend and values do not match in ggplot

2017-08-04 Thread greg holly
 I have following codes for ggplots. The legends are given in the plot do
not match with the values specified in the codes given below. Your helps
highly appreciated.

Greg

 library(ggplot2)
 p <- ggplot(a,aes(x=NO_BMI_FI_beta ,y=FI_beta ,color= Super.Pathway))+
 theme_bw() +theme(panel.border=element_blank()) +
 geom_point(size=3)
 p2<-p+scale_color_manual(name="Super.Pathway",
 labels=c("Amino Acid", "Cofactors and Vitamins", "Carbohydrate", "Energy",
"Lipid", "Peptide", "Nucleotide"),
 values=c("Amino Acid"="red",
 "Cofactors and Vitamins"="purple",
  "Carbohydrate"="darkgreen",
  "Energy"="orange",
  "Lipid"="darkblue",
  "Peptide"="darkred",
  "Nucleotide"="blue"))
  p2

[[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] ggplot problem

2017-05-23 Thread greg holly
Hi all;

When I run the following program substantially I have "Warning message:
position_dodge requires non-overlapping x intervals"

How I can overcome this problem.

Regards,

Greg

p <- ggplot() + geom_point(data=a, aes(x=Betas, y=Traits, color=
Super.Pathway), shape=15, size=4)

p <- p + guides(color=guide_legend(title=NULL))

p <- p + theme(legend.key = element_blank())

p <- p  + geom_boxplot(data=a,aes(x=Betas,fill=factor(Super.Pathway),y=Traits))
+ guides(fill=FALSE) +scale_x_continuous(breaks = seq(-50, 60, 5))

p

[[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] point size

2017-06-16 Thread greg holly
Perfect. Thanks so much Adams. It is much appreciated.

Greg

On Fri, Jun 16, 2017 at 12:56 PM, Adams, Jean <jvad...@usgs.gov> wrote:

> You could add size = log10_P to the aes() inside geom_point().
> Untested code below.
> See also http://ggplot2.tidyverse.org/reference/geom_point.html
>
> ggplot(mydata,  aes(x = X,  y = log10_P)) +
>   theme_bw() +
>   theme(panel.border=element_blank(), legend.position="top",
>  axis.text=element_text(size = 8)) +
>   geom_point(aes(color = Traits, size = log10_P))
>
> Jean
>
> On Fri, Jun 16, 2017 at 9:33 AM, greg holly <mak.hho...@gmail.com> wrote:
>
>> Hi all;
>>
>> I am running the following ggplot codes. Runs well. However, I need to
>> reflect the numeric values of the log10_P to the point size in the graph.
>>
>> Your help highly appreciated,
>>
>> Regards,
>> Greg
>>
>>
>> p <- ggplot(mydata,  aes(x = X,  y = log10_P)) +
>>   theme_bw() +theme(panel.border=element_blank())
>>   + theme(legend.position="top",  axis.text=element_text(size = 8))
>>   (p1 <- p + geom_point(aes(color = Traits)
>>
>> [[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/posti
>> ng-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] point size

2017-06-16 Thread greg holly
Hi all;

I am running the following ggplot codes. Runs well. However, I need to
reflect the numeric values of the log10_P to the point size in the graph.

Your help highly appreciated,

Regards,
Greg


p <- ggplot(mydata,  aes(x = X,  y = log10_P)) +
  theme_bw() +theme(panel.border=element_blank())
  + theme(legend.position="top",  axis.text=element_text(size = 8))
  (p1 <- p + geom_point(aes(color = Traits)

[[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] remove quotes from matrix

2017-09-19 Thread greg holly
Hi all;

I have data at 734*22 dimensions with rows and columns names are
non-numeric.When I convert this data into matrix then all values show up
with quotes. Then when I use
x1= noquotes(x) to remove the quotes from the matrix then non-numeric row
names remain all other values in matrix disappear.

Your help is greatly appreciated.

Greg

[[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] remove quotes from matrix

2017-09-19 Thread greg holly
Hi Duncan and Bert;

I do appreciate for your replies. I just figured out that after x1=
noquotes(x) commend my 733*22 matrix returns into n*1 vector. Is there way
to keep this as matrix with the dimension of 733*22?

Regards,

Greg


On Tue, Sep 19, 2017 at 10:04 AM, Duncan Murdoch <murdoch.dun...@gmail.com>
wrote:

> On 19/09/2017 9:47 AM, greg holly wrote:
>
>> Hi all;
>>
>> I have data at 734*22 dimensions with rows and columns names are
>> non-numeric.When I convert this data into matrix then all values show up
>> with quotes. Then when I use
>> x1= noquotes(x) to remove the quotes from the matrix then non-numeric row
>> names remain all other values in matrix disappear.
>>
>> Your help is greatly appreciated.
>>
>>
>
> Matrices in R can have only one type.  If you start with a dataframe and
> any columns contain character data, all entries will be converted to
> character, and the matrix will be displayed with quotes.
>
> When you say all values disappear, it sounds as though you are displaying
> strings containing nothing (or just blanks).  Those will be displayed as ""
> normally, but if the matrix is marked to display without quotes, they are
> displayed as empty strings, so it will appear that nothing is displayed.
>
> You can see the structure of the original data using the str() function,
> e.g. str(x) should display types for each column.
>
> If this isn't enough to explain what's going on, please show us more
> detail.  For example, show us the result of
>
> y <- x[1:5, 1:5]
> dput(y)
>
> both before and after converting x to a matrix.
>
> Duncan Murdoch
>

[[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] remove quotes from matrix

2017-09-19 Thread greg holly
Dear all;

Thanks. Here are the dput results as Duncan suggested.

Regards,

Greg

structure(list(Sub_Pathways = structure(c(3L, 3L, 3L, 3L, 3L), .Label =
c("Acetylated_Peptides",
"Advanced_Glycation_End-product", "Alanine_and_Aspartate", "Aminosugar",
"Ascorbate_and_Aldarate", "Carnitine", "Ceramides", "Creatine",
"Diacylglycerol", "Dipeptide", "Dipeptide_Derivative",
"Disaccharides_and_Oligosaccharides",
"Eicosanoid", "Endocannabinoid", "Fatty_Acid(Acyl_Carnitine)",
"Fatty_Acid(Acyl_Glycine)", "Fatty_Acid,_Amino", "Fatty_Acid,_Branched",
"Fatty_Acid,_Dicarboxylate", "Fatty_Acid,_Dihydroxy",
"Fatty_Acid,_Monohydroxy",
"Fatty_Acid_(Acyl_Choline)", "Fatty_Acid_(Acyl_Glutamine)",
"Fatty_Acid_(also_BCAA)",
"Fatty_Acid_Synthesis", "Fibrinogen_Cleavage_Peptide",
"Fructose,_Mannose_and_Galactose",
"Gamma-glutamyl_Amino_Acid", "Glutamate", "Glutathione", "Glycerolipid",
"Glycine,_Serine_and_Threonine", "Glycogen",
"Glycolysis,_Gluconeogenesis,_and_Pyruvate",
"Guanidino_and_Acetamido", "Hemoglobin_and_Porphyrin", "Histidine",
"Inositol", "Ketone_Bodies", "Leucine,_Isoleucine_and_Valine",
"Long_Chain_Fatty_Acid", "Lysine", "Lyso-phospho-ether", "Lysolipid",
"Lysoplasmalogen", "Medium_Chain_Fatty_Acid",
"Methionine,_Cysteine,_SAM_and_Taurine",
"Mevalonate", "Monoacylglycerol", "Nicotinate_and_Nicotinamide",
"Oxidative_Phosphorylation", "Pantothenate_and_CoA", "Pentose",
"Phenylalanine_and_Tyrosine", "Phospholipid", "Plasmalogen",
"Polyamine", "Polypeptide", "Polyunsaturated_Fatty_Acid_(n3_and_n6)",
"Primary_Bile_Acid", "Purine,_(Hypo)Xanthine/Inosine_containing",
"Purine,_Adenine_containing", "Purine,_Guanine_containing",
"Pyrimidine,_Cytidine_containing",
"Pyrimidine,_Orotate_containing", "Pyrimidine,_Thymine_containing",
"Pyrimidine,_Uracil_containing", "Riboflavin", "Secondary_Bile_Acid",
"Short_Chain_Fatty_Acid", "Sphingolipid", "Steroid", "Sterol",
"TCA_Cycle", "Tocopherol", "Tryptophan",
"Urea_cycle;_Arginine_and_Proline",
"Vitamin_A", "Vitamin_B6"), class = "factor"), BMI_beta = c(0.2382,
-0.313, 0.1238, 0.3035, -0.00982), SAT_beta = c(-0.02409, -1.9751,
0.4095, 0.4861, 0.3293), VAT_beta = c(0.9418, -2.2204, 0.6805,
0.7083, 0.01597), VSR_beta = c(0.2469, -0.2354, 0.05539, 0.01337,
-0.04353)), .Names = c("Sub_Pathways", "BMI_beta", "SAT_beta",
"VAT_beta", "VSR_beta"), row.names = c(NA, 5L), class = "data.frame")

On Tue, Sep 19, 2017 at 10:04 AM, Duncan Murdoch <murdoch.dun...@gmail.com>
wrote:

> On 19/09/2017 9:47 AM, greg holly wrote:
>
>> Hi all;
>>
>> I have data at 734*22 dimensions with rows and columns names are
>> non-numeric.When I convert this data into matrix then all values show up
>> with quotes. Then when I use
>> x1= noquotes(x) to remove the quotes from the matrix then non-numeric row
>> names remain all other values in matrix disappear.
>>
>> Your help is greatly appreciated.
>>
>>
>
> Matrices in R can have only one type.  If you start with a dataframe and
> any columns contain character data, all entries will be converted to
> character, and the matrix will be displayed with quotes.
>
> When you say all values disappear, it sounds as though you are displaying
> strings containing nothing (or just blanks).  Those will be displayed as ""
> normally, but if the matrix is marked to display without quotes, they are
> displayed as empty strings, so it will appear that nothing is displayed.
>
> You can see the structure of the original data using the str() function,
> e.g. str(x) should display types for each column.
>
> If this isn't enough to explain what's going on, please show us more
> detail.  For example, show us the result of
>
> y <- x[1:5, 1:5]
> dput(y)
>
> both before and after converting x to a matrix.
>
> Duncan Murdoch
>

[[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] remove quotes from matrix

2017-09-19 Thread greg holly
Hi Bert;

I sincerely appreciate for this. When I follow your way I have got
dimnames(dm)
[[1]]
NULL

I think this is the reason why the matrix is being converted into  a column
vector.

Regards,

Greg

On Tue, Sep 19, 2017 at 11:32 AM, Bert Gunter <bgunter.4...@gmail.com>
wrote:

> Works fine for me. What do you object to in the following?
>
> Calling the above df "d",
>
> > dm <- as.matrix(d)
> > dm
>   Sub_PathwaysBMI_beta   SAT_beta   VAT_beta
> 1 "Alanine_and_Aspartate" " 0.23820" "-0.02409" " 0.94180"
> 2 "Alanine_and_Aspartate" "-0.31300" "-1.97510" "-2.22040"
> 3 "Alanine_and_Aspartate" " 0.12380" " 0.40950" " 0.68050"
> 4 "Alanine_and_Aspartate" " 0.30350" " 0.48610" " 0.70830"
> 5 "Alanine_and_Aspartate" "-0.00982" " 0.32930" " 0.01597"
>   VSR_beta
> 1 " 0.24690"
> 2 "-0.23540"
> 3 " 0.05539"
> 4 " 0.01337"
> 5 "-0.04353"
> > dimnames(dm)
> [[1]]
> [1] "1" "2" "3" "4" "5"
>
> [[2]]
> [1] "Sub_Pathways" "BMI_beta" "SAT_beta" "VAT_beta"
> [5] "VSR_beta"
>
> > dm <- noquote(dm)
> > dm
>   Sub_Pathways  BMI_beta SAT_beta VAT_beta VSR_beta
> 1 Alanine_and_Aspartate  0.23820 -0.02409  0.94180  0.24690
> 2 Alanine_and_Aspartate -0.31300 -1.97510 -2.22040 -0.23540
> 3 Alanine_and_Aspartate  0.12380  0.40950  0.68050  0.05539
> 4 Alanine_and_Aspartate  0.30350  0.48610  0.70830  0.01337
> 5 Alanine_and_Aspartate -0.00982  0.32930  0.01597 -0.04353
> > dimnames(dm)
> [[1]]
> [1] "1" "2" "3" "4" "5"
>
> [[2]]
> [1] "Sub_Pathways" "BMI_beta" "SAT_beta" "VAT_beta"
> [5] "VSR_beta"
>
>
> Perhaps you need to read ?noquote or ?matrix.
>
> -- Bert
>
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Tue, Sep 19, 2017 at 8:20 AM, greg holly <mak.hho...@gmail.com> wrote:
>
>> Dear all;
>>
>> Thanks. Here are the dput results as Duncan suggested.
>>
>> Regards,
>>
>> Greg
>>
>> structure(list(Sub_Pathways = structure(c(3L, 3L, 3L, 3L, 3L), .Label =
>> c("Acetylated_Peptides",
>> "Advanced_Glycation_End-product", "Alanine_and_Aspartate", "Aminosugar",
>> "Ascorbate_and_Aldarate", "Carnitine", "Ceramides", "Creatine",
>> "Diacylglycerol", "Dipeptide", "Dipeptide_Derivative",
>> "Disaccharides_and_Oligosaccharides",
>> "Eicosanoid", "Endocannabinoid", "Fatty_Acid(Acyl_Carnitine)",
>> "Fatty_Acid(Acyl_Glycine)", "Fatty_Acid,_Amino", "Fatty_Acid,_Branched",
>> "Fatty_Acid,_Dicarboxylate", "Fatty_Acid,_Dihydroxy",
>> "Fatty_Acid,_Monohydroxy",
>> "Fatty_Acid_(Acyl_Choline)", "Fatty_Acid_(Acyl_Glutamine)",
>> "Fatty_Acid_(also_BCAA)",
>> "Fatty_Acid_Synthesis", "Fibrinogen_Cleavage_Peptide",
>> "Fructose,_Mannose_and_Galactose",
>> "Gamma-glutamyl_Amino_Acid", "Glutamate", "Glutathione", "Glycerolipid",
>> "Glycine,_Serine_and_Threonine", "Glycogen",
>> "Glycolysis,_Gluconeogenesis,_and_Pyruvate",
>> "Guanidino_and_Acetamido", "Hemoglobin_and_Porphyrin", "Histidine",
>> "Inositol", "Ketone_Bodies", "Leucine,_Isoleucine_and_Valine",
>> "Long_Chain_Fatty_Acid", "Lysine", "Lyso-phospho-ether", "Lysolipid",
>> "Lysoplasmalogen", "Medium_Chain_Fatty_Acid",
>> "Methionine,_Cysteine,_SAM_and_Taurine",
>> "Mevalonate", "Monoacylglycerol", "Nicotinate_and_Nicotinamide",
>> "Oxidative_Phosphorylation", "Pantothenate_and_CoA", "Pentose",
>> "Phenylalanine_and_Tyrosine", "Phospholipid", "Plasmalogen",
>> "Polyamine", "Polypeptide", "Polyunsaturated_Fatty_Acid_(n3_and_n6)",
>> "

[R] the first name of the first column

2018-05-10 Thread greg holly
Dear all;

I need to run heatmap. Because my first column in my data is alphanumeric,
I can not run as.matrix(scale(my_data)). So I need to make my data readable
as in data(mtcars). In *mtcars *data the first column is alphanumeric and
has no  name.

Thanks,

Greg

[[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] par(mfrow=c(3,4)) problem

2018-05-30 Thread greg holly
Hi all;

I need to put 12 different plot2 into the same matrix. So my array for the
matrix will be par(mfrow=c(3,4)).  I am running ggplot2 to produce my 12
plots. For some reason, par(mfrow=c(3,4)) did not turn out 3*4 matrix.

my basic R codes for each plot is
par(mfrow=c(3,4))
library(ggplot2)
p <- ggplot(a, aes(x=Genotypes, y=Plant_hight, size=Plant_hight,
color=Showing_rate)) +
.
.

Best regards,

Greg

[[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] plotting the regression coefficients

2018-02-08 Thread greg holly
 Hi Petr;

Thanks for your reply. It is much appreciated. A small example is given
below for 4 independent and 4 dependent variables only. The values given
are regression coefficients.I have looked ggplot documents before writing
to you. Unfortunately, I could not figure out as my experience in ggplot is
ignorable

Regards.
Greg

y1 y2 y3 y4
x1 -0.19 0.40 -0.06 0.13
x2 0.45 -0.75 -8.67 -0.46
x3 -0.09 0.14 1.42 0.06
x4 -0.16 -0.01 2.21 0.06


On Thu, Feb 8, 2018 at 10:19 AM, PIKAL Petr <petr.pi...@precheza.cz> wrote:

> Hi
>
> Example, example, example - preferably working.
>
> Wild guess - did you try ggplot?
>
> Cheers
> Petr
>
>
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of greg
> holly
> > Sent: Thursday, February 8, 2018 8:14 AM
> > To: r-help mailing list <r-help@r-project.org>
> > Subject: [R] plotting the regression coefficients
> >
> > Hi Dear all;
> >
> > I would like to create a plot for regression coefficients with each
> independent
> > variable (x) along the side and the phenotypes (y) across the top (as
> given
> > below). For each data point, direction and magnitude of effect could be
> color
> > and significance could be the size of the circle? Is this possible?
> >
> >
> > I would greatly be appreciated your help.
> >
> > Thanks,
> >
> > Greg
> >
> >
> >
> >   y1 y2 y3 y4 y5 y6
> > x1
> > x2
> > x3
> > x4
> > x5
> > x6
> > x7
> > x8
> > x9
> > x10
> > x11
> > x12
> > x13
> > x14
> > x15
> > x16
> > x17
> > .
> > .
> >
> > [[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.
>
> 
> Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou
> určeny pouze jeho adresátům.
> Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě
> neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie
> vymažte ze svého systému.
> Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email
> jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
> Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi
> či zpožděním přenosu e-mailu.
>
> V případě, že je tento e-mail součástí obchodního jednání:
> - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření
> smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
> - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout;
> Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany
> příjemce s dodatkem či odchylkou.
> - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve
> výslovným dosažením shody na všech jejích náležitostech.
> - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za
> společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn
> nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto
> emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich
> existence je adresátovi či osobě jím zastoupené známá.
>
> This e-mail and any documents attached to it may be confidential and are
> intended only for its intended recipients.
> If you received this e-mail by mistake, please immediately inform its
> sender. Delete the contents of this e-mail with all attachments and its
> copies from your system.
> If you are not the intended recipient of this e-mail, you are not
> authorized to use, disseminate, copy or disclose this e-mail in any manner.
> The sender of this e-mail shall not be liable for any possible damage
> caused by modifications of the e-mail or by delay with transfer of the
> email.
>
> In case that this e-mail forms part of business dealings:
> - the sender reserves the right to end negotiations about entering into a
> contract in any time, for any reason, and without stating any reasoning.
> - if the e-mail contains an offer, the recipient is entitled to
> immediately accept such offer; The sender of this e-mail (offer) excludes
> any acceptance of the offer on the part of the recipient containing any
> amendment or variation.
> - the sender insists on that the respective contract is concluded only
> upon an express mutual agreement on all

[R] plotting the regression coefficients

2018-02-07 Thread greg holly
Hi Dear all;

I would like to create a plot for regression coefficients with each
independent variable (x) along the side and the phenotypes (y) across the
top (as given below). For each data point, direction and magnitude of
effect could be color and significance could be the size of the circle? Is
this possible?


I would greatly be appreciated your help.

Thanks,

Greg



  y1 y2 y3 y4 y5 y6
x1
x2
x3
x4
x5
x6
x7
x8
x9
x10
x11
x12
x13
x14
x15
x16
x17
.
.

[[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] plotting the regression coefficients

2018-02-12 Thread greg holly
Hi Petr and Richard;

Thanks for your responses and supports.  I just faced a different problem.
I have the following R codes and work well.

p <- ggplot(a, aes(x=Phenotypes, y=Metabolites, size=abs(Beta),
colour=factor(sign(Beta +
theme(axis.text=element_text(size = 5))
p1<-p+geom_point()
p2<-p1+theme(panel.grid.major = element_blank(),
  panel.grid.minor = element_blank(),
  panel.border = element_blank(),
  axis.ticks = element_blank())

p3<-p2+theme(panel.grid.major = element_blank(), panel.grid.minor =
element_blank(),
panel.background = element_blank(), axis.line = element_line(colour =
"black"))

p4<-p3+scale_color_manual(breaks = c("-1", "0", "1"),
values=c("darkblue", "green", "red"))


*My question is:*
What if I was to repeat the analysis and standardize the beta (z-score) so
they are comparable across phenotypes (I have 8 phenotypes). We could then
“bin” the betas to represent shades of red and blue.

Regards,

Greg


On Mon, Feb 12, 2018 at 8:10 PM, Richard M. Heiberger <r...@temple.edu>
wrote:

> Petr, there was a thinko in your response.
>
>
> tmp <- data.frame(m=factor(letters[1:4]), n=1:4)
> tmp
> tmp$m <- factor(tmp$m, levels=c("c","b","a","d")) ## right
> tmp[order(tmp$m),]
>
> tmp <- data.frame(m=factor(letters[1:4]), n=1:4)
> levels(tmp$m) <- c("c","b","a","d") ## wrong
> tmp[order(tmp$m),]
>
> changing levels directly changes the names only, not the ordering.
> You must redefine the factor to retain the relationship of factor
> names with the numerical values.
>
> Rich
>
>
> On Mon, Feb 12, 2018 at 3:49 AM, PIKAL Petr <petr.pi...@precheza.cz>
> wrote:
> > Hi
> >
> > After melt you can change levels of your factor variable. Again with the
> toy example.
> >
> >> levels(temp$variable)
> > [1] "y1" "y2" "y3" "y4"
> >> levels(temp$variable) <- levels(temp$variable)[c(2,4,1,3)]
> >> levels(temp$variable)
> > [1] "y2" "y4" "y1" "y3"
> >>
> >
> > And you will get graphs with this new levels ordering.
> >
> > Cheers
> > Petr
> >
> > From: greg holly [mailto:mak.hho...@gmail.com]
> > Sent: Monday, February 12, 2018 8:52 AM
> > To: PIKAL Petr <petr.pi...@precheza.cz>
> > Cc: r-help mailing list <r-help@r-project.org>
> > Subject: Re: [R] plotting the regression coefficients
> >
> > Hi Petr;
> >
> > Thanks so much. This is great! Although last Sunday, alternatively, I
> have solved the problem using the following statement at the very end of
> the program.
> >
> >  ggsave('circle.pdf', p4, height = 70, width = 8, device=pdf, limitsize
> = F, dpi=300).
> >
> > This works very well too.
> >
> > Asa my categorical variables are in my Y axis, my R program reorders the
> names on Y-axis. However, I would like have and plot output with the names
> as they are. Is there any way to have plot without ordering the names of
> variables on Y-axis?
> >
> > Regards,
> > Greg.
> >
> > On Mon, Feb 12, 2018 at 10:12 AM, PIKAL Petr <petr.pi...@precheza.cz<
> mailto:petr.pi...@precheza.cz>> wrote:
> > Hi
> >
> > Maybe there are other ways but I would split data to several chunks e.g.
> in list and use for cycle to fill multipage pdf.
> >
> > With the toy data something like
> >
> > library(reshape2)
> > library(ggplot2)
> > temp <- melt(temp)
> > temp.s<-split(temp, cut(1:nrow(temp), 2))
> >
> > pdf("temp.pdf")
> > for (i in 1: length(temp.s)) {
> > p <- ggplot(temp.s[[i]], aes(x=par1, y=variable, size=abs(value),
> colour=factor(sign(value
> > print(p+geom_point())
> > }
> > dev.off()
> >
> > But the real code partly depends on your real data.
> >
> > Cheers
> > Petr
> >
> > From: greg holly [mailto:mak.hho...@gmail.com mak.hho...@gmail.com>]
> > Sent: Saturday, February 10, 2018 9:05 PM
> >
> > To: PIKAL Petr <petr.pi...@precheza.cz<mailto:petr.pi...@precheza.cz>>
> > Cc: r-help mailing list <r-help@r-project.org -h...@r-project.org>>
> > Subject: Re: [R] plotting the regression coefficients
> >
> > Hi Peter;
> >
> > The R code you provided works very well. Once again thanks so much for
> this. The number of variables in my data set that should appear on the
> y-axis is 733 and they are not numerical (for 

Re: [R] plotting the regression coefficients

2018-02-11 Thread greg holly
Hi Petr;

Thanks so much. This is great! Although last Sunday, alternatively, I have
solved the problem using the following statement at the very end of the
program.

* ggsave('circle.pdf', p4, height = 70, width = 8, device=pdf, limitsize =
F, dpi=300).*

This works very well too.

Asa my categorical variables are in my Y axis, my R program reorders the
names on Y-axis. However, I would like have and plot output with the names
as they are. Is there any way to have plot without ordering the names of
variables on Y-axis?

Regards,
Greg.

On Mon, Feb 12, 2018 at 10:12 AM, PIKAL Petr <petr.pi...@precheza.cz> wrote:

> Hi
>
>
>
> Maybe there are other ways but I would split data to several chunks e.g.
> in list and use for cycle to fill multipage pdf.
>
>
>
> With the toy data something like
>
>
>
> library(reshape2)
>
> library(ggplot2)
>
> temp <- melt(temp)
>
> temp.s<-split(temp, cut(1:nrow(temp), 2))
>
>
>
> pdf("temp.pdf")
>
> for (i in 1: length(temp.s)) {
>
> p <- ggplot(temp.s[[i]], aes(x=par1, y=variable, size=abs(value),
> colour=factor(sign(value
>
> print(p+geom_point())
>
> }
>
> dev.off()
>
>
>
> But the real code partly depends on your real data.
>
>
>
> Cheers
>
> Petr
>
>
>
> *From:* greg holly [mailto:mak.hho...@gmail.com]
> *Sent:* Saturday, February 10, 2018 9:05 PM
>
> *To:* PIKAL Petr <petr.pi...@precheza.cz>
> *Cc:* r-help mailing list <r-help@r-project.org>
> *Subject:* Re: [R] plotting the regression coefficients
>
>
>
> Hi Peter;
>
>
>
> The R code you provided works very well. Once again thanks so much for
> this. The number of variables in my data set that should appear on the
> y-axis is 733 and they are not numerical (for example the name of one
> variable is *palmitoyl-arachidonoyl-glycerol (16:0/20:4) [1]**. So, the
> plot looks very messy in one page. How can I make the plot to print out on
> multiple pages?
>
>
>
> Regards,
>
>
>
> Greg
>
>
>
> On Thu, Feb 8, 2018 at 4:33 PM, greg holly <mak.hho...@gmail.com> wrote:
>
> Hi Petr;
>
>
>
> Thanks so much. Exactly this is what I need. I will play to change color
> and so on but this backbound is perfect to me. I do appreciate your help
> and support.
>
>
>
> Regards,
>
> Greg
>
>
>
> On Thu, Feb 8, 2018 at 1:29 PM, PIKAL Petr <petr.pi...@precheza.cz> wrote:
>
> Hi
>
> I copied your values to R, here it is
>
>
>
> > dput(temp)
>
>
>
> temp <- structure(list(par1 = structure(1:4, .Label = c("x1", "x2", "x3",
>
> "x4"), class = "factor"), y1 = c(-0.19, 0.45, -0.09, -0.16),
>
> y2 = c(0.4, -0.75, 0.14, -0.01), y3 = c(-0.06, -8.67, 1.42,
>
> 2.21), y4 = c(0.13, -0.46, 0.06, 0.06)), .Names = c("par1",
>
> "y1", "y2", "y3", "y4"), class = "data.frame", row.names = c(NA,
>
> -4L))
>
>
>
> For plotting it need to be reshaped
>
>
>
> library(reshape2)
>
> library(ggplot2)
>
>
>
> temp <- melt(temp)
>
> p <- ggplot(temp, aes(x=par1, y=variable, size=abs(value),
> colour=factor(sign(value
>
> p+geom_point()
>
>
>
> Is this what you wanted?
>
>
>
> Cheers
>
> Petr
>
> And preferably do not post in HTML, the email content could be scrambled.
>
>
>
> *From:* greg holly [mailto:mak.hho...@gmail.com]
> *Sent:* Thursday, February 8, 2018 9:23 AM
> *To:* PIKAL Petr <petr.pi...@precheza.cz>
> *Cc:* r-help mailing list <r-help@r-project.org>
> *Subject:* Re: [R] plotting the regression coefficients
>
>
>
> Hi Petr;
>
>
>
> Thanks for your reply. It is much appreciated. A small example is given
> below for 4 independent and 4 dependent variables only. The values given
> are regression coefficients.I have looked ggplot documents before writing
> to you. Unfortunately, I could not figure out as my experience in ggplot is
> ignorable
>
>
>
> Regards.
>
> Greg
>
>
>
> y1 y2 y3 y4
>
> x1 -0.19 0.40 -0.06 0.13
>
> x2 0.45 -0.75 -8.67 -0.46
>
> x3 -0.09 0.14 1.42 0.06
>
> x4 -0.16 -0.01 2.21 0.06
>
>
>
>
>
> On Thu, Feb 8, 2018 at 10:19 AM, PIKAL Petr <petr.pi...@precheza.cz>
> wrote:
>
> Hi
>
> Example, example, example - preferably working.
>
> Wild guess - did you try ggplot?
>
> Cheers
> Petr
>
>
>
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Be

Re: [R] plotting the regression coefficients

2018-02-13 Thread greg holly
Hi Petr;

Thanks for this. I have used  scale_colour_gradient before but could not
get what I am looking for. I will check the links you provide to get Idea.
Once again thanks for your support and help.

Rgerads,
Greg



On Tue, Feb 13, 2018 at 5:34 PM, PIKAL Petr <petr.pi...@precheza.cz> wrote:

> Hi
>
> scale_colour_gradient(“red”, “blue”)
>
> should do the trick.
>
> Actually I found it by Google
>
> ggplot colour
>
> http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/
>
> http://www.sthda.com/english/wiki/ggplot2-colors-how-to-
> change-colors-automatically-and-manually#gradient-colors-for-scatter-plots
>
> question. So you could find it too and probably far more quickly then
> myself as I have also other duties.
>
> Cheers
>
> Petr
>
> BTW, you still post in HTML which could be sometimes problematic in this
> text only list.
>
>
>
> *From:* greg holly [mailto:mak.hho...@gmail.com]
> *Sent:* Monday, February 12, 2018 7:07 PM
> *To:* Richard M. Heiberger <r...@temple.edu>
> *Cc:* PIKAL Petr <petr.pi...@precheza.cz>; r-help mailing list <
> r-help@r-project.org>
>
> *Subject:* Re: [R] plotting the regression coefficients
>
>
>
> Hi Petr and Richard;
>
>
>
> Thanks for your responses and supports.  I just faced a different problem.
> I have the following R codes and work well.
>
>
>
> p <- ggplot(a, aes(x=Phenotypes, y=Metabolites, size=abs(Beta),
> colour=factor(sign(Beta +
>
> theme(axis.text=element_text(size = 5))
>
> p1<-p+geom_point()
>
> p2<-p1+theme(panel.grid.major = element_blank(),
>
>   panel.grid.minor = element_blank(),
>
>   panel.border = element_blank(),
>
>   axis.ticks = element_blank())
>
>
>
> p3<-p2+theme(panel.grid.major = element_blank(), panel.grid.minor =
> element_blank(),
>
> panel.background = element_blank(), axis.line = element_line(colour =
> "black"))
>
>
>
> p4<-p3+scale_color_manual(breaks = c("-1", "0", "1"),
>
> values=c("darkblue", "green", "red"))
>
>
>
>
>
> *My question is:*
>
> What if I was to repeat the analysis and standardize the beta (z-score) so
> they are comparable across phenotypes (I have 8 phenotypes). We could then
> “bin” the betas to represent shades of red and blue.
>
>
>
> Regards,
>
>
>
> Greg
>
>
>
>
>
> On Mon, Feb 12, 2018 at 8:10 PM, Richard M. Heiberger <r...@temple.edu>
> wrote:
>
> Petr, there was a thinko in your response.
>
>
> tmp <- data.frame(m=factor(letters[1:4]), n=1:4)
> tmp
> tmp$m <- factor(tmp$m, levels=c("c","b","a","d")) ## right
> tmp[order(tmp$m),]
>
> tmp <- data.frame(m=factor(letters[1:4]), n=1:4)
> levels(tmp$m) <- c("c","b","a","d") ## wrong
> tmp[order(tmp$m),]
>
> changing levels directly changes the names only, not the ordering.
> You must redefine the factor to retain the relationship of factor
> names with the numerical values.
>
> Rich
>
>
> On Mon, Feb 12, 2018 at 3:49 AM, PIKAL Petr <petr.pi...@precheza.cz>
> wrote:
> > Hi
> >
> > After melt you can change levels of your factor variable. Again with the
> toy example.
> >
> >> levels(temp$variable)
> > [1] "y1" "y2" "y3" "y4"
> >> levels(temp$variable) <- levels(temp$variable)[c(2,4,1,3)]
> >> levels(temp$variable)
> > [1] "y2" "y4" "y1" "y3"
> >>
> >
> > And you will get graphs with this new levels ordering.
> >
> > Cheers
> > Petr
> >
> > From: greg holly [mailto:mak.hho...@gmail.com]
> > Sent: Monday, February 12, 2018 8:52 AM
> > To: PIKAL Petr <petr.pi...@precheza.cz>
> > Cc: r-help mailing list <r-help@r-project.org>
> > Subject: Re: [R] plotting the regression coefficients
> >
> > Hi Petr;
> >
> > Thanks so much. This is great! Although last Sunday, alternatively, I
> have solved the problem using the following statement at the very end of
> the program.
> >
> >  ggsave('circle.pdf', p4, height = 70, width = 8, device=pdf, limitsize
> = F, dpi=300).
> >
> > This works very well too.
> >
> > Asa my categorical variables are in my Y axis, my R program reorders the
> names on Y-axis. However, I would like have and plot output with the names
> as they are. Is there any way to have plot without ordering the names of
> variables on Y-ax

Re: [R] plotting the regression coefficients

2018-02-10 Thread greg holly
Hi Peter;

The R code you provided works very well. Once again thanks so much for
this. The number of variables in my data set that should appear on the
y-axis is 733 and they are not numerical (for example the name of one
variable is *palmitoyl-arachidonoyl-glycerol (16:0/20:4) [1]**. So, the
plot looks very messy in one page. How can I make the plot to print out on
multiple pages?

Regards,

Greg

On Thu, Feb 8, 2018 at 4:33 PM, greg holly <mak.hho...@gmail.com> wrote:

> Hi Petr;
>
> Thanks so much. Exactly this is what I need. I will play to change color
> and so on but this backbound is perfect to me. I do appreciate your help
> and support.
>
> Regards,
> Greg
>
> On Thu, Feb 8, 2018 at 1:29 PM, PIKAL Petr <petr.pi...@precheza.cz> wrote:
>
>> Hi
>>
>> I copied your values to R, here it is
>>
>>
>>
>> > dput(temp)
>>
>>
>>
>> temp <- structure(list(par1 = structure(1:4, .Label = c("x1", "x2", "x3",
>>
>> "x4"), class = "factor"), y1 = c(-0.19, 0.45, -0.09, -0.16),
>>
>> y2 = c(0.4, -0.75, 0.14, -0.01), y3 = c(-0.06, -8.67, 1.42,
>>
>> 2.21), y4 = c(0.13, -0.46, 0.06, 0.06)), .Names = c("par1",
>>
>> "y1", "y2", "y3", "y4"), class = "data.frame", row.names = c(NA,
>>
>> -4L))
>>
>>
>>
>> For plotting it need to be reshaped
>>
>>
>>
>> library(reshape2)
>>
>> library(ggplot2)
>>
>>
>>
>> temp <- melt(temp)
>>
>> p <- ggplot(temp, aes(x=par1, y=variable, size=abs(value),
>> colour=factor(sign(value
>>
>> p+geom_point()
>>
>>
>>
>> Is this what you wanted?
>>
>>
>>
>> Cheers
>>
>> Petr
>>
>> And preferably do not post in HTML, the email content could be scrambled.
>>
>>
>>
>> *From:* greg holly [mailto:mak.hho...@gmail.com]
>> *Sent:* Thursday, February 8, 2018 9:23 AM
>> *To:* PIKAL Petr <petr.pi...@precheza.cz>
>> *Cc:* r-help mailing list <r-help@r-project.org>
>> *Subject:* Re: [R] plotting the regression coefficients
>>
>>
>>
>> Hi Petr;
>>
>>
>>
>> Thanks for your reply. It is much appreciated. A small example is given
>> below for 4 independent and 4 dependent variables only. The values given
>> are regression coefficients.I have looked ggplot documents before writing
>> to you. Unfortunately, I could not figure out as my experience in ggplot is
>> ignorable
>>
>>
>>
>> Regards.
>>
>> Greg
>>
>>
>>
>> y1 y2 y3 y4
>>
>> x1 -0.19 0.40 -0.06 0.13
>>
>> x2 0.45 -0.75 -8.67 -0.46
>>
>> x3 -0.09 0.14 1.42 0.06
>>
>> x4 -0.16 -0.01 2.21 0.06
>>
>>
>>
>>
>>
>> On Thu, Feb 8, 2018 at 10:19 AM, PIKAL Petr <petr.pi...@precheza.cz>
>> wrote:
>>
>> Hi
>>
>> Example, example, example - preferably working.
>>
>> Wild guess - did you try ggplot?
>>
>> Cheers
>> Petr
>>
>>
>>
>> > -Original Message-
>> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of greg
>> holly
>> > Sent: Thursday, February 8, 2018 8:14 AM
>> > To: r-help mailing list <r-help@r-project.org>
>> > Subject: [R] plotting the regression coefficients
>> >
>> > Hi Dear all;
>> >
>> > I would like to create a plot for regression coefficients with each
>> independent
>> > variable (x) along the side and the phenotypes (y) across the top (as
>> given
>> > below). For each data point, direction and magnitude of effect could be
>> color
>> > and significance could be the size of the circle? Is this possible?
>> >
>> >
>> > I would greatly be appreciated your help.
>> >
>> > Thanks,
>> >
>> > Greg
>> >
>> >
>> >
>> >   y1 y2 y3 y4 y5 y6
>> > x1
>> > x2
>> > x3
>> > x4
>> > x5
>> > x6
>> > x7
>> > x8
>> > x9
>> > x10
>> > x11
>> > x12
>> > x13
>> > x14
>> > x15
>> > x16
>> > x17
>> > .
>> > .
>> >
>>
>> > [[alternative HTML version deleted]]
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UN

Re: [R] plotting the regression coefficients

2018-02-08 Thread greg holly
Hi Petr;

Thanks so much. Exactly this is what I need. I will play to change color
and so on but this backbound is perfect to me. I do appreciate your help
and support.

Regards,
Greg

On Thu, Feb 8, 2018 at 1:29 PM, PIKAL Petr <petr.pi...@precheza.cz> wrote:

> Hi
>
> I copied your values to R, here it is
>
>
>
> > dput(temp)
>
>
>
> temp <- structure(list(par1 = structure(1:4, .Label = c("x1", "x2", "x3",
>
> "x4"), class = "factor"), y1 = c(-0.19, 0.45, -0.09, -0.16),
>
> y2 = c(0.4, -0.75, 0.14, -0.01), y3 = c(-0.06, -8.67, 1.42,
>
> 2.21), y4 = c(0.13, -0.46, 0.06, 0.06)), .Names = c("par1",
>
> "y1", "y2", "y3", "y4"), class = "data.frame", row.names = c(NA,
>
> -4L))
>
>
>
> For plotting it need to be reshaped
>
>
>
> library(reshape2)
>
> library(ggplot2)
>
>
>
> temp <- melt(temp)
>
> p <- ggplot(temp, aes(x=par1, y=variable, size=abs(value),
> colour=factor(sign(value
>
> p+geom_point()
>
>
>
> Is this what you wanted?
>
>
>
> Cheers
>
> Petr
>
> And preferably do not post in HTML, the email content could be scrambled.
>
>
>
> *From:* greg holly [mailto:mak.hho...@gmail.com]
> *Sent:* Thursday, February 8, 2018 9:23 AM
> *To:* PIKAL Petr <petr.pi...@precheza.cz>
> *Cc:* r-help mailing list <r-help@r-project.org>
> *Subject:* Re: [R] plotting the regression coefficients
>
>
>
> Hi Petr;
>
>
>
> Thanks for your reply. It is much appreciated. A small example is given
> below for 4 independent and 4 dependent variables only. The values given
> are regression coefficients.I have looked ggplot documents before writing
> to you. Unfortunately, I could not figure out as my experience in ggplot is
> ignorable
>
>
>
> Regards.
>
> Greg
>
>
>
> y1 y2 y3 y4
>
> x1 -0.19 0.40 -0.06 0.13
>
> x2 0.45 -0.75 -8.67 -0.46
>
> x3 -0.09 0.14 1.42 0.06
>
> x4 -0.16 -0.01 2.21 0.06
>
>
>
>
>
> On Thu, Feb 8, 2018 at 10:19 AM, PIKAL Petr <petr.pi...@precheza.cz>
> wrote:
>
> Hi
>
> Example, example, example - preferably working.
>
> Wild guess - did you try ggplot?
>
> Cheers
> Petr
>
>
>
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of greg
> holly
> > Sent: Thursday, February 8, 2018 8:14 AM
> > To: r-help mailing list <r-help@r-project.org>
> > Subject: [R] plotting the regression coefficients
> >
> > Hi Dear all;
> >
> > I would like to create a plot for regression coefficients with each
> independent
> > variable (x) along the side and the phenotypes (y) across the top (as
> given
> > below). For each data point, direction and magnitude of effect could be
> color
> > and significance could be the size of the circle? Is this possible?
> >
> >
> > I would greatly be appreciated your help.
> >
> > Thanks,
> >
> > Greg
> >
> >
> >
> >   y1 y2 y3 y4 y5 y6
> > x1
> > x2
> > x3
> > x4
> > x5
> > x6
> > x7
> > x8
> > x9
> > x10
> > x11
> > x12
> > x13
> > x14
> > x15
> > x16
> > x17
> > .
> > .
> >
>
> > [[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.
>
> 
> Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou
> určeny pouze jeho adresátům.
> Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě
> neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie
> vymažte ze svého systému.
> Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email
> jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
> Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi
> či zpožděním přenosu e-mailu.
>
> V případě, že je tento e-mail součástí obchodního jednání:
> - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření
> smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
> - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout;
> Odesílatel tohoto e-mailu (nabídky) vylučuje 

Re: [R] plotting the regression coefficients

2018-02-08 Thread greg holly
Hi Bert;

Thanks so much for this. It is much appreciated.

Regards,
Greg

On Thu, Feb 8, 2018 at 3:29 PM, Bert Gunter <bgunter.4...@gmail.com> wrote:

> Fwiw, encoding magnitude in color is generally a bad idea. Using
> area(*not* radius) is also not great, but maybe it will work for you.
>
> See here for some explanation: https://www.amazon.com/Visual-Display-
> Quantitative-Information/dp/0961392142/ref=sr_1_1?s=books&
> ie=UTF8=1518092778=1-1=Tufte
>
> Bert
>
>
>
> On Feb 7, 2018 11:13 PM, "greg holly" <mak.hho...@gmail.com> wrote:
>
>> Hi Dear all;
>>
>> I would like to create a plot for regression coefficients with each
>> independent variable (x) along the side and the phenotypes (y) across the
>> top (as given below). For each data point, direction and magnitude of
>> effect could be color and significance could be the size of the circle? Is
>> this possible?
>>
>>
>> I would greatly be appreciated your help.
>>
>> Thanks,
>>
>> Greg
>>
>>
>>
>>   y1 y2 y3 y4 y5 y6
>> x1
>> x2
>> x3
>> x4
>> x5
>> x6
>> x7
>> x8
>> x9
>> x10
>> x11
>> x12
>> x13
>> x14
>> x15
>> x16
>> x17
>> .
>> .
>>
>> [[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/posti
>> ng-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] Putting 733 discrete categories on Y-axis in qqplot2 as they are

2018-02-15 Thread greg holly
Hi all;

I have 733 discrete categories that will go on y-axis in ggplot2. I used
the following command to put the name of x-axis.

scale_x_discrete (limits = c("SI", "HOMAIR",
"AIR","HOMAB","SG","DI","FI","FG"))

Since there are only 8 categories on x it was easy to do. Is there any way
to do the same for 733 discrete categories for y-axis. Essentially I did
not want to order categories. I would like to put the name of categories as
they are.

Best regards,

Greg

[[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] Putting 733 discrete categories on Y-axis in qqplot2 as they are

2018-02-16 Thread greg holly
Hi Petr;

Thanks. I do save the result in pdf by using the following command.

   ggsave("z7.pdf", p4, height = 95, width = 8, device=pdf, limitsize =
F,dpi=300)

 I can achieve the y axis with 733 levels. But I need get the plot WITHOUT
reordering the names.

Regards,

Greg

On Fri, Feb 16, 2018 at 3:39 PM, PIKAL Petr <petr.pi...@precheza.cz> wrote:

> Hi
>
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of greg
> holly
> > Sent: Thursday, February 15, 2018 3:58 PM
> > To: r-help mailing list <r-help@r-project.org>
> > Subject: [R] Putting 733 discrete categories on Y-axis in qqplot2 as
> they are
> >
> > Hi all;
> >
> > I have 733 discrete categories that will go on y-axis in ggplot2. I used
> the
> > following command to put the name of x-axis.
> >
> > scale_x_discrete (limits = c("SI", "HOMAIR",
> > "AIR","HOMAB","SG","DI","FI","FG"))
> >
> > Since there are only 8 categories on x it was easy to do. Is there any
> way to do
> > the same for 733 discrete categories for y-axis. Essentially I did not
> want to
> > order categories. I would like to put the name of categories as they are.
>
> You probably can achieve the y axis with 733 levels if you do not use
> limits in scale.
>
> Just from curiosity, standard page has 30 lines, so your axis should
> stretch to more than 20 pages. Or you need to shrink your y axis 20 times.
> Both options will give you unreadable results.
>
> Cheers
> Petr
>
> >
> > Best regards,
> >
> > Greg
> >
> > [[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.
>
> 
> Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou
> určeny pouze jeho adresátům.
> Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě
> neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie
> vymažte ze svého systému.
> Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email
> jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
> Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi
> či zpožděním přenosu e-mailu.
>
> V případě, že je tento e-mail součástí obchodního jednání:
> - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření
> smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
> - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout;
> Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany
> příjemce s dodatkem či odchylkou.
> - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve
> výslovným dosažením shody na všech jejích náležitostech.
> - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za
> společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn
> nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto
> emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich
> existence je adresátovi či osobě jím zastoupené známá.
>
> This e-mail and any documents attached to it may be confidential and are
> intended only for its intended recipients.
> If you received this e-mail by mistake, please immediately inform its
> sender. Delete the contents of this e-mail with all attachments and its
> copies from your system.
> If you are not the intended recipient of this e-mail, you are not
> authorized to use, disseminate, copy or disclose this e-mail in any manner.
> The sender of this e-mail shall not be liable for any possible damage
> caused by modifications of the e-mail or by delay with transfer of the
> email.
>
> In case that this e-mail forms part of business dealings:
> - the sender reserves the right to end negotiations about entering into a
> contract in any time, for any reason, and without stating any reasoning.
> - if the e-mail contains an offer, the recipient is entitled to
> immediately accept such offer; The sender of this e-mail (offer) excludes
> any acceptance of the offer on the part of the recipient containing any
> amendment or variation.
> - the sender insists on that the respective contract is concluded only
> upon an express mutual agreement on all its aspects.
> - the

Re: [R] Putting 733 discrete categories on Y-axis in qqplot2 as they are

2018-02-16 Thread greg holly
Hi Petr;

I would like to get a plot with names as they are in the original file.
They are chemical names and I have 733 in the my file. For example, let me
give to chemical names "*2-hydroxybutyrate/2-hydroxyisobutyrate*" and
"*palmitoyl-arachidonoyl-glycerol
(16:0/20:4) [1]**" .So, what should I put  [c(2,3,1)] part in the command:
iris$MySpecies<-factor(iris$Species, levels(iris$Species)[c(2,3,1)])

Regards,

Greg

On Fri, Feb 16, 2018 at 6:13 PM, PIKAL Petr <petr.pi...@precheza.cz> wrote:

> Hi
>
>
>
> What do you mean „without reordering the names“. Factor variable is
> ordered according to its levels and you can freely change the ordering.
> This is why factors are useful and worth to use in many cases instead of
> character vectors.
>
>
>
> See this result
>
>
>
> > iris$MySpecies<-factor(iris$Species, levels(iris$Species)[c(2,3,1)])
>
> > p<-ggplot(iris, aes(x=Sepal.Length, y=Species))
>
> > p+geom_point()
>
> > p<-ggplot(iris, aes(x=Sepal.Length, y=MySpecies))
>
> > p+geom_point()
>
> >
>
> Cheers
>
> Petr
>
>
>
> *From:* greg holly [mailto:mak.hho...@gmail.com]
> *Sent:* Friday, February 16, 2018 3:56 PM
> *To:* PIKAL Petr <petr.pi...@precheza.cz>
> *Cc:* r-help mailing list <r-help@r-project.org>
> *Subject:* Re: [R] Putting 733 discrete categories on Y-axis in qqplot2
> as they are
>
>
>
> Hi Petr;
>
>
>
> Thanks. I do save the result in pdf by using the following command.
>
>
>
>ggsave("z7.pdf", p4, height = 95, width = 8, device=pdf, limitsize =
> F,dpi=300)
>
>
>
>  I can achieve the y axis with 733 levels. But I need get the plot
> WITHOUT reordering the names.
>
>
>
> Regards,
>
>
>
> Greg
>
>
>
> On Fri, Feb 16, 2018 at 3:39 PM, PIKAL Petr <petr.pi...@precheza.cz>
> wrote:
>
> Hi
>
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of greg
> holly
> > Sent: Thursday, February 15, 2018 3:58 PM
> > To: r-help mailing list <r-help@r-project.org>
> > Subject: [R] Putting 733 discrete categories on Y-axis in qqplot2 as
> they are
> >
> > Hi all;
> >
> > I have 733 discrete categories that will go on y-axis in ggplot2. I used
> the
> > following command to put the name of x-axis.
> >
> > scale_x_discrete (limits = c("SI", "HOMAIR",
> > "AIR","HOMAB","SG","DI","FI","FG"))
> >
> > Since there are only 8 categories on x it was easy to do. Is there any
> way to do
> > the same for 733 discrete categories for y-axis. Essentially I did not
> want to
> > order categories. I would like to put the name of categories as they are.
>
> You probably can achieve the y axis with 733 levels if you do not use
> limits in scale.
>
> Just from curiosity, standard page has 30 lines, so your axis should
> stretch to more than 20 pages. Or you need to shrink your y axis 20 times.
> Both options will give you unreadable results.
>
> Cheers
> Petr
>
> >
> > Best regards,
> >
> > Greg
> >
>
>
>
> --
> Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou
> určeny pouze jeho adresátům.
> Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě
> neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie
> vymažte ze svého systému.
> Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email
> jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
> Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi
> či zpožděním přenosu e-mailu.
>
> V případě, že je tento e-mail součástí obchodního jednání:
> - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření
> smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
> - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout;
> Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany
> příjemce s dodatkem či odchylkou.
> - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve
> výslovným dosažením shody na všech jejích náležitostech.
> - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za
> společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn
> nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto
> emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich
> existence je adresátovi či osobě jím zastoupené známá.
>
> This e-mail and any documents attache

Re: [R] Putting 733 discrete categories on Y-axis in qqplot2 as they are

2018-02-19 Thread greg holly
Hi Petr;

Thanks for this. I have used the following code to overcome with the problem


a$Meta <- factor(a$Meta, levels=a[order(a$Superpath,decreasing=T),]$Meta)

Regards,
Greg


On Mon, Feb 19, 2018 at 4:04 PM, PIKAL Petr <petr.pi...@precheza.cz> wrote:

> Hi
>
>
>
> When you load external file to R, character variables are converted to
> factors by default and alphabetically sorted. I have limited connection to
> internet, so I cannot find the answer, you could try it yourself. Maybe you
> could try not to convert vector with names to factor, which, for plotting
> issue is not different from factor coding.
>
>
>
> See ?read.table for details
>
>
>
> However I am not sure if it stays in original order.
>
>
>
> Cheers
>
> Petr
>
>
>
> *From:* greg holly [mailto:mak.hho...@gmail.com]
> *Sent:* Friday, February 16, 2018 6:28 PM
>
> *To:* PIKAL Petr <petr.pi...@precheza.cz>
> *Cc:* r-help mailing list <r-help@r-project.org>
> *Subject:* Re: [R] Putting 733 discrete categories on Y-axis in qqplot2
> as they are
>
>
>
> Hi Petr;
>
>
>
> I would like to get a plot with names as they are in the original file.
> They are chemical names and I have 733 in the my file. For example, let me
> give to chemical names "*2-hydroxybutyrate/2-hydroxyisobutyrate*" and  
> "*palmitoyl-arachidonoyl-glycerol
> (16:0/20:4) [1]**" .So, what should I put  [c(2,3,1)] part in the
> command:  iris$MySpecies<-factor(iris$Species,
> levels(iris$Species)[c(2,3,1)])
>
>
>
> Regards,
>
>
>
> Greg
>
>
>
> On Fri, Feb 16, 2018 at 6:13 PM, PIKAL Petr <petr.pi...@precheza.cz>
> wrote:
>
> Hi
>
>
>
> What do you mean „without reordering the names“. Factor variable is
> ordered according to its levels and you can freely change the ordering.
> This is why factors are useful and worth to use in many cases instead of
> character vectors.
>
>
>
> See this result
>
>
>
> > iris$MySpecies<-factor(iris$Species, levels(iris$Species)[c(2,3,1)])
>
> > p<-ggplot(iris, aes(x=Sepal.Length, y=Species))
>
> > p+geom_point()
>
> > p<-ggplot(iris, aes(x=Sepal.Length, y=MySpecies))
>
> > p+geom_point()
>
> >
>
> Cheers
>
> Petr
>
>
>
> *From:* greg holly [mailto:mak.hho...@gmail.com]
> *Sent:* Friday, February 16, 2018 3:56 PM
> *To:* PIKAL Petr <petr.pi...@precheza.cz>
> *Cc:* r-help mailing list <r-help@r-project.org>
> *Subject:* Re: [R] Putting 733 discrete categories on Y-axis in qqplot2
> as they are
>
>
>
> Hi Petr;
>
>
>
> Thanks. I do save the result in pdf by using the following command.
>
>
>
>ggsave("z7.pdf", p4, height = 95, width = 8, device=pdf, limitsize =
> F,dpi=300)
>
>
>
>  I can achieve the y axis with 733 levels. But I need get the plot
> WITHOUT reordering the names.
>
>
>
> Regards,
>
>
>
> Greg
>
>
>
> On Fri, Feb 16, 2018 at 3:39 PM, PIKAL Petr <petr.pi...@precheza.cz>
> wrote:
>
> Hi
>
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of greg
> holly
> > Sent: Thursday, February 15, 2018 3:58 PM
> > To: r-help mailing list <r-help@r-project.org>
> > Subject: [R] Putting 733 discrete categories on Y-axis in qqplot2 as
> they are
> >
> > Hi all;
> >
> > I have 733 discrete categories that will go on y-axis in ggplot2. I used
> the
> > following command to put the name of x-axis.
> >
> > scale_x_discrete (limits = c("SI", "HOMAIR",
> > "AIR","HOMAB","SG","DI","FI","FG"))
> >
> > Since there are only 8 categories on x it was easy to do. Is there any
> way to do
> > the same for 733 discrete categories for y-axis. Essentially I did not
> want to
> > order categories. I would like to put the name of categories as they are.
>
> You probably can achieve the y axis with 733 levels if you do not use
> limits in scale.
>
> Just from curiosity, standard page has 30 lines, so your axis should
> stretch to more than 20 pages. Or you need to shrink your y axis 20 times.
> Both options will give you unreadable results.
>
> Cheers
> Petr
>
> >
> > Best regards,
> >
> > Greg
> >
>
>
>
>
> --
>
> Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou
> určeny pouze jeho adresátům.
> Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě
> neprodleně jeho ode

[R] Error in adabag

2018-01-01 Thread greg holly
Hi all;

Happy new year. I have got the following error

rror in if (nrow(object$splits) > 0) { : argument is of length zero

 when I am running the following codes.

train <- c(sample(1:27,18), sample(28:54, 18), sample(55:81, 8))
 a2011.adaboost <- boosting(median_kod ~ ., data = b[train, ], boos=TRUE,
mfinal = 10,  control = rpart.control(minsplit = 0))

Regards,

Greg

[[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] reading data problem

2018-09-24 Thread greg holly
Hi Dear all;

I have a dataset with 151*291 dimension. After making data read into R I am
getting a data with 96*291 dimension. Even though  I have no error message
from R I could not understand the reason why I cannot get data correctly?

Here are my codes to make read the data
a<-read.table("for_R_graphs.csv", header=T, sep=",")
a<-read.table("for_R_graphs.txt", header=T, sep="\t")

Regards,

Greg

[[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] reading data problem

2018-09-24 Thread greg holly
Hi Jan;

Thanks so much. It is much appreciated. The problem has been solved.

Regards,

Greg

On Mon, Sep 24, 2018 at 3:05 PM Jan T Kim  wrote:

> hmm... I don't see the quote="" paraneter in your read.csv call
>
>
> Best regards, Jan
> --
> Sent from my mobile. Apologies for typos and terseness
>
> On Mon, Sep 24, 2018, 20:40 greg holly  wrote:
>
>> Hi Jan;
>>
>> Thanks so much for this. Yes, I did. Her is my code to read
>> data: a<-read.csv("for_R_graphs.csv", header=T, sep=",")
>>
>> On Mon, Sep 24, 2018 at 2:07 PM Jan T Kim via R-help <
>> r-help@r-project.org> wrote:
>>
>>> Yet one more: have you tried adding quote="" to your read.table
>>> parameters? Quote characters have a 50% chance of being balanced,
>>> and they can encompass multiple lines...
>>>
>>> On Mon, Sep 24, 2018 at 11:40:47AM -0700, Bert Gunter wrote:
>>> > One more question:
>>> >
>>> > 5. Have you tried shutting down, restarting R, and rereading?
>>> >
>>> > -- Bert
>>> >
>>> > On Mon, Sep 24, 2018 at 11:36 AM Bert Gunter 
>>> wrote:
>>> >
>>> > > *Perhaps* useful questions (perhaps *not*, though):
>>> > >
>>> > > 1. What is your OS? What is your R version?
>>> > > 2. How do you know that your data has 151 rows?
>>> > > 3. Are there stray characters -- perhaps a stray eof -- in your
>>> data? Have
>>> > > you checked around row 96 to see what's there?
>>> > > 4. Are the data you did get in R what you expect?
>>> > >
>>> > > -- 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 Mon, Sep 24, 2018 at 11:27 AM greg holly 
>>> wrote:
>>> > >
>>> > >> Hi Dear all;
>>> > >>
>>> > >> I have a dataset with 151*291 dimension. After making data read
>>> into R I
>>> > >> am
>>> > >> getting a data with 96*291 dimension. Even though  I have no error
>>> message
>>> > >> from R I could not understand the reason why I cannot get data
>>> correctly?
>>> > >>
>>> > >> Here are my codes to make read the data
>>> > >> a<-read.table("for_R_graphs.csv", header=T, sep=",")
>>> > >> a<-read.table("for_R_graphs.txt", header=T, sep="\t")
>>> > >>
>>> > >> Regards,
>>> > >>
>>> > >> Greg
>>> > >>
>>> > >> [[alternative HTML version deleted]]
>>> > >>
>>> > >> __
>>> > >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> > >> https://stat.ethz.ch/mailman/listinfo/r-help
>>> > >> PLEASE do read the posting guide
>>> > >> http://www.R-project.org/posting-guide.html
>>> > >> and provide commented, minimal, self-contained, reproducible code.
>>> > >>
>>> > >
>>> >
>>> >   [[alternative HTML version deleted]]
>>> >
>>> > __
>>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> > https://stat.ethz.ch/mailman/listinfo/r-help
>>> > PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> > and provide commented, minimal, self-contained, reproducible code.
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>

[[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] reading data problem

2018-09-24 Thread greg holly
Hi Bert;

Thanks for writing. Here are my answers to your questions:

Regards,

Greg

1. What is your OS? What is your R version?  *The version is 3.5.0*
2. How do you know that your data has 151 rows?  *Because I looked in excel
also I work on the same data in SAS*
3. Are there stray characters -- perhaps a stray eof -- in your data? Have
you checked around row 96 to see what's there?  *I don't think so if I have
stray characters*
4. Are the data you did get in R what you expect? * I will run for some
graphics*
5. Have you tried shutting down, restarting R, and rereading?  *Yes and
again I had the same problem*

On Mon, Sep 24, 2018 at 1:36 PM Bert Gunter  wrote:

> *Perhaps* useful questions (perhaps *not*, though):
>
> 1. What is your OS? What is your R version?
> 2. How do you know that your data has 151 rows?
> 3. Are there stray characters -- perhaps a stray eof -- in your data? Have
> you checked around row 96 to see what's there?
> 4. Are the data you did get in R what you expect?
>
> -- 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 Mon, Sep 24, 2018 at 11:27 AM greg holly  wrote:
>
>> Hi Dear all;
>>
>> I have a dataset with 151*291 dimension. After making data read into R I
>> am
>> getting a data with 96*291 dimension. Even though  I have no error message
>> from R I could not understand the reason why I cannot get data correctly?
>>
>> Here are my codes to make read the data
>> a<-read.table("for_R_graphs.csv", header=T, sep=",")
>> a<-read.table("for_R_graphs.txt", header=T, sep="\t")
>>
>> Regards,
>>
>> Greg
>>
>> [[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] reading data problem

2018-09-24 Thread greg holly
Hi Jan;

Thanks so much for this. Yes, I did. Her is my code to read
data: a<-read.csv("for_R_graphs.csv", header=T, sep=",")

On Mon, Sep 24, 2018 at 2:07 PM Jan T Kim via R-help 
wrote:

> Yet one more: have you tried adding quote="" to your read.table
> parameters? Quote characters have a 50% chance of being balanced,
> and they can encompass multiple lines...
>
> On Mon, Sep 24, 2018 at 11:40:47AM -0700, Bert Gunter wrote:
> > One more question:
> >
> > 5. Have you tried shutting down, restarting R, and rereading?
> >
> > -- Bert
> >
> > On Mon, Sep 24, 2018 at 11:36 AM Bert Gunter 
> wrote:
> >
> > > *Perhaps* useful questions (perhaps *not*, though):
> > >
> > > 1. What is your OS? What is your R version?
> > > 2. How do you know that your data has 151 rows?
> > > 3. Are there stray characters -- perhaps a stray eof -- in your data?
> Have
> > > you checked around row 96 to see what's there?
> > > 4. Are the data you did get in R what you expect?
> > >
> > > -- 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 Mon, Sep 24, 2018 at 11:27 AM greg holly 
> wrote:
> > >
> > >> Hi Dear all;
> > >>
> > >> I have a dataset with 151*291 dimension. After making data read into
> R I
> > >> am
> > >> getting a data with 96*291 dimension. Even though  I have no error
> message
> > >> from R I could not understand the reason why I cannot get data
> correctly?
> > >>
> > >> Here are my codes to make read the data
> > >> a<-read.table("for_R_graphs.csv", header=T, sep=",")
> > >> a<-read.table("for_R_graphs.txt", header=T, sep="\t")
> > >>
> > >> Regards,
> > >>
> > >> Greg
> > >>
> > >> [[alternative HTML version deleted]]
> > >>
> > >> __
> > >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > >> https://stat.ethz.ch/mailman/listinfo/r-help
> > >> PLEASE do read the posting guide
> > >> http://www.R-project.org/posting-guide.html
> > >> and provide commented, minimal, self-contained, reproducible code.
> > >>
> > >
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] meta analysis for sensitivity and specificity

2018-12-07 Thread greg holly
Dear All;

I sincerely apologize for TYPOS. My question is that:

Does anyone know any R library that runs meta-analysis differently for
Sensitivity and Specificity if I have only the following info in my data
set?
Once again my apologies for the mistake in my earlier email.

Regards,

Greg

specificity sample_size Sensitivity Sample_size
1 21 0.66 57
1 70 0.55 33
1 19 0.76 17
1 10 0.4 30
1 16 0.46 11

On Fri, Dec 7, 2018 at 6:16 AM Viechtbauer, Wolfgang (SP) <
wolfgang.viechtba...@maastrichtuniversity.nl> wrote:

> Dear Greg,
>
> I am not sure if I understand your question. If you are asking how to do
> this in R, then one could use the metafor or meta package for this. The
> specificity and sensitivity values are proportions, so one would usually
> meta-analyze them after a logit transformation. But all of the specificity
> values are equal to 1, so this is pretty pointless. For sensitivity:
>
> dat <- data.frame(pi = c(.66, .55, .76, .40, .46), ni = c(57, 33, 17, 30,
> 11))
> dat$xi <- round(dat$pi * dat$ni)
>
> library(metafor)
>
> dat <- escalc(measure="PLO", xi=xi, ni=ni, data=dat)
> res <- rma(yi, vi, data=dat)
> res
> predict(res, transf=transf.ilogit)
>
> One could also use a logistic mixed-effects model for this:
>
> res <- rma.glmm(measure="PLO", xi=xi, ni=ni, data=dat)
> res
> predict(res, transf=transf.ilogit)
>
> If you want to analyze the specificity and sensitivity together, then you
> would want to use a bivariate model. There are some specific packages for
> this. See the Meta-Analysis Task View (
> https://cran.r-project.org/web/views/MetaAnalysis.html). I just saw that
> Michael also replied with the same suggestion (and the note about the
> mailing list).
>
> Best,
> Wolfgang
>
> >-Original Message-
> >From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of greg
> >holly
> >Sent: Thursday, 06 December, 2018 22:38
> >To: r-help mailing list
> >Subject: [R] meta analysis for sensitivity and specificity
> >
> >Does anyone know any R library that runs meta-analysis in SAS differently
> >for  Sensitivity and Specificity if I have only the following info?
> >
> >Regards,
> >
> >Greg
> >
> >specificity sample_size Sensitivity Sample_size
> >1 21 0.66 57
> >1 70 0.55 33
> >1 19 0.76 17
> >1 10 0.4 30
> >1 16 0.46 11
>

[[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] meta analysis for sensitivity and specificity

2018-12-07 Thread greg holly
Hi Viechtbauer and Micheal;


Thanks so much for writing. It is much appreciated.

Regards,
Greg

On Fri, Dec 7, 2018 at 6:16 AM Viechtbauer, Wolfgang (SP) <
wolfgang.viechtba...@maastrichtuniversity.nl> wrote:

> Dear Greg,
>
> I am not sure if I understand your question. If you are asking how to do
> this in R, then one could use the metafor or meta package for this. The
> specificity and sensitivity values are proportions, so one would usually
> meta-analyze them after a logit transformation. But all of the specificity
> values are equal to 1, so this is pretty pointless. For sensitivity:
>
> dat <- data.frame(pi = c(.66, .55, .76, .40, .46), ni = c(57, 33, 17, 30,
> 11))
> dat$xi <- round(dat$pi * dat$ni)
>
> library(metafor)
>
> dat <- escalc(measure="PLO", xi=xi, ni=ni, data=dat)
> res <- rma(yi, vi, data=dat)
> res
> predict(res, transf=transf.ilogit)
>
> One could also use a logistic mixed-effects model for this:
>
> res <- rma.glmm(measure="PLO", xi=xi, ni=ni, data=dat)
> res
> predict(res, transf=transf.ilogit)
>
> If you want to analyze the specificity and sensitivity together, then you
> would want to use a bivariate model. There are some specific packages for
> this. See the Meta-Analysis Task View (
> https://cran.r-project.org/web/views/MetaAnalysis.html). I just saw that
> Michael also replied with the same suggestion (and the note about the
> mailing list).
>
> Best,
> Wolfgang
>
> >-Original Message-
> >From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of greg
> >holly
> >Sent: Thursday, 06 December, 2018 22:38
> >To: r-help mailing list
> >Subject: [R] meta analysis for sensitivity and specificity
> >
> >Does anyone know any R library that runs meta-analysis in SAS differently
> >for  Sensitivity and Specificity if I have only the following info?
> >
> >Regards,
> >
> >Greg
> >
> >specificity sample_size Sensitivity Sample_size
> >1 21 0.66 57
> >1 70 0.55 33
> >1 19 0.76 17
> >1 10 0.4 30
> >1 16 0.46 11
>

[[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] meta analysis for sensitivity and specificity

2018-12-06 Thread greg holly
Does anyone know any R library that runs meta-analysis in SAS differently
for  Sensitivity and Specificity if I have only the following info?

Regards,

Greg

specificity sample_size Sensitivity Sample_size
1 21 0.66 57
1 70 0.55 33
1 19 0.76 17
1 10 0.4 30
1 16 0.46 11

[[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] label and font problems in Vennerable

2018-09-14 Thread greg holly
Hi everyone;

I am running Vennerable with 7 sets of variables. The labels are not very
clear and the font size is not very visible. Does anyone know how I can
change the label colors and font sizes?

Regards,

Greg

[[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] positive deviance plot for Binomial distribution

2019-01-28 Thread greg holly
Hi Jeff;

Thanks so much for this. I would try to reformulate what you suggested.
Your help is highly appreciated

Regards,
Greg



On Sun, Jan 27, 2019 at 8:16 PM Jeff Newmiller 
wrote:

> I haven't found much call to mess with this, but I think the built-in
> "glm" function could do it. You might have to reformulate the inputs to
> outcome/observation (ratio) and outcome+observation (weight) to get glm to
> accept it [1]... but I am not sure.  What I am somewhat more sure of is
> that your description sounds an awful lot like a q-q plot which is one of
> the standard outputs when you plot a regression model.
>
> [1]
>
> https://stats.stackexchange.com/questions/322038/input-format-for-binomial-glm-in-r
>
>
> On Fri, 25 Jan 2019, greg holly wrote:
>
> > Hi Dear all;
> >
> > I have binomially distributed data (a small portion is given below) and I
> > would like to create a distribution plot for positive deviance with
> > "Probability of results" at Y axis and "percentage of outcome" at the
> > x-axis. I wondered anyone knows the name of R  library for this.
> >
> > Regards,
> >
> > Greg
> >
> > provider outcome observation
> > 1   1427
> > 211   33
> > 39 17
> >
> >   [[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.
> >
>
> ---
> 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
> ---
>

[[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] differences between meat and metafor packages

2019-02-25 Thread greg holly
Hi all;

I have got different results (CI and Q value for heterogeneity, tau) on the
same data when I run meta and metafor for hazard ratio with a random
effects model. The basic programs for both are given below. What can cause?

Regards,
Greg

Metafor
 res <- rma(HR, SE, data=a)
predict(res, transf=exp)

Meta
 metagen(HR, SE, sm="HR", data=a)

[[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] differences between meat and metafor packages

2019-02-27 Thread greg holly
Hı Wolfgangş

I do appreciate for this info. Very helpful. And I do apologize for the
personal email. It was done mistakenly.

Regards,

Greg

On Wed, Feb 27, 2019 at 5:42 AM Viechtbauer, Wolfgang (SP) <
wolfgang.viechtba...@maastrichtuniversity.nl> wrote:

> Hi Greg,
>
> Please cc the mailing list when responding.
>
> No, this is not correct. The argument 'vi' is for the *variances*, not the
> standard errors. So, either use:
>
> res <- rma(HR, sei=SE, data=a, method="REML", slab=paste(a$study),
> digits=3)
>
> or
>
> res <- rma(HR, vi=SE^2, data=a, method="REML", slab=paste(a$study),
> digits=3)
>
> Best,
> Wolfgang
>
> -Original Message-
> From: greg holly [mailto:mak.hho...@gmail.com]
> Sent: Monday, 25 February, 2019 21:20
> To: Viechtbauer, Wolfgang (SP)
> Subject: Re: [R] differences between meat and metafor packages
>
> Hi Wolfgang;
>
> Thanks so much for this. It is much appreciated. Essentially, I run the
> following with metafor. Is not this correct? Still, should I specify sei in
> program?
>
> Regards,
> Greg.
> ### Spesify log hazard ratios and sampling variances
> a$yi <- a$HR
> a$vi <- a$SE
> ### meta-analysis based on all trials
> res <- rma(yi, vi, data=a, method="REML", slab=paste(a$study), digits=3)
>
> On Mon, Feb 25, 2019 at 1:34 PM Viechtbauer, Wolfgang (SP) <
> wolfgang.viechtba...@maastrichtuniversity.nl> wrote:
> The second argument (called 'vi') in rma() is for the variances. If you
> have SEs, then use the 'sei' argument:
>
> res <- rma(HR, sei=SE, data=a)
>
> Best,
> Wolfgang
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of greg holly
> Sent: Monday, 25 February, 2019 18:40
> To: r-help mailing list
> Subject: [R] differences between meat and metafor packages
>
> Hi all;
>
> I have got different results (CI and Q value for heterogeneity, tau) on the
> same data when I run meta and metafor for hazard ratio with a random
> effects model. The basic programs for both are given below. What can cause?
>
> Regards,
> Greg
>
> Metafor
>  res <- rma(HR, SE, data=a)
> predict(res, transf=exp)
>
> Meta
>  metagen(HR, SE, sm="HR", data=a)
>

[[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 "sufficient values in manual scale. 10 needed but only 7 provided"

2019-01-23 Thread greg holly
Hi Dear all;

I am getting the "sufficient values in manual scale. 10 needed but only 7
provided." problem when running the followings. Your help is highly
appreciated.

Regards,
Greg

p2<-p1+scale_color_manual(name="Diseases",
labels=c("Myocardial Infarction", "Coronary artery disease", "Stroke",
"Hypertension", "Depression Anxiety Emotional Problems",  "Circulatory
Problems", "Diabetes"),

values=c("Myocardial Infarction"="red",  "Coronary artery
disease"="purple","Stroke"="darkgreen",
 "Hypertension"="orange",  "Depression Anxiety Emotional
Problems"="darkblue",
 "Circulatory  Problems"="darkred","Diabetes"="blue"))

[[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] Error "sufficient values in manual scale. 10 needed but only 7 provided"

2019-01-23 Thread greg holly
Hi Jeff;

I figured out the problem. I do apologize to you and members in the list to
bother you with this simple problem.

Regards,
Greg

On Wed, Jan 23, 2019 at 6:46 PM Jeff Newmiller 
wrote:

> Problem is in your data not matching your values, but you did not share
> your data. Try using the unique() function to see what values you have in
> your data.
>
> I will say that when I want to assign discrete colors I always start by
> converting my character column in the data frame to a factor and specify
> the order I want to see the levels presented in that conversion step. Then
> the colors only need to be specified in that same order and I don't need to
> keep repeating the labels in multiple places.
>
> library(ggplot2)
>
> mpg$classf <- factor( mpg$class
>, levels = c( "2seater"
>, "subcompact"
>, "compact"
>, "midsize"
>, "minivan"
>, "suv"
>, "pickup"
>)
>)
>
> class_colours <- rainbow( length( levels( mpg$classf ) ) )
> ggplot( mpg, aes( x = classf, y = cty, colour=classf ) ) +
>  geom_boxplot() +
>  scale_colour_manual( name="Class", values = class_colours )
>
>
>
>
> On January 23, 2019 3:12:26 PM PST, greg holly 
> wrote:
> >Hi Dear all;
> >
> >I am getting the "sufficient values in manual scale. 10 needed but only
> >7
> >provided." problem when running the followings. Your help is highly
> >appreciated.
> >
> >Regards,
> >Greg
> >
> >p2<-p1+scale_color_manual(name="Diseases",
> >labels=c("Myocardial Infarction", "Coronary artery disease", "Stroke",
> >"Hypertension", "Depression Anxiety Emotional Problems",  "Circulatory
> >Problems", "Diabetes"),
> >
> >values=c("Myocardial Infarction"="red",  "Coronary artery
> >disease"="purple","Stroke"="darkgreen",
> > "Hypertension"="orange",  "Depression Anxiety Emotional
> >Problems"="darkblue",
> > "Circulatory  Problems"="darkred","Diabetes"="blue"))
> >
> >   [[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.
>
> --
> Sent from my phone. Please excuse my brevity.
>

[[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] positive deviance plot for Binomial distribution

2019-01-25 Thread greg holly
Hi Dear all;

I have binomially distributed data (a small portion is given below) and I
would like to create a distribution plot for positive deviance with
"Probability of results" at Y axis and "percentage of outcome" at the
x-axis. I wondered anyone knows the name of R  library for this.

Regards,

Greg

provider outcome observation
1   1427
211   33
39 17

[[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] Why I can not get work the "tidyverse" and "corrr" libraries

2019-04-17 Thread greg holly
;

I need work on libraries "tidyverse" and "corrr". When I cal these, I am
getting the following error message. What can be done? Your help is highly
appreciated.

Greg

Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(i,
c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
 namespace ‘rlang’ 0.3.0 is already loaded, but >= 0.3.1 is required
In addition: Warning message:
package ‘tidyverse’ was built under R version 3.5.3

[[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] problem in WRS2

2019-11-07 Thread greg holly
Hi David, Jim and Bert;

Thanks so much. Your responses are much appreciated. Here is the results
when I create a cross-tabulation from xtab(Grup~Time,cp) for the whole
data. It seems to me there is no problem. I am wondering why still I
have the
 Error in x[[grp[i]]] :
  attempt to select less than one element in get1index

ERROR when I am running the t2way(y ~ Grup*Time, data = cp)  using WRS2
package. Yours advice are highly appreciated.

Kind regards,
Greg


Time
Grup Cp0  Cp1  Cp14 Cp21 Cp28 Cp3  Cp7
1 25  25  25  25  25  25  25 175
   14.29   14.29   14.29   14.29   14.29   14.29   14.29   -
62.562.562.562.562.562.562.562.5

2 15  15  15  15  15  15  15 105
   14.29   14.29   14.29   14.29   14.29   14.29   14.29   -
37.537.537.537.537.537.537.537.5

  40  40  40  40  40  40  40 280
   14.29   14.29   14.29   14.29   14.29   14.29   14.29  100.00





On Wed, Nov 6, 2019 at 7:46 PM David Winsemius 
wrote:

> If a crosstabs on the two factors has any zero counts it might explain.
>
> —
> David
>
> Sent from my iPhone
>
> > On Nov 6, 2019, at 5:42 PM, Jim Lemon  wrote:
> >
> > Hi Greg,
> > I tried this:
> >
> > cp<-read.table(text="Birey Grup Time y
> > 11  Cp1 0.7916386
> > 11  Cp3 1.7463777
> > 11  Cp7 1.2008390
> > 11 Cp14 0.6311380
> > 11 Cp21 2.1563557
> > 11 Cp28 1.2008390",
> > header=TRUE)
> > library(prettyR)
> > xtab(Grup~Time,cp)
> > Crosstabulation of Grup by Time
> >   Time
> > Grup Cp1  Cp14 Cp21 Cp28 Cp3  Cp7
> > 1  1   1   1   1   1   1   6
> >  16.67   16.67   16.67   16.67   16.67   16.67   -
> >100 100 100 100 100 100 100
> >
> >  1   1   1   1   1   1   6
> >  16.67   16.67   16.67   16.67   16.67   16.67  100.00
> >
> > Maybe doing the same on your entire data set will reveal something.
> >
> > Jim
> >
> >> On Thu, Nov 7, 2019 at 8:58 AM greg holly  wrote:
> >>
> >> I got the following error message after running  t2way(y ~ Grup*Time,
> data
> >> = cp)
> >>  Error in x[[grp[i]]] :
> >>  attempt to select less than one element in get1index
> >>
> >> a part of the data is given below. Your help is highly appreciated.
> >>
> >> Greg
> >>
> >>> head(cp)
> >>  Birey Grup Time y
> >> 1 11  Cp1 0.7916386
> >> 2 11  Cp3 1.7463777
> >> 3 11  Cp7 1.2008390
> >> 4 11 Cp14 0.6311380
> >> 5 11 Cp21 2.1563557
> >> 6 11 Cp28 1.2008390
> >>
> >>[[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.
>
>

[[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] problem in WRS2

2019-11-07 Thread greg holly
Thanks, William. After converting Grup into the factor, I got the results.
Thanks, everyone to spend time to give their help.

Regards,
Greg

On Thu, Nov 7, 2019 at 12:02 PM William Dunlap  wrote:

> You can get this error if one of the explanatory variables is not a
> factor.  E.g.
> > WRS2::t2way(y ~ x1 * x2, data =
> expand.grid(y=11:12,x1=letters[11:13],x2=21:24))
> Error in x[[grp[i]]] :
>   attempt to select less than one element in get1index
>
> The immediate cause is that t2way uses 1:p instead of seq_len(p) when p
> may be zero, but I suspect that the code should be converting some things
> to factors so p cannot be zero.  Take this up with the package's maintainer.
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
>
> On Wed, Nov 6, 2019 at 1:58 PM greg holly  wrote:
>
>> I got the following error message after running  t2way(y ~ Grup*Time, data
>> = cp)
>>   Error in x[[grp[i]]] :
>>   attempt to select less than one element in get1index
>>
>> a part of the data is given below. Your help is highly appreciated.
>>
>> Greg
>>
>> > head(cp)
>>   Birey Grup Time y
>> 1 11  Cp1 0.7916386
>> 2 11  Cp3 1.7463777
>> 3 11  Cp7 1.2008390
>> 4 11 Cp14 0.6311380
>> 5 11 Cp21 2.1563557
>> 6 11 Cp28 1.2008390
>>
>> [[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] problem in WRS2

2019-11-06 Thread greg holly
I got the following error message after running  t2way(y ~ Grup*Time, data
= cp)
  Error in x[[grp[i]]] :
  attempt to select less than one element in get1index

a part of the data is given below. Your help is highly appreciated.

Greg

> head(cp)
  Birey Grup Time y
1 11  Cp1 0.7916386
2 11  Cp3 1.7463777
3 11  Cp7 1.2008390
4 11 Cp14 0.6311380
5 11 Cp21 2.1563557
6 11 Cp28 1.2008390

[[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: cannot allocate vector of size 6.5 Gb

2020-02-22 Thread greg holly
Dear R-Help members;

I have the following error messages when I would like to create
training and testing data for Random Forest.

Your help is highly appreciated.

Regards,
Greg

inTrain <- createDataPartition(a, p = 0.7, list = FALSE)
Error: cannot allocate vector of size 6.5 Gb

[[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] write out a complete GAM fitted model equation, using parameter estimates

2021-12-16 Thread greg holly
Hi all,

I have the following results from a study. I ran this model for binary
distributed outcome log(event/non_event). I need to write out a complete
GAM fitted model equation, using parameter estimates given below. I have
difficulty putting the parameter estimates of Spline part in the fitted
model. Your help is much appreciated.

Merry Christmas,
Oslo





Regression Model Analysis
Parameter Estimates
ParameterParameter
EstimateStandard
Errort ValuePr > |t|
Intercept -0.59214 1.47184 -0.40 0.6875
Study XX -0.53056 0.15266 -3.48 0.0005
Study YY 0 . . .
sex 1 -0.23585 0.22393 -1.05 0.2924
sex 0 0 . . .
Linear(cal_a) 0.01551 0.00718 2.16 0.0309
Linear(cal_B) -0.01627 0.00950 -1.71 0.0870
Linear(vit) 0.84962 0.17092 4.97 <.0001
Linear(mg) -2.21676 0.19107 -11.60 <.0001

Smoothing Model Analysis
Fit Summary for Smoothing Components
ComponentSmoothing
ParameterDFGCVNum
Unique
Obs
Spline(cal_a) 0.11 3.381362 3.007482 76
Spline(cal_B) 1.00 0.140625 10.741715 1201
Spline(vit) 1.00 0.01597 10.593968 43
Spline(mg) 0.60 1.673807 22.737182 36

Smoothing Model Analysis
Analysis of Deviance
SourceDFSum of SquaresChi-SquarePr > ChiSq
Spline(cal_a) 3.38136 16.148270 16.1483 0.0016
Spline(cal_B) 0.14063 0.107249 0.1072 .
Spline(vit) 0.0160 0.090490 0.0905 .
Spline(mg) 1.67381 7.585028 7.5850 0.0156

[[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] sample size for beta regression

2023-05-19 Thread greg holly
Hi all,

Does anyone have experience estimating the sample size for beta
regression? I have three treatment groups with 0.6, 0.5 and 0.3 mean of
proportions. I tried use BetaPASS but failed,

Regards,
Greg

[[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] (no subject)

2016-08-03 Thread greg holly
Hi all;


I am going to run models for variable selection using elastic-net. Because
I have about 1500 descriptive (independent) variables which they are highly
correlated. Before running elastic-net and even single regressions (~1500)
I need get fitted values for dependent variables using MIXED model. My
question is:

Should I used the fitted values or residuals as dependent variable for run
elastic-net (even single regressions which is not main purpose)?

Your helps are highly appreciated,

Greg

[[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] Predicted values VS residuals

2016-08-03 Thread greg holly
Dear all;

I am sorry for my earlier post without subject. My question in earlier mail
was:

I am going to run models for variable selection using elastic-net. Because
I have about 1500 descriptive (independent) variables which they are highly
correlated. Before running elastic-net and even single regressions (~1500)
I need get fitted values for dependent variables using MIXED model. My
question is:

Should I used the fitted values or residuals as dependent variable for run
elastic-net (even single regressions which is not main purpose)?

Your helps are highly appreciated,

Greg

[[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] Sensitivity and Specificity

2022-10-24 Thread greg holly
THanks Michael for this.This is much appreciated. So, how can I estimate
the sensitivity and  specificity after having the prediction on testing
data. Any thoughts?

Kind regards,
Greg



On Mon, Oct 24, 2022 at 12:10 PM Michael Dewey 
wrote:

> So predict is a one-dimensional vector of predictions but you are
> treating it as a two-dimensional matrix (presumably you think those are
> the totals).
>
> Michael
>
> On 24/10/2022 16:50, greg holly wrote:
> > Hi Michael,
> >
> > I appreciate your writing. Here are what I have after;
> >
> >  > predict_testing <- ifelse(predict > 0.5,1,0)
> >  >
> >  > head(predict)
> >   1  2  3  5  7  8
> > 0.29006984 0.28370507 0.10761993 0.02204224 0.12873872 0.08127920
> >  >
> >  > # Sensitivity and Specificity
> >  >
> >  >
> >
> sensitivity<-(predict_testing[2,2]/(predict_testing[2,2]+predict_testing[2,1]))*100
> > Error in predict_testing[2, 2] : incorrect number of dimensions
> >  > sensitivity
> > function (data, ...)
> > {
> >  UseMethod("sensitivity")
> > }
> > 
> > 
> >  >
> >  >
> >
> specificity<-(predict_testing[1,1]/(predict_testing[1,1]+predict_testing[1,2]))*100
> > Error in predict_testing[1, 1] : incorrect number of dimensions
> >  > specificity
> > function (data, ...)
> > {
> >  UseMethod("specificity")
> > }
> > 
> > 
> >
> > On Mon, Oct 24, 2022 at 10:45 AM Michael Dewey  > <mailto:li...@dewey.myzen.co.uk>> wrote:
> >
> > Rather hard to know without seeing what output you expected and what
> > error message you got if any but did you mean to summarise your
> > variable
> > predict before doing anything with it?
> >
> > Michael
> >
> > On 24/10/2022 16:17, greg holly wrote:
> >  > Hi all R-Help ,
> >  >
> >  > After partitioning my data to testing and training (please see
> > below), I
> >  > need to estimate the Sensitivity and Specificity. I failed. It
> > would be
> >  > appropriate to get your help.
> >  >
> >  > Best regards,
> >  > Greg
> >  >
> >  >
> >  > inTrain <- createDataPartition(y=data$case,
> >  > p=0.7,
> >  > list=FALSE)
> >  > training <- data[ inTrain,]
> >  > testing  <- data[-inTrain,]
> >  >
> >  > attach(training)
> >  > #model training and prediction
> >  > data_training <- glm(case ~ age+BMI+Calcium+Albumin+meno_1, data =
> >  > training, family = binomial(link="logit"))
> >  >
> >  > predict <- predict(data_training, data_predict = testing, type =
> > "response")
> >  >
> >  > predict_testing <- ifelse(predict > 0.5,1,0)
> >  >
> >  > # Sensitivity and Specificity
> >  >
> >  >
> >
>  
> sensitivity<-(predict_testing[2,2]/(predict_testing[2,2]+predict_testing[2,1]))*100
> >  >   sensitivity
> >  >
> >  >
> >
>  
> specificity<-(predict_testing[1,1]/(predict_testing[1,1]+predict_testing[1,2]))*100
> >  >   specificity
> >  >
> >  >   [[alternative HTML version deleted]]
> >  >
> >  > __
> >  > R-help@r-project.org <mailto:R-help@r-project.org> mailing list
> > -- To UNSUBSCRIBE and more, see
> >  > https://stat.ethz.ch/mailman/listinfo/r-help
> > <https://stat.ethz.ch/mailman/listinfo/r-help>
> >  > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > <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
> > <http://www.dewey.myzen.co.uk/home.html>
> >
> >
> > <
> http://www.avg.com/email-signature?utm_medium=email_source=link_campaign=sig-email_content=emailclient>
> Virus-free.www.avg.com <
> http://www.avg.com/email-signature?utm_medium=email_source=link_campaign=sig-email_content=emailclient
> >
> >
> > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> --
> Michael
> http://www.dewey.myzen.co.uk/home.html
>

[[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] Sensitivity and Specificity

2022-10-25 Thread greg holly
Hi Micheal, Rui, Jin and Matthias,
I appreciate your time and help. The problem has been solved with your
guides.
Kind regards,
Greg.

On Tue, Oct 25, 2022 at 12:11 AM Prof. Dr. Matthias Kohl <
matthias.k...@stamats.de> wrote:

> MKclass::perfMeasures(predict_testing, truth = testing$case, namePos = 1)
>
> should also work and computes 80 performance measures.
>
> Best Matthias
>
> Am 25.10.22 um 06:42 schrieb Jin Li:
> > Hi Greg,
> >
> > This can be done by:
> > spm::pred.acc(testing$case,  predict_testing)
> >
> > It will return both sensitivity and specificity, along with a few other
> > commonly used measures.
> >
> > Hope this helps,
> > Jin
> >
> > On Tue, Oct 25, 2022 at 6:01 AM Rui Barradas 
> wrote:
> >
> >> Às 16:50 de 24/10/2022, greg holly escreveu:
> >>> Hi Michael,
> >>>
> >>> I appreciate your writing. Here are what I have after;
> >>>
> >>>> predict_testing <- ifelse(predict > 0.5,1,0)
> >>>>
> >>>> head(predict)
> >>>1  2  3  5  7  8
> >>> 0.29006984 0.28370507 0.10761993 0.02204224 0.12873872 0.08127920
> >>>>
> >>>> # Sensitivity and Specificity
> >>>>
> >>>>
> >>>
> >>
> sensitivity<-(predict_testing[2,2]/(predict_testing[2,2]+predict_testing[2,1]))*100
> >>> Error in predict_testing[2, 2] : incorrect number of dimensions
> >>>> sensitivity
> >>> function (data, ...)
> >>> {
> >>>   UseMethod("sensitivity")
> >>> }
> >>> 
> >>> 
> >>>>
> >>>>
> >>>
> >>
> specificity<-(predict_testing[1,1]/(predict_testing[1,1]+predict_testing[1,2]))*100
> >>> Error in predict_testing[1, 1] : incorrect number of dimensions
> >>>> specificity
> >>> function (data, ...)
> >>> {
> >>>   UseMethod("specificity")
> >>> }
> >>> 
> >>> 
> >>>
> >>> On Mon, Oct 24, 2022 at 10:45 AM Michael Dewey <
> li...@dewey.myzen.co.uk>
> >>> wrote:
> >>>
> >>>> Rather hard to know without seeing what output you expected and what
> >>>> error message you got if any but did you mean to summarise your
> variable
> >>>> predict before doing anything with it?
> >>>>
> >>>> Michael
> >>>>
> >>>> On 24/10/2022 16:17, greg holly wrote:
> >>>>> Hi all R-Help ,
> >>>>>
> >>>>> After partitioning my data to testing and training (please see
> below),
> >> I
> >>>>> need to estimate the Sensitivity and Specificity. I failed. It would
> be
> >>>>> appropriate to get your help.
> >>>>>
> >>>>> Best regards,
> >>>>> Greg
> >>>>>
> >>>>>
> >>>>> inTrain <- createDataPartition(y=data$case,
> >>>>>   p=0.7,
> >>>>>   list=FALSE)
> >>>>> training <- data[ inTrain,]
> >>>>> testing  <- data[-inTrain,]
> >>>>>
> >>>>> attach(training)
> >>>>> #model training and prediction
> >>>>> data_training <- glm(case ~ age+BMI+Calcium+Albumin+meno_1, data =
> >>>>> training, family = binomial(link="logit"))
> >>>>>
> >>>>> predict <- predict(data_training, data_predict = testing, type =
> >>>> "response")
> >>>>>
> >>>>> predict_testing <- ifelse(predict > 0.5,1,0)
> >>>>>
> >>>>> # Sensitivity and Specificity
> >>>>>
> >>>>>
> >>>>
> >>
>  
> sensitivity<-(predict_testing[2,2]/(predict_testing[2,2]+predict_testing[2,1]))*100
> >>>>> sensitivity
> >>>>>
> >>>>>
> >>>>
> >>
>  
> specificity<-(predict_testing[1,1]/(predict_testing[1,1]+predict_testing[1,2]))*100
> >>>>> specificity
> >>>>>
> >>>>> [[alternative HTML version deleted]]
> >>>>>
> >>>>> _

[R] Sensitivity and Specificity

2022-10-24 Thread greg holly
Hi all R-Help ,

After partitioning my data to testing and training (please see below), I
need to estimate the Sensitivity and Specificity. I failed. It would be
appropriate to get your help.

Best regards,
Greg


inTrain <- createDataPartition(y=data$case,
   p=0.7,
   list=FALSE)
training <- data[ inTrain,]
testing  <- data[-inTrain,]

attach(training)
#model training and prediction
data_training <- glm(case ~ age+BMI+Calcium+Albumin+meno_1, data =
training, family = binomial(link="logit"))

predict <- predict(data_training, data_predict = testing, type = "response")

predict_testing <- ifelse(predict > 0.5,1,0)

# Sensitivity and Specificity

 
sensitivity<-(predict_testing[2,2]/(predict_testing[2,2]+predict_testing[2,1]))*100
 sensitivity

 
specificity<-(predict_testing[1,1]/(predict_testing[1,1]+predict_testing[1,2]))*100
 specificity

[[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] Sensitivity and Specificity

2022-10-24 Thread greg holly
Hi Michael,

I appreciate your writing. Here are what I have after;

> predict_testing <- ifelse(predict > 0.5,1,0)
>
> head(predict)
 1  2  3  5  7  8
0.29006984 0.28370507 0.10761993 0.02204224 0.12873872 0.08127920
>
> # Sensitivity and Specificity
>
>
sensitivity<-(predict_testing[2,2]/(predict_testing[2,2]+predict_testing[2,1]))*100
Error in predict_testing[2, 2] : incorrect number of dimensions
> sensitivity
function (data, ...)
{
UseMethod("sensitivity")
}


>
>
specificity<-(predict_testing[1,1]/(predict_testing[1,1]+predict_testing[1,2]))*100
Error in predict_testing[1, 1] : incorrect number of dimensions
> specificity
function (data, ...)
{
UseMethod("specificity")
}



On Mon, Oct 24, 2022 at 10:45 AM Michael Dewey 
wrote:

> Rather hard to know without seeing what output you expected and what
> error message you got if any but did you mean to summarise your variable
> predict before doing anything with it?
>
> Michael
>
> On 24/10/2022 16:17, greg holly wrote:
> > Hi all R-Help ,
> >
> > After partitioning my data to testing and training (please see below), I
> > need to estimate the Sensitivity and Specificity. I failed. It would be
> > appropriate to get your help.
> >
> > Best regards,
> > Greg
> >
> >
> > inTrain <- createDataPartition(y=data$case,
> > p=0.7,
> > list=FALSE)
> > training <- data[ inTrain,]
> > testing  <- data[-inTrain,]
> >
> > attach(training)
> > #model training and prediction
> > data_training <- glm(case ~ age+BMI+Calcium+Albumin+meno_1, data =
> > training, family = binomial(link="logit"))
> >
> > predict <- predict(data_training, data_predict = testing, type =
> "response")
> >
> > predict_testing <- ifelse(predict > 0.5,1,0)
> >
> > # Sensitivity and Specificity
> >
> >
>  
> sensitivity<-(predict_testing[2,2]/(predict_testing[2,2]+predict_testing[2,1]))*100
> >   sensitivity
> >
> >
>  
> specificity<-(predict_testing[1,1]/(predict_testing[1,1]+predict_testing[1,2]))*100
> >   specificity
> >
> >   [[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
>

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