Re: [R] Equivalent of gtools::mixedsort in R base

2018-03-11 Thread Bert Gunter
???

> y <- sort( c("a1","a2","a10","a12","a100"))
> y
[1] "a1"   "a10"  "a100" "a12"  "a2"
> mixedsort(y)
[1] "a1"   "a2"   "a10"  "a12"  "a100"

**Please read the docs!** They say that mixedsort() and mixedorder()  both
take a **single vector**  as the argument to be sorted or ordered and, as
the above indicates, they perform exactly as advertised. **Unlike
order()**. So of course your do.call() construction fails.

So presumably you have a data frame with multiple columns of mixed alpha
and numerics?  (A reproducible example would be most helpful here.)

If this is the case, one **possibly dumb** approach (you have been warned!)
would be to turn each column into an ordered factor and then call order()
on the data frame of ordered factors via do.call() as above. i.e.

> y1 <- ordered(y,lev = mixedsort(y))
> y1
[1] a1   a10  a100 a12  a2
Levels: a1 < a2 < a10 < a12 < a100
> order(y1)
[1] 1 5 2 4 3

(this is just for 1 vector to show how the idea would work).

Of course, if this is **not** what you want, you'll need to clarify,
hopefully with a reprex. Or hope that someone else has better insight than
I.

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, Mar 11, 2018 at 9:15 PM, Sebastien Bihorel <
sebastien.biho...@cognigencorp.com> wrote:

> Hi,
>
> Searching for functions that would order strings that mix characters and
> numbers in a "natural" way (ie, "a1 a2 a10" instead of "a1 a10 a2"), I
> found the mixedsort and mixedorder from the gtools package.
>
> Problems:
> 1- mixedorder does not work in a "do.call(mixedorder, mydataframe)" call
> like the order function does
> 2- gtools has not been updated in 2.5 years
>
> Are you aware of an equivalent of this function in base R or a another
> contributed package (with correction of problem #1)?
>
> Thanks
>
> __
> 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] Equivalent of gtools::mixedsort in R base

2018-03-11 Thread Sebastien Bihorel
Hi,

Searching for functions that would order strings that mix characters and 
numbers in a "natural" way (ie, "a1 a2 a10" instead of "a1 a10 a2"), I found 
the mixedsort and mixedorder from the gtools package.

Problems: 
1- mixedorder does not work in a "do.call(mixedorder, mydataframe)" call like 
the order function does
2- gtools has not been updated in 2.5 years

Are you aware of an equivalent of this function in base R or a another 
contributed package (with correction of problem #1)?

Thanks

__
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] Dataframe Subsetting comparison

2018-03-11 Thread Neha Aggarwal
Hello All,
I am facing a unique issue and am unable to find any help in R help pages
or online. I will appreciate your help for the following problem:
I have 2 data-frames, samples below and there is an expected output

R Dataframe1:
C1  C2   C3 C4.. CN
R1   0  1   0   1
R21  0  11
R31  0   0 0
.
.
.
RN

U Dataframe2 :
 C1 C2C3 C4.. CN
U1 1   101
U2 1   1 11


Expected Output:
U1 satisfies R1, R3
U2 satisfies R1, R2, R3

So this is a comparison of dataframes problem, with a subset dimension.
There are 2 dataframe R and U. column names are same. There are certain
columns belonging to each row in dataframe 1, denoted as 1s, while there
are certain cols to each U denoted as 1s in each URow in dataframe2.

I have to find relationships between Rs and Us. So i start with each U row
in U dataframe (lets say U1 row) and try to find all the rows in R
dataframe, which are subset of U1 row.

I cant find a way to compare rows to see if one is subset of
anotherwhat can I try, any pointers/ packages will be great help.
Please help.

Thanks
Neha

[[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] Subsetting comparison problem

2018-03-11 Thread Neha Aggarwal
Hello All,
I am facing a unique problem and am unable to find any help in R help pages
or online. I will appreciate your help for the following problem:
I have 2 data-frames, samples below and there is an expected output

R Dataframe1:
C1  C2   C3 C4.. CN
R1   0  1   0   1
R21  0  11
R31  0   0 0
.
.
.
RN

U Dataframe2 :
 C1 C2C3 C4.. CN
U1 1   101
U2 1   1 11


Expected Output:
U1 satisfies R1, R3
U2 satisfies R1, R2, R3

So this is a comparison of dataframes problem, with a subset dimension.
There are 2 dataframe R and U. column names are same. There are certain
columns belonging to each row in dataframe 1, denoted as 1s, while there
are certain cols to each U denoted as 1s in each URow in dataframe2.

I have to find relationships between Rs and Us. So i start with each U row
in U dataframe (lets say U1 row) and try to find all the rows in R
dataframe, which are subset of U1 row.

I cant find a way to compare rows to see if one is subset of
anotherwhat can I try, any pointers/ packages will be great help.
Please help.

Thanks
Neha

[[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: subsetting comparison problem

2018-03-11 Thread Neha Aggarwal
Hello All,
I am facing a unique problem and am unable to find any help in R help pages
or online. I will appreciate your help for the following problem:
I have 2 data-frames, samples below and there is an expected output

R Dataframe1:
C1  C2   C3 C4.. CN
R1   0  1   0   1
R21  0  11
R31  0   0 0
.
.
.
RN

U Dataframe2 :
 C1 C2C3 C4.. CN
U1 1   101
U2 1   1 11


Expected Output:
U1 satisfies R1, R3
U2 satisfies R1, R2, R3

So this is a comparison of dataframes problem, with a subset dimension.
There are 2 dataframe R and U. column names are same. There are certain
columns belonging to each row in dataframe 1, denoted as 1s, while there
are certain cols to each U denoted as 1s in each URow in dataframe2.

I have to find relationships between Rs and Us. So i start with each U row
in U dataframe (lets say U1 row) and try to find all the rows in R
dataframe, which are subset of U1 row.

I cant find a way to compare rows to see if one is subset of
anotherwhat can I try, any pointers/ packages will be great help.
Please help.

Thanks
Neha

[[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] subsetting comparison problem

2018-03-11 Thread Jim Lemon
Hi Neha,
This might help:

R<-read.table(text="C1 C2 C3 C4
R1 0 1 0 1
R2 1 0 1 1
R3 1 0 0 0",
header=TRUE)
U<-read.table(text="C1 C2 C3 C4
U1 1 1 0 1
U2 1 1 1 1",
header=TRUE)
# these are matrices - I think this will work for dataframes as well
for(ui in 1:dim(U)[1]) {
 for(ri in 1:dim(R)[1]) {
  if(sum(U[ui,][ri,])==sum(R[ri,]))
   cat("R$",rownames(R)[ri]," subset of ","U$",rownames(U)[ui],"\n",sep="")
 }
}

Jim

On Mon, Mar 12, 2018 at 1:59 PM, David Winsemius  wrote:
>
>> On Mar 11, 2018, at 3:32 PM, Neha Aggarwal  
>> wrote:
>>
>> Hello All,
>> I am facing a unique problem and am unable to find any help in R help pages
>> or online. I will appreciate your help for the following problem:
>> I have 2 data-frames, samples below and there is an expected output
>>
>> R Dataframe1:
>>C1  C2   C3 C4.. CN
>> R1   0  1   0   1
>> R21  0  11
>> R31  0   0 0
>> .
>> .
>> .
>> RN
>>
>> U Dataframe2 :
>> C1 C2C3 C4.. CN
>> U1 1   101
>> U2 1   1 11
>>
>>
>> Expected Output:
>> U1 satisfies R1, R3
>> U2 satisfies R1, R2, R3
>>
>
> I don't think you have communicated what sort of meaning is attached to the 
> word "satisfies".
>
> Here's a double loop that reports membership of the column names of each row 
> of U (Dataframe2) in each row of R (Dataframe1):
>
>  apply( Dataframe2, 1, function(x){ z <- which(x==1);
>z2 <- names(x)[z];
> zlist=apply(Dataframe1, 1, function(y){ z3 <- 
> which(y==1);
> z4 <- 
> names(y)[z3];
> z4[ which(z4 
> %in% z2) ]});
> zlist})
> $U1
> $U1$R1
> [1] "C2" "C4"
>
> $U1$R2
> [1] "C1" "C4"
>
> $U1$R3
> [1] "C1"
>
>
> $U2
> $U2$R1
> [1] "C2" "C4"
>
> $U2$R2
> [1] "C1" "C3" "C4"
>
> $U2$R3
> [1] "C1"
>
> --
> David.
>
>
>> So this is a comparison of dataframes problem, with a subset dimension.
>> There are 2 dataframe R and U. column names are same. There are certain
>> columns belonging to each row in dataframe 1, denoted as 1s, while there
>> are certain cols to each U denoted as 1s in each URow in dataframe2.
>>
>> I have to find relationships between Rs and Us. So i start with each U row
>> in U dataframe (lets say U1 row) and try to find all the rows in R
>> dataframe, which are subset of U1 row.
>>
>> I cant find a way to compare rows to see if one is subset of
>> anotherwhat can I try, any pointers/ packages will be great help.
>> Please help.
>>
>> Thanks
>> Neha
>>
>>   [[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.
>
> David Winsemius
> Alameda, CA, USA
>
> 'Any technology distinguishable from magic is insufficiently advanced.'   
> -Gehm's Corollary to Clarke's Third Law
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Empirical density estimation

2018-03-11 Thread Jeff Newmiller

cwhmisc package provides essentially the algorithm outlined by Dan.

If you want answers outside your original data (extrapolation) then the 
following code at least won't give broken answers, though it is not 
necessarily any more "correct" for extrapolation than the approx solution 
is.


Regarding "needing this for reporting", do thoroughly read ?density as 
Bert suggested, because the bandwidth parameter affects your answers and 
there are various historical recommendations for choosing possible 
bandwidth values, and really no "right" answer.



smoothed.df2 <- function ( d ) {
F <- cumsum( d$y )
F <- F / F[ length( F ) ] * ( length( F ) - 0.5 ) / length( F )
eF <- splinefun( d$x, qlogis( F ), "monoH.FC" )
function( x ) {
efx <- eF( x )
plogis( efx )
}
}

set.seed( 42 )
Dat <- c( rnorm( 100, 1 ), rnorm( 100, 5 ) )

d <- density( Dat )

CDF1 <- cwhmisc::smoothed.df( d )
plot( Dat, CDF1( Dat ) )

CDF2 <- smoothed.df2( d )
plot( Dat, CDF2( Dat ) )

CDF1( -5 ) # <0
CDF2( -5 ) # >0


On Sun, 11 Mar 2018, Daniel Nordlund wrote:


On 3/11/2018 3:35 PM, Christofer Bogaso wrote:

But for my reporting purpose, I need to generate a bell curve like
plot based on empirical PDF, that also contains original points.

Any idea would be helpful. Thanks,




Christofer,

something like the following may get you what you want:

## get the kernel density estimate
dens <- density(Dat)

## estimate the density at your original points
dnew <- approx(dens$x,dens$y,xout=Dat)

## plot kernel density estimate
plot(dx)

## add your original values with the estimated density
points(dnew, pch=1, cex=0.5, col="red")


Hope this is helpful,

Dan

--
Daniel Nordlund
Port Townsend, WA  USA

On Mon, Mar 12, 2018 at 3:49 AM, Bert Gunter  
wrote:
You need to re-read ?density and perhaps think again -- or do some study 
--

about how a (kernel) density estimate works. The points at which the
estimate is calculated are *not* the values given, nor should they be!

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, Mar 11, 2018 at 11:45 AM, Christofer Bogaso
 wrote:


Hi,

Let say I have below vector of data-points :

Dat = c(-0.444, -0.25, -0.237449799196787, 
-0.227467046669042,


-0.227454464682363, -0.22, -0.214876033057851, -0.211781206171108,

-0.199891067538126, -0.192920353982301, -0.192307692307692,
-0.186046511627907,

-0.184418145956608, -0.181818181818182, -0.181818181818182,
-0.181266261925412,

-0.181003118503119, -0.179064587973274, -0.178217821782178,
-0.17809021675454,

-0.177685950413223, -0.177570093457944, -0.176470588235294,
-0.176470588235294,

-0.174825741611282, -0.168021680216802, -0.167,
-0.167,

-0.166380789022298, -0.164209115281501, -0.164011246485473,
-0.162689804772234,

-0.162361623616236, -0.160161507402423, -0.16, -0.155038759689922,

-0.154172560113154, -0.15311004784689, -0.151515151515152,
-0.151462994836489,

-0.151098901098901, -0.150537634408602, -0.150442477876106,
-0.150406504065041,

-0.149904214559387, -0.149882903981265, -0.149797570850202,
-0.148496240601504,

-0.148325358851675, -0.147540983606557, -0.147239263803681,
-0.146989966555184,

-0.14622641509434, -0.146095717884131, -0.145994832041344,
-0.14572864321608,

-0.145161290322581, -0.144292237442922, -0.144144144144144,
-0.144021739130435,

-0.14375, -0.142212189616253, -0.141122913505311, -0.140324963072378,

-0.139344262295082, -0.13884007029877, -0.138356164383562,
-0.137626262626263,

-0.137142857142857, -0.136690647482014, -0.136577708006279,
-0.136363636363636,

-0.136094674556213, -0.135879774577332, -0.135586319218241,
-0.135135135135135,

-0.132780082987552, -0.132209405501331, -0.132023755139333,
-0.131233595800525,

-0.130434782608696, -0.130434782608696, -0.130268199233717,
-0.128813559322034,

-0.1284046692607, -0.128205128205128, -0.128182616330114,
-0.127937336814621,

-0.126283367556468, -0.125853658536585, -0.125448028673835,
-0.125425564840607,

-0.125311203319502, -0.125, -0.124401913875598, -0.124248496993988,

-0.124031007751938, -0.123572170301142, -0.123188405797102,
-0.122905027932961,

-0.1216667, -0.121573685907772, -0.120658135283364,
-0.120540019286403,

-0.119858156028369, -0.11965811965812, -0.11965811965812,
-0.119565217391304,

-0.118942731277533, -0.117820324005891, -0.116257947320618,
-0.115789473684211,

-0.115683584819387, -0.115384615384615, -0.115281501340483,
-0.114492753623188,

-0.114357262103506, -0.114285714285714, -0.114035087719298,
-0.113181972212809,

-0.112790697674419, -0.112781954887218, -0.112195121951219,
-0.112191473448018,

-0.111, -0.111, -0.110813226094727,
-0.110384300899428,

-0.110147441457069, -0.110137672090113, -0.109913793103448,

Re: [R] subsetting comparison problem

2018-03-11 Thread David Winsemius

> On Mar 11, 2018, at 3:32 PM, Neha Aggarwal  wrote:
> 
> Hello All,
> I am facing a unique problem and am unable to find any help in R help pages
> or online. I will appreciate your help for the following problem:
> I have 2 data-frames, samples below and there is an expected output
> 
> R Dataframe1:
>C1  C2   C3 C4.. CN
> R1   0  1   0   1
> R21  0  11
> R31  0   0 0
> .
> .
> .
> RN
> 
> U Dataframe2 :
> C1 C2C3 C4.. CN
> U1 1   101
> U2 1   1 11
> 
> 
> Expected Output:
> U1 satisfies R1, R3
> U2 satisfies R1, R2, R3
> 

I don't think you have communicated what sort of meaning is attached to the 
word "satisfies".

Here's a double loop that reports membership of the column names of each row of 
U (Dataframe2) in each row of R (Dataframe1):

 apply( Dataframe2, 1, function(x){ z <- which(x==1);
   z2 <- names(x)[z];  
zlist=apply(Dataframe1, 1, function(y){ z3 <- 
which(y==1); 
z4 <- 
names(y)[z3]; 
z4[ which(z4 
%in% z2) ]}); 
zlist})
$U1
$U1$R1
[1] "C2" "C4"

$U1$R2
[1] "C1" "C4"

$U1$R3
[1] "C1"


$U2
$U2$R1
[1] "C2" "C4"

$U2$R2
[1] "C1" "C3" "C4"

$U2$R3
[1] "C1"

-- 
David.


> So this is a comparison of dataframes problem, with a subset dimension.
> There are 2 dataframe R and U. column names are same. There are certain
> columns belonging to each row in dataframe 1, denoted as 1s, while there
> are certain cols to each U denoted as 1s in each URow in dataframe2.
> 
> I have to find relationships between Rs and Us. So i start with each U row
> in U dataframe (lets say U1 row) and try to find all the rows in R
> dataframe, which are subset of U1 row.
> 
> I cant find a way to compare rows to see if one is subset of
> anotherwhat can I try, any pointers/ packages will be great help.
> Please help.
> 
> Thanks
> Neha
> 
>   [[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.

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law

__
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] subsetting comparison problem

2018-03-11 Thread Jeff Newmiller

Responses inline.

On Sun, 11 Mar 2018, Neha Aggarwal wrote:


Hello All,
I am facing a unique problem and am unable to find any help in R help pages
or online. I will appreciate your help for the following problem:
I have 2 data-frames, samples below and there is an expected output

R Dataframe1:
   C1  C2   C3 C4.. CN
R1   0  1   0   1
R21  0  11
R31  0   0 0
.
.
.
RN

U Dataframe2 :
C1 C2C3 C4.. CN
U1 1   101
U2 1   1 11


Expected Output:
U1 satisfies R1, R3
U2 satisfies R1, R2, R3

So this is a comparison of dataframes problem, with a subset dimension.
There are 2 dataframe R and U. column names are same. There are certain
columns belonging to each row in dataframe 1, denoted as 1s, while there
are certain cols to each U denoted as 1s in each URow in dataframe2.

I have to find relationships between Rs and Us. So i start with each U row
in U dataframe (lets say U1 row) and try to find all the rows in R
dataframe, which are subset of U1 row.

I cant find a way to compare rows to see if one is subset of
anotherwhat can I try, any pointers/ packages will be great help.
Please help.

Thanks
Neha

[[alternative HTML version deleted]]


As the Posting Guide says (you have read it, haven't you?), please post 
plain text... the mailing list mangles your code with varying levels of 
damage as it tries to fix this problem for you. It also helps if you can 
pose your question in R code rather than pseudo-code and formatted data 
tables.


Your problem appears to be an outer join of binary subsets... I don't 
think this is a very common problem structure (in most cases you want to 
avoid outer joins if you can because they are computationally expensive), 
but you can read ?outer and ?expand.grid to see some ways to pair up all 
possible row indexes.  If you know that the number of rows in both inputs 
is <32, this problem can be optimized for speed and memory with the bitops 
package, or for larger size problems you can use the bit package. The 
below code shows the skeleton of logic with no such optimizations, and is 
likely the most practical solution for a one-off analysis:


##
r <- read.table( text=
" C1   C2  C3  C4
R10 1   0   1
R21 0   1   1
R31 0   0   0
", header=TRUE )

u <- read.table( text=
"   C1  C2  C3  C4
U1  1   1   0   1
U2  1   1   1   1
", header=TRUE )

rmx <- as.matrix( r )
umx <- as.matrix( u )

result <- expand.grid( R = rownames( rmx )
 , U = rownames( umx )
 )

# see how:
1L - umx[ U, ]  # 1 for every 0 in u
rmx[ R, ]   # 1 for every 1 in r
( 1L - umx[ U, ] ) * rmx[ R, ] # 1 where both have 1

# do it:
# for every row, 0 where both conditions are true in any column
result$IN <- 1L - with( result
  , apply(   ( 1L - umx[ U, ] ) # any 0 column
   * rmx[ R, ]  # any 1 column
 , 1  # by rows
 , max
 )
  )
result
# show key pairings only
result[ as.logical( result$IN ), c( "U", "R" ) ]
##

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

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


Re: [R] Empirical density estimation

2018-03-11 Thread Daniel Nordlund

On 3/11/2018 3:35 PM, Christofer Bogaso wrote:

But for my reporting purpose, I need to generate a bell curve like
plot based on empirical PDF, that also contains original points.

Any idea would be helpful. Thanks,




Christofer,

something like the following may get you what you want:

## get the kernel density estimate
dens <- density(Dat)

## estimate the density at your original points
dnew <- approx(dens$x,dens$y,xout=Dat)

## plot kernel density estimate
plot(dx)

## add your original values with the estimated density
points(dnew, pch=1, cex=0.5, col="red")


Hope this is helpful,

Dan

--
Daniel Nordlund
Port Townsend, WA  USA


On Mon, Mar 12, 2018 at 3:49 AM, Bert Gunter  wrote:

You need to re-read ?density and perhaps think again -- or do some study --
about how a (kernel) density estimate works. The points at which the
estimate is calculated are *not* the values given, nor should they be!

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, Mar 11, 2018 at 11:45 AM, Christofer Bogaso
 wrote:


Hi,

Let say I have below vector of data-points :

Dat = c(-0.444, -0.25, -0.237449799196787, -0.227467046669042,

-0.227454464682363, -0.22, -0.214876033057851, -0.211781206171108,

-0.199891067538126, -0.192920353982301, -0.192307692307692,
-0.186046511627907,

-0.184418145956608, -0.181818181818182, -0.181818181818182,
-0.181266261925412,

-0.181003118503119, -0.179064587973274, -0.178217821782178,
-0.17809021675454,

-0.177685950413223, -0.177570093457944, -0.176470588235294,
-0.176470588235294,

-0.174825741611282, -0.168021680216802, -0.167,
-0.167,

-0.166380789022298, -0.164209115281501, -0.164011246485473,
-0.162689804772234,

-0.162361623616236, -0.160161507402423, -0.16, -0.155038759689922,

-0.154172560113154, -0.15311004784689, -0.151515151515152,
-0.151462994836489,

-0.151098901098901, -0.150537634408602, -0.150442477876106,
-0.150406504065041,

-0.149904214559387, -0.149882903981265, -0.149797570850202,
-0.148496240601504,

-0.148325358851675, -0.147540983606557, -0.147239263803681,
-0.146989966555184,

-0.14622641509434, -0.146095717884131, -0.145994832041344,
-0.14572864321608,

-0.145161290322581, -0.144292237442922, -0.144144144144144,
-0.144021739130435,

-0.14375, -0.142212189616253, -0.141122913505311, -0.140324963072378,

-0.139344262295082, -0.13884007029877, -0.138356164383562,
-0.137626262626263,

-0.137142857142857, -0.136690647482014, -0.136577708006279,
-0.136363636363636,

-0.136094674556213, -0.135879774577332, -0.135586319218241,
-0.135135135135135,

-0.132780082987552, -0.132209405501331, -0.132023755139333,
-0.131233595800525,

-0.130434782608696, -0.130434782608696, -0.130268199233717,
-0.128813559322034,

-0.1284046692607, -0.128205128205128, -0.128182616330114,
-0.127937336814621,

-0.126283367556468, -0.125853658536585, -0.125448028673835,
-0.125425564840607,

-0.125311203319502, -0.125, -0.124401913875598, -0.124248496993988,

-0.124031007751938, -0.123572170301142, -0.123188405797102,
-0.122905027932961,

-0.1216667, -0.121573685907772, -0.120658135283364,
-0.120540019286403,

-0.119858156028369, -0.11965811965812, -0.11965811965812,
-0.119565217391304,

-0.118942731277533, -0.117820324005891, -0.116257947320618,
-0.115789473684211,

-0.115683584819387, -0.115384615384615, -0.115281501340483,
-0.114492753623188,

-0.114357262103506, -0.114285714285714, -0.114035087719298,
-0.113181972212809,

-0.112790697674419, -0.112781954887218, -0.112195121951219,
-0.112191473448018,

-0.111, -0.111, -0.110813226094727,
-0.110384300899428,

-0.110147441457069, -0.110137672090113, -0.109913793103448,
-0.109792284866469,

-0.109375, -0.10919540229885, -0.109112709832134, -0.10844250363901,

-0.107776617954071, -0.10752688172043, -0.107317073170732,
-0.106674272675414,

-0.106382978723404, -0.106100795755968, -0.106060606060606,
-0.10595160235448,

-0.105742474070326, -0.105263157894737, -0.104454685099846,
-0.104283054003724,

-0.103916449086162, -0.103723404255319, -0.103448275862069,
-0.102737680438029,

-0.10267471958585, -0.101696871753434, -0.100893997445721,
-0.10041265474553,

-0.100042983021706, -0.1, -0.0995111731843576, -0.099502487562189,

-0.0994117647058824, -0.0991561181434598, -0.0989492119089317,

-0.0988372093023255, -0.0983908045977012, -0.0983050847457627,

-0.0977198697068404, -0.0974702380952382, -0.0973819695475956,

-0.097345132743363, -0.0971472629144179, -0.0971438645980254,

-0.0961538461538461, -0.096062667491239, -0.0957347238935687,

-0.0956521739130435, -0.0954773869346733, -0.0954115076474873,

-0.0952380952380952, -0.0951115834218915, -0.0950642007303569,

-0.0949423247559894, -0.0947368421052631, -0.0946291560102303,

-0.0945220193340494, -0.0944309927360775, 

[R] subsetting comparison problem

2018-03-11 Thread Neha Aggarwal
Hello All,
I am facing a unique problem and am unable to find any help in R help pages
or online. I will appreciate your help for the following problem:
I have 2 data-frames, samples below and there is an expected output

R Dataframe1:
C1  C2   C3 C4.. CN
R1   0  1   0   1
R21  0  11
R31  0   0 0
.
.
.
RN

U Dataframe2 :
 C1 C2C3 C4.. CN
U1 1   101
U2 1   1 11


Expected Output:
U1 satisfies R1, R3
U2 satisfies R1, R2, R3

So this is a comparison of dataframes problem, with a subset dimension.
There are 2 dataframe R and U. column names are same. There are certain
columns belonging to each row in dataframe 1, denoted as 1s, while there
are certain cols to each U denoted as 1s in each URow in dataframe2.

I have to find relationships between Rs and Us. So i start with each U row
in U dataframe (lets say U1 row) and try to find all the rows in R
dataframe, which are subset of U1 row.

I cant find a way to compare rows to see if one is subset of
anotherwhat can I try, any pointers/ packages will be great help.
Please help.

Thanks
Neha

[[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] Empirical density estimation

2018-03-11 Thread Christofer Bogaso
But for my reporting purpose, I need to generate a bell curve like
plot based on empirical PDF, that also contains original points.

Any idea would be helpful. Thanks,

On Mon, Mar 12, 2018 at 3:49 AM, Bert Gunter  wrote:
> You need to re-read ?density and perhaps think again -- or do some study --
> about how a (kernel) density estimate works. The points at which the
> estimate is calculated are *not* the values given, nor should they be!
>
> 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, Mar 11, 2018 at 11:45 AM, Christofer Bogaso
>  wrote:
>>
>> Hi,
>>
>> Let say I have below vector of data-points :
>>
>> Dat = c(-0.444, -0.25, -0.237449799196787, -0.227467046669042,
>>
>> -0.227454464682363, -0.22, -0.214876033057851, -0.211781206171108,
>>
>> -0.199891067538126, -0.192920353982301, -0.192307692307692,
>> -0.186046511627907,
>>
>> -0.184418145956608, -0.181818181818182, -0.181818181818182,
>> -0.181266261925412,
>>
>> -0.181003118503119, -0.179064587973274, -0.178217821782178,
>> -0.17809021675454,
>>
>> -0.177685950413223, -0.177570093457944, -0.176470588235294,
>> -0.176470588235294,
>>
>> -0.174825741611282, -0.168021680216802, -0.167,
>> -0.167,
>>
>> -0.166380789022298, -0.164209115281501, -0.164011246485473,
>> -0.162689804772234,
>>
>> -0.162361623616236, -0.160161507402423, -0.16, -0.155038759689922,
>>
>> -0.154172560113154, -0.15311004784689, -0.151515151515152,
>> -0.151462994836489,
>>
>> -0.151098901098901, -0.150537634408602, -0.150442477876106,
>> -0.150406504065041,
>>
>> -0.149904214559387, -0.149882903981265, -0.149797570850202,
>> -0.148496240601504,
>>
>> -0.148325358851675, -0.147540983606557, -0.147239263803681,
>> -0.146989966555184,
>>
>> -0.14622641509434, -0.146095717884131, -0.145994832041344,
>> -0.14572864321608,
>>
>> -0.145161290322581, -0.144292237442922, -0.144144144144144,
>> -0.144021739130435,
>>
>> -0.14375, -0.142212189616253, -0.141122913505311, -0.140324963072378,
>>
>> -0.139344262295082, -0.13884007029877, -0.138356164383562,
>> -0.137626262626263,
>>
>> -0.137142857142857, -0.136690647482014, -0.136577708006279,
>> -0.136363636363636,
>>
>> -0.136094674556213, -0.135879774577332, -0.135586319218241,
>> -0.135135135135135,
>>
>> -0.132780082987552, -0.132209405501331, -0.132023755139333,
>> -0.131233595800525,
>>
>> -0.130434782608696, -0.130434782608696, -0.130268199233717,
>> -0.128813559322034,
>>
>> -0.1284046692607, -0.128205128205128, -0.128182616330114,
>> -0.127937336814621,
>>
>> -0.126283367556468, -0.125853658536585, -0.125448028673835,
>> -0.125425564840607,
>>
>> -0.125311203319502, -0.125, -0.124401913875598, -0.124248496993988,
>>
>> -0.124031007751938, -0.123572170301142, -0.123188405797102,
>> -0.122905027932961,
>>
>> -0.1216667, -0.121573685907772, -0.120658135283364,
>> -0.120540019286403,
>>
>> -0.119858156028369, -0.11965811965812, -0.11965811965812,
>> -0.119565217391304,
>>
>> -0.118942731277533, -0.117820324005891, -0.116257947320618,
>> -0.115789473684211,
>>
>> -0.115683584819387, -0.115384615384615, -0.115281501340483,
>> -0.114492753623188,
>>
>> -0.114357262103506, -0.114285714285714, -0.114035087719298,
>> -0.113181972212809,
>>
>> -0.112790697674419, -0.112781954887218, -0.112195121951219,
>> -0.112191473448018,
>>
>> -0.111, -0.111, -0.110813226094727,
>> -0.110384300899428,
>>
>> -0.110147441457069, -0.110137672090113, -0.109913793103448,
>> -0.109792284866469,
>>
>> -0.109375, -0.10919540229885, -0.109112709832134, -0.10844250363901,
>>
>> -0.107776617954071, -0.10752688172043, -0.107317073170732,
>> -0.106674272675414,
>>
>> -0.106382978723404, -0.106100795755968, -0.106060606060606,
>> -0.10595160235448,
>>
>> -0.105742474070326, -0.105263157894737, -0.104454685099846,
>> -0.104283054003724,
>>
>> -0.103916449086162, -0.103723404255319, -0.103448275862069,
>> -0.102737680438029,
>>
>> -0.10267471958585, -0.101696871753434, -0.100893997445721,
>> -0.10041265474553,
>>
>> -0.100042983021706, -0.1, -0.0995111731843576, -0.099502487562189,
>>
>> -0.0994117647058824, -0.0991561181434598, -0.0989492119089317,
>>
>> -0.0988372093023255, -0.0983908045977012, -0.0983050847457627,
>>
>> -0.0977198697068404, -0.0974702380952382, -0.0973819695475956,
>>
>> -0.097345132743363, -0.0971472629144179, -0.0971438645980254,
>>
>> -0.0961538461538461, -0.096062667491239, -0.0957347238935687,
>>
>> -0.0956521739130435, -0.0954773869346733, -0.0954115076474873,
>>
>> -0.0952380952380952, -0.0951115834218915, -0.0950642007303569,
>>
>> -0.0949423247559894, -0.0947368421052631, -0.0946291560102303,
>>
>> -0.0945220193340494, -0.0944309927360775, -0.0943016759776536,
>>
>> -0.0942720763723149, -0.0941770647653002, -0.0940298507462686,
>>
>> 

Re: [R] Empirical density estimation

2018-03-11 Thread Jim Lemon
Hi Christofer,
You may be looking for ecdf (stats) for a start, then working out a
way to translate the cumulative density values into probability
values.

Jim


On Mon, Mar 12, 2018 at 5:45 AM, Christofer Bogaso
 wrote:
> Hi,
>
> Let say I have below vector of data-points :
>
> Dat = c(-0.444, -0.25, -0.237449799196787, -0.227467046669042,
>
> -0.227454464682363, -0.22, -0.214876033057851, -0.211781206171108,
>
> -0.199891067538126, -0.192920353982301, -0.192307692307692, 
> -0.186046511627907,
>
> -0.184418145956608, -0.181818181818182, -0.181818181818182, 
> -0.181266261925412,
>
> -0.181003118503119, -0.179064587973274, -0.178217821782178, -0.17809021675454,
>
> -0.177685950413223, -0.177570093457944, -0.176470588235294, 
> -0.176470588235294,
>
> -0.174825741611282, -0.168021680216802, -0.167, 
> -0.167,
>
> -0.166380789022298, -0.164209115281501, -0.164011246485473, 
> -0.162689804772234,
>
> -0.162361623616236, -0.160161507402423, -0.16, -0.155038759689922,
>
> -0.154172560113154, -0.15311004784689, -0.151515151515152, -0.151462994836489,
>
> -0.151098901098901, -0.150537634408602, -0.150442477876106, 
> -0.150406504065041,
>
> -0.149904214559387, -0.149882903981265, -0.149797570850202, 
> -0.148496240601504,
>
> -0.148325358851675, -0.147540983606557, -0.147239263803681, 
> -0.146989966555184,
>
> -0.14622641509434, -0.146095717884131, -0.145994832041344, -0.14572864321608,
>
> -0.145161290322581, -0.144292237442922, -0.144144144144144, 
> -0.144021739130435,
>
> -0.14375, -0.142212189616253, -0.141122913505311, -0.140324963072378,
>
> -0.139344262295082, -0.13884007029877, -0.138356164383562, -0.137626262626263,
>
> -0.137142857142857, -0.136690647482014, -0.136577708006279, 
> -0.136363636363636,
>
> -0.136094674556213, -0.135879774577332, -0.135586319218241, 
> -0.135135135135135,
>
> -0.132780082987552, -0.132209405501331, -0.132023755139333, 
> -0.131233595800525,
>
> -0.130434782608696, -0.130434782608696, -0.130268199233717, 
> -0.128813559322034,
>
> -0.1284046692607, -0.128205128205128, -0.128182616330114, -0.127937336814621,
>
> -0.126283367556468, -0.125853658536585, -0.125448028673835, 
> -0.125425564840607,
>
> -0.125311203319502, -0.125, -0.124401913875598, -0.124248496993988,
>
> -0.124031007751938, -0.123572170301142, -0.123188405797102, 
> -0.122905027932961,
>
> -0.1216667, -0.121573685907772, -0.120658135283364, 
> -0.120540019286403,
>
> -0.119858156028369, -0.11965811965812, -0.11965811965812, -0.119565217391304,
>
> -0.118942731277533, -0.117820324005891, -0.116257947320618, 
> -0.115789473684211,
>
> -0.115683584819387, -0.115384615384615, -0.115281501340483, 
> -0.114492753623188,
>
> -0.114357262103506, -0.114285714285714, -0.114035087719298, 
> -0.113181972212809,
>
> -0.112790697674419, -0.112781954887218, -0.112195121951219, 
> -0.112191473448018,
>
> -0.111, -0.111, -0.110813226094727, 
> -0.110384300899428,
>
> -0.110147441457069, -0.110137672090113, -0.109913793103448, 
> -0.109792284866469,
>
> -0.109375, -0.10919540229885, -0.109112709832134, -0.10844250363901,
>
> -0.107776617954071, -0.10752688172043, -0.107317073170732, -0.106674272675414,
>
> -0.106382978723404, -0.106100795755968, -0.106060606060606, -0.10595160235448,
>
> -0.105742474070326, -0.105263157894737, -0.104454685099846, 
> -0.104283054003724,
>
> -0.103916449086162, -0.103723404255319, -0.103448275862069, 
> -0.102737680438029,
>
> -0.10267471958585, -0.101696871753434, -0.100893997445721, -0.10041265474553,
>
> -0.100042983021706, -0.1, -0.0995111731843576, -0.099502487562189,
>
> -0.0994117647058824, -0.0991561181434598, -0.0989492119089317,
>
> -0.0988372093023255, -0.0983908045977012, -0.0983050847457627,
>
> -0.0977198697068404, -0.0974702380952382, -0.0973819695475956,
>
> -0.097345132743363, -0.0971472629144179, -0.0971438645980254,
>
> -0.0961538461538461, -0.096062667491239, -0.0957347238935687,
>
> -0.0956521739130435, -0.0954773869346733, -0.0954115076474873,
>
> -0.0952380952380952, -0.0951115834218915, -0.0950642007303569,
>
> -0.0949423247559894, -0.0947368421052631, -0.0946291560102303,
>
> -0.0945220193340494, -0.0944309927360775, -0.0943016759776536,
>
> -0.0942720763723149, -0.0941770647653002, -0.0940298507462686,
>
> -0.094017094017094, -0.0935672514619884, -0.0934579439252337,
>
> -0.0930232558139535, -0.0929772502472798, -0.0929054054054054,
>
> -0.0928778745255637, -0.0927700348432055, -0.0925266903914591,
>
> -0.0922502666192677, -0.0918094218415418, -0.0915254237288135,
>
> -0.0914774596906876, -0.0914662894860915, -0.0914285714285715,
>
> -0.0912322274881517, -0.090909090909091, -0.0909090909090909,
>
> -0.09079754601227, -0.0907071455016661, -0.0906593406593406,
>
> -0.0903614457831325, -0.0903323548906352, -0.09, -0.0897243107769424,
>
> -0.0896358543417368, -0.0895522388059702, -0.0895052902487847,
>
> -0.0891719745222929, -0.0888, -0.0887227819304518,
>
> 

Re: [R] Empirical density estimation

2018-03-11 Thread Bert Gunter
You need to re-read ?density and perhaps think again -- or do some study --
about how a (kernel) density estimate works. The points at which the
estimate is calculated are *not* the values given, nor should they be!

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, Mar 11, 2018 at 11:45 AM, Christofer Bogaso <
bogaso.christo...@gmail.com> wrote:

> Hi,
>
> Let say I have below vector of data-points :
>
> Dat = c(-0.444, -0.25, -0.237449799196787, -0.227467046669042,
>
> -0.227454464682363, -0.22, -0.214876033057851, -0.211781206171108,
>
> -0.199891067538126, -0.192920353982301, -0.192307692307692,
> -0.186046511627907,
>
> -0.184418145956608, -0.181818181818182, -0.181818181818182,
> -0.181266261925412,
>
> -0.181003118503119, -0.179064587973274, -0.178217821782178,
> -0.17809021675454,
>
> -0.177685950413223, -0.177570093457944, -0.176470588235294,
> -0.176470588235294,
>
> -0.174825741611282, -0.168021680216802, -0.167,
> -0.167,
>
> -0.166380789022298, -0.164209115281501, -0.164011246485473,
> -0.162689804772234,
>
> -0.162361623616236, -0.160161507402423, -0.16, -0.155038759689922,
>
> -0.154172560113154, -0.15311004784689, -0.151515151515152,
> -0.151462994836489,
>
> -0.151098901098901, -0.150537634408602, -0.150442477876106,
> -0.150406504065041,
>
> -0.149904214559387, -0.149882903981265, -0.149797570850202,
> -0.148496240601504,
>
> -0.148325358851675, -0.147540983606557, -0.147239263803681,
> -0.146989966555184,
>
> -0.14622641509434, -0.146095717884131, -0.145994832041344,
> -0.14572864321608,
>
> -0.145161290322581, -0.144292237442922, -0.144144144144144,
> -0.144021739130435,
>
> -0.14375, -0.142212189616253, -0.141122913505311, -0.140324963072378,
>
> -0.139344262295082, -0.13884007029877, -0.138356164383562,
> -0.137626262626263,
>
> -0.137142857142857, -0.136690647482014, -0.136577708006279,
> -0.136363636363636,
>
> -0.136094674556213, -0.135879774577332, -0.135586319218241,
> -0.135135135135135,
>
> -0.132780082987552, -0.132209405501331, -0.132023755139333,
> -0.131233595800525,
>
> -0.130434782608696, -0.130434782608696, -0.130268199233717,
> -0.128813559322034,
>
> -0.1284046692607, -0.128205128205128, -0.128182616330114,
> -0.127937336814621,
>
> -0.126283367556468, -0.125853658536585, -0.125448028673835,
> -0.125425564840607,
>
> -0.125311203319502, -0.125, -0.124401913875598, -0.124248496993988,
>
> -0.124031007751938, -0.123572170301142, -0.123188405797102,
> -0.122905027932961,
>
> -0.1216667, -0.121573685907772, -0.120658135283364,
> -0.120540019286403,
>
> -0.119858156028369, -0.11965811965812, -0.11965811965812,
> -0.119565217391304,
>
> -0.118942731277533, -0.117820324005891, -0.116257947320618,
> -0.115789473684211,
>
> -0.115683584819387, -0.115384615384615, -0.115281501340483,
> -0.114492753623188,
>
> -0.114357262103506, -0.114285714285714, -0.114035087719298,
> -0.113181972212809,
>
> -0.112790697674419, -0.112781954887218, -0.112195121951219,
> -0.112191473448018,
>
> -0.111, -0.111, -0.110813226094727,
> -0.110384300899428,
>
> -0.110147441457069, -0.110137672090113, -0.109913793103448,
> -0.109792284866469,
>
> -0.109375, -0.10919540229885, -0.109112709832134, -0.10844250363901,
>
> -0.107776617954071, -0.10752688172043, -0.107317073170732,
> -0.106674272675414,
>
> -0.106382978723404, -0.106100795755968, -0.106060606060606,
> -0.10595160235448,
>
> -0.105742474070326, -0.105263157894737, -0.104454685099846,
> -0.104283054003724,
>
> -0.103916449086162, -0.103723404255319, -0.103448275862069,
> -0.102737680438029,
>
> -0.10267471958585, -0.101696871753434, -0.100893997445721,
> -0.10041265474553,
>
> -0.100042983021706, -0.1, -0.0995111731843576, -0.099502487562189,
>
> -0.0994117647058824, -0.0991561181434598, -0.0989492119089317,
>
> -0.0988372093023255, -0.0983908045977012, -0.0983050847457627,
>
> -0.0977198697068404, -0.0974702380952382, -0.0973819695475956,
>
> -0.097345132743363, -0.0971472629144179, -0.0971438645980254,
>
> -0.0961538461538461, -0.096062667491239, -0.0957347238935687,
>
> -0.0956521739130435, -0.0954773869346733, -0.0954115076474873,
>
> -0.0952380952380952, -0.0951115834218915, -0.0950642007303569,
>
> -0.0949423247559894, -0.0947368421052631, -0.0946291560102303,
>
> -0.0945220193340494, -0.0944309927360775, -0.0943016759776536,
>
> -0.0942720763723149, -0.0941770647653002, -0.0940298507462686,
>
> -0.094017094017094, -0.0935672514619884, -0.0934579439252337,
>
> -0.0930232558139535, -0.0929772502472798, -0.0929054054054054,
>
> -0.0928778745255637, -0.0927700348432055, -0.0925266903914591,
>
> -0.0922502666192677, -0.0918094218415418, -0.0915254237288135,
>
> -0.0914774596906876, -0.0914662894860915, -0.0914285714285715,
>
> -0.0912322274881517, -0.090909090909091, -0.0909090909090909,
>
> -0.09079754601227, 

[R] Empirical density estimation

2018-03-11 Thread Christofer Bogaso
Hi,

Let say I have below vector of data-points :

Dat = c(-0.444, -0.25, -0.237449799196787, -0.227467046669042,

-0.227454464682363, -0.22, -0.214876033057851, -0.211781206171108,

-0.199891067538126, -0.192920353982301, -0.192307692307692, -0.186046511627907,

-0.184418145956608, -0.181818181818182, -0.181818181818182, -0.181266261925412,

-0.181003118503119, -0.179064587973274, -0.178217821782178, -0.17809021675454,

-0.177685950413223, -0.177570093457944, -0.176470588235294, -0.176470588235294,

-0.174825741611282, -0.168021680216802, -0.167, -0.167,

-0.166380789022298, -0.164209115281501, -0.164011246485473, -0.162689804772234,

-0.162361623616236, -0.160161507402423, -0.16, -0.155038759689922,

-0.154172560113154, -0.15311004784689, -0.151515151515152, -0.151462994836489,

-0.151098901098901, -0.150537634408602, -0.150442477876106, -0.150406504065041,

-0.149904214559387, -0.149882903981265, -0.149797570850202, -0.148496240601504,

-0.148325358851675, -0.147540983606557, -0.147239263803681, -0.146989966555184,

-0.14622641509434, -0.146095717884131, -0.145994832041344, -0.14572864321608,

-0.145161290322581, -0.144292237442922, -0.144144144144144, -0.144021739130435,

-0.14375, -0.142212189616253, -0.141122913505311, -0.140324963072378,

-0.139344262295082, -0.13884007029877, -0.138356164383562, -0.137626262626263,

-0.137142857142857, -0.136690647482014, -0.136577708006279, -0.136363636363636,

-0.136094674556213, -0.135879774577332, -0.135586319218241, -0.135135135135135,

-0.132780082987552, -0.132209405501331, -0.132023755139333, -0.131233595800525,

-0.130434782608696, -0.130434782608696, -0.130268199233717, -0.128813559322034,

-0.1284046692607, -0.128205128205128, -0.128182616330114, -0.127937336814621,

-0.126283367556468, -0.125853658536585, -0.125448028673835, -0.125425564840607,

-0.125311203319502, -0.125, -0.124401913875598, -0.124248496993988,

-0.124031007751938, -0.123572170301142, -0.123188405797102, -0.122905027932961,

-0.1216667, -0.121573685907772, -0.120658135283364, -0.120540019286403,

-0.119858156028369, -0.11965811965812, -0.11965811965812, -0.119565217391304,

-0.118942731277533, -0.117820324005891, -0.116257947320618, -0.115789473684211,

-0.115683584819387, -0.115384615384615, -0.115281501340483, -0.114492753623188,

-0.114357262103506, -0.114285714285714, -0.114035087719298, -0.113181972212809,

-0.112790697674419, -0.112781954887218, -0.112195121951219, -0.112191473448018,

-0.111, -0.111, -0.110813226094727, -0.110384300899428,

-0.110147441457069, -0.110137672090113, -0.109913793103448, -0.109792284866469,

-0.109375, -0.10919540229885, -0.109112709832134, -0.10844250363901,

-0.107776617954071, -0.10752688172043, -0.107317073170732, -0.106674272675414,

-0.106382978723404, -0.106100795755968, -0.106060606060606, -0.10595160235448,

-0.105742474070326, -0.105263157894737, -0.104454685099846, -0.104283054003724,

-0.103916449086162, -0.103723404255319, -0.103448275862069, -0.102737680438029,

-0.10267471958585, -0.101696871753434, -0.100893997445721, -0.10041265474553,

-0.100042983021706, -0.1, -0.0995111731843576, -0.099502487562189,

-0.0994117647058824, -0.0991561181434598, -0.0989492119089317,

-0.0988372093023255, -0.0983908045977012, -0.0983050847457627,

-0.0977198697068404, -0.0974702380952382, -0.0973819695475956,

-0.097345132743363, -0.0971472629144179, -0.0971438645980254,

-0.0961538461538461, -0.096062667491239, -0.0957347238935687,

-0.0956521739130435, -0.0954773869346733, -0.0954115076474873,

-0.0952380952380952, -0.0951115834218915, -0.0950642007303569,

-0.0949423247559894, -0.0947368421052631, -0.0946291560102303,

-0.0945220193340494, -0.0944309927360775, -0.0943016759776536,

-0.0942720763723149, -0.0941770647653002, -0.0940298507462686,

-0.094017094017094, -0.0935672514619884, -0.0934579439252337,

-0.0930232558139535, -0.0929772502472798, -0.0929054054054054,

-0.0928778745255637, -0.0927700348432055, -0.0925266903914591,

-0.0922502666192677, -0.0918094218415418, -0.0915254237288135,

-0.0914774596906876, -0.0914662894860915, -0.0914285714285715,

-0.0912322274881517, -0.090909090909091, -0.0909090909090909,

-0.09079754601227, -0.0907071455016661, -0.0906593406593406,

-0.0903614457831325, -0.0903323548906352, -0.09, -0.0897243107769424,

-0.0896358543417368, -0.0895522388059702, -0.0895052902487847,

-0.0891719745222929, -0.0888, -0.0887227819304518,

-0.0887096774193548, -0.0886956521739131, -0.0884703196347032,

-0.0884450784593437, -0.0884413309982488, -0.0883577310155536,

-0.0883054892601431, -0.0882917466410749, -0.0881628999776236,

-0.0881193929739248, -0.0880681818181819, -0.0878186968838525,

-0.087719298245614, -0.0876010781671159, -0.0873634945397815,

-0.0872641509433961, -0.0871512228728901, -0.0871032050299035,

-0.0868133772309825, -0.0865384615384615, -0.0858895705521473,

-0.085742525327403, -0.0855766209280403, -0.0854700854700855,


Re: [R] Your browser do not suport oracle bi presentation services

2018-03-11 Thread KENNETH ROY CABRERA TORRES
Thank you José María:

You are very kind.

I will study and use your advice.

The first step, takes more information,
but not what I want. (I want the whole data set of "TRM").

I'm going to try with Selenium (RSelenium).

Thank you very much for your help.

Kenneth

- Mensaje original -
De: "José María Mateos" 
Para: "r-help@r-project.org r-help@r-project.org" 
Enviados: Domingo, 11 de Marzo 2018 9:25:51
Asunto: Re: [R] Your browser do not suport oracle bi presentation services

On Sun, Mar 11, 2018 at 09:12:56AM -0500, KENNETH ROY CABRERA TORRES wrote:
> Hi dear R users: 
> 
> I'm trying the following code to download an information from the web. 
> 
> url1 <- 
> "http://obieebr.banrep.gov.co/analytics/saw.dll?Go=%2fshared%2fSeries%20Estad%C3%ADsticas_T%2f1.%20Tasa%20de%20Cambio%20Peso%20Colombiano%2f1.1%20TRM%20-%20Disponible%20desde%20el%2027%20de%20noviembre%20de%201991%2f1.1.1.TCM_Serie%20hist%C3%B3rica%20o%20por%20a%C3%B1o=rdf=es=publico=publico;
>  
> 
> con <- url(url1, "r") 
> x <- readLines(con) 
> close(con) 
> 
> I obtain the folowing message: 
> 
> "Su explorador no es soportado por Oracle BI Presentation Services." 
> 
> Your browser do not support Oracle BI Presentation Sevices. 

I tried opening that URL with my browser and it worked (or at least I 
think it worked, it took me to a page where I could see a very long 
table titled "Tasa de cambio representativa del mercado (TRM)".

I tried obtaining the page using wget and I got the error you mentioned. 
When I forge wget to identify itself as Firefox, I get returned a 
different code (one that I suppose will redirect me to the page you are 
trying to scrape).

The problem could be solved by telling R to use a different user-agent, 
like Firefox or Chrome. Check 
https://stackoverflow.com/questions/4536835/changing-user-agent-string-in-a-http-request-in-r

However, I think the system that provides the HTML content you want 
relies heavily on JavaScript. You might need to end up using something 
like Selenium (https://www.r-bloggers.com/scraping-with-selenium/).

Cheers,

-- 
José María (Chema) Mateos
https://rinzewind.org/blog-es || https://rinzewind.org/blog-en

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

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


Re: [R] Your browser do not suport oracle bi presentation services

2018-03-11 Thread José María Mateos
On Sun, Mar 11, 2018 at 09:12:56AM -0500, KENNETH ROY CABRERA TORRES wrote:
> Hi dear R users: 
> 
> I'm trying the following code to download an information from the web. 
> 
> url1 <- 
> "http://obieebr.banrep.gov.co/analytics/saw.dll?Go=%2fshared%2fSeries%20Estad%C3%ADsticas_T%2f1.%20Tasa%20de%20Cambio%20Peso%20Colombiano%2f1.1%20TRM%20-%20Disponible%20desde%20el%2027%20de%20noviembre%20de%201991%2f1.1.1.TCM_Serie%20hist%C3%B3rica%20o%20por%20a%C3%B1o=rdf=es=publico=publico;
>  
> 
> con <- url(url1, "r") 
> x <- readLines(con) 
> close(con) 
> 
> I obtain the folowing message: 
> 
> "Su explorador no es soportado por Oracle BI Presentation Services." 
> 
> Your browser do not support Oracle BI Presentation Sevices. 

I tried opening that URL with my browser and it worked (or at least I 
think it worked, it took me to a page where I could see a very long 
table titled "Tasa de cambio representativa del mercado (TRM)".

I tried obtaining the page using wget and I got the error you mentioned. 
When I forge wget to identify itself as Firefox, I get returned a 
different code (one that I suppose will redirect me to the page you are 
trying to scrape).

The problem could be solved by telling R to use a different user-agent, 
like Firefox or Chrome. Check 
https://stackoverflow.com/questions/4536835/changing-user-agent-string-in-a-http-request-in-r

However, I think the system that provides the HTML content you want 
relies heavily on JavaScript. You might need to end up using something 
like Selenium (https://www.r-bloggers.com/scraping-with-selenium/).

Cheers,

-- 
José María (Chema) Mateos
https://rinzewind.org/blog-es || https://rinzewind.org/blog-en

__
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] Your browser do not suport oracle bi presentation services

2018-03-11 Thread KENNETH ROY CABRERA TORRES
Hi dear R users: 


I'm trying the following code to download an information from the web. 

url1 <- 
"http://obieebr.banrep.gov.co/analytics/saw.dll?Go=%2fshared%2fSeries%20Estad%C3%ADsticas_T%2f1.%20Tasa%20de%20Cambio%20Peso%20Colombiano%2f1.1%20TRM%20-%20Disponible%20desde%20el%2027%20de%20noviembre%20de%201991%2f1.1.1.TCM_Serie%20hist%C3%B3rica%20o%20por%20a%C3%B1o=rdf=es=publico=publico;
 

con <- url(url1, "r") 
x <- readLines(con) 
close(con) 

I obtain the folowing message: 

"Su explorador no es soportado por Oracle BI Presentation Services." 

Your browser do not support Oracle BI Presentation Sevices. 


How can I deal with this problem? 

Thank you very much for your help. 

Kenneth 



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