Re: [R] reticulate + virtual environments

2024-07-15 Thread Sigbert Klinke

Hi,

thanks, I posted in the Posit community.

Sigbert

Am 15.07.24 um 16:41 schrieb Bert Gunter:

Have you tried https://rstudio.github.io/reticulate/  ?

Generally speaking, complex nonstandard package specific questions
such as yours rarely get a reply here -- there are 20,000+ packages
(and counting) after all! As reticulate was created by and integrated
with RStudio/Posit, I would think their site and help resources might
be a better venue. Of course, if you don't use RStudio, you may have
no joy there either.

Cheers,
Bert




On Sun, Jul 14, 2024 at 10:56 PM Sigbert Klinke
 wrote:


Hi,

I am using reticulate and a virtual environment (not conda) to run
Python scripts from RStudio. However, when I try to use my own
(existing) virtual environment, reticulate does not use it. If I run my
scripts, the installed modules (e.g., py_install("pandas",
"mmstat4.hu.data")) are not found. I believe this happens because
reticulate is using r-reticulate instead of mmstat4.hu.data. How can I
force reticulate to use my virtual environment?

Thanks Sigbert

  > library("reticulate")

  > py_config()

python: /home/sk/.virtualenvs/r-reticulate/bin/python

libpython:
/usr/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.so

pythonhome:
/home/sk/.virtualenvs/r-reticulate:/home/sk/.virtualenvs/r-reticulate

version:3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0]

numpy:
/home/sk/.virtualenvs/r-reticulate/lib/python3.10/site-packages/numpy

numpy_version:  2.0.0

  > use_virtualenv("mmstat4.hu.data", required = TRUE)

  > py_config()

python: /home/sk/.virtualenvs/r-reticulate/bin/python

libpython:
/usr/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.so

pythonhome:
/home/sk/.virtualenvs/r-reticulate:/home/sk/.virtualenvs/r-reticulate

version:3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0]

numpy:
/home/sk/.virtualenvs/r-reticulate/lib/python3.10/site-packages/numpy

numpy_version:  2.0.0

--
https://hu.berlin/sk
https://hu.berlin/mmstat

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


--
https://hu.berlin/sk
https://hu.berlin/mmstat

__
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] reticulate + virtual environments

2024-07-14 Thread Sigbert Klinke

Hi,

I am using reticulate and a virtual environment (not conda) to run 
Python scripts from RStudio. However, when I try to use my own 
(existing) virtual environment, reticulate does not use it. If I run my 
scripts, the installed modules (e.g., py_install("pandas", 
"mmstat4.hu.data")) are not found. I believe this happens because 
reticulate is using r-reticulate instead of mmstat4.hu.data. How can I 
force reticulate to use my virtual environment?


Thanks Sigbert

> library("reticulate")

> py_config()

python: /home/sk/.virtualenvs/r-reticulate/bin/python

libpython: 
/usr/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.so


pythonhome: 
/home/sk/.virtualenvs/r-reticulate:/home/sk/.virtualenvs/r-reticulate


version:3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0]

numpy: 
/home/sk/.virtualenvs/r-reticulate/lib/python3.10/site-packages/numpy


numpy_version:  2.0.0

> use_virtualenv("mmstat4.hu.data", required = TRUE)

> py_config()

python: /home/sk/.virtualenvs/r-reticulate/bin/python

libpython: 
/usr/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.so


pythonhome: 
/home/sk/.virtualenvs/r-reticulate:/home/sk/.virtualenvs/r-reticulate


version:3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0]

numpy: 
/home/sk/.virtualenvs/r-reticulate/lib/python3.10/site-packages/numpy


numpy_version:  2.0.0

--
https://hu.berlin/sk
https://hu.berlin/mmstat

__
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 with base::order

2024-04-10 Thread Sigbert Klinke

Hi,

you are unfortunately right. Executing

x <- sample(c(1,2,NA), 26, replace=TRUE)
y <- sample(c(1,2,NA), 26, replace=TRUE)
o <- order(x, y, decreasing = c(T,F), na.last=c(F,T))
cbind(x[o], y[o])

shows that the second entry of na.last is ignored without warning.

Thanks Sigbert

Am 10.04.24 um 10:29 schrieb Ivan Krylov:

В Wed, 10 Apr 2024 09:33:19 +0200
Sigbert Klinke  пишет:


decreasing=c(F,F,F)


This is only documented to work with method = 'radix':


For the ‘"radix"’ method, this can be a vector of length equal to
the number of arguments in ‘...’ and the elements are recycled as
necessary.  For the other methods, it must be length one.



na.last=c(T,T,T),


I think this is supposed to be a scalar, no matter the sort method. At
the very least, I don't see it documented to accept a logical vector,
and the C code in both src/main/sort.c and src/main/radixsort.c treats
the argument as a scalar (using asLogical(...), not LOGICAL(...) on the
R value).



--
https://hu.berlin/sk
https://hu.berlin/mmstat
https://hu.berlin/mmstat-ar

__
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 with base::order

2024-04-10 Thread Sigbert Klinke

Hi,

when I execute

order(letters, LETTERS, 1:26)

then everything is fine. But if I execute

order(letters, LETTERS, 1:26, na.last=c(T,T,T), decreasing=c(F,F,F))

I get the error message

Error in method != "radix" && !is.na(na.last) :
'length = 3' in constraint to 'logical(1)'

Shouldn't both give the same result?

Sigbert

__
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] Dynamically create a (convenience) function in a package

2023-10-30 Thread Sigbert Klinke

Hi,

n a package, I have a data object with attributes, and I want to 
dynamically create a convenience function to access those attributes. 
This way, instead of using attr(x, "number"), I would like to use number(x).




Because I don't know in advance which attributes the data object may 
have, I've used the following algorithm:


x <- structure(pi, number=exp(1))

a <- attributes(x)

for (n in names(a)) {

  if (!exists(n, mode="function")) {

f <- eval(parse(text=sprintf("function(x) { attr(x, '%s') } ", n))) 



assign(n, f, envir=.GlobalEnv)

  }

}

number(x)

However, I believe modifying the global environment with this is not 
allowed by CRAN for a package. Is there a way to implement such 
functionality?


Thanks Sigbert

--
https://hu.berlin/sk
https://www.stat.de/faqs
https://hu.berlin/mmstat
https://hu.berlin/mmstat-ar

__
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] Use generic functions, e.g. print, without UseMethod?

2023-08-11 Thread Sigbert Klinke

Hello,

I have defined a function 'equations(...)' which returns an object with 
class 'equations'. I also defined a function 'print.equations' which 
prints the object. But I did not use 'equations <- function(x, ...) 
UseMethod("equations"). Two questions:


1.) Is this a sensible approach?
2.) If yes, are there any pitfalls I could run in later?

Thanks

Sigbert

--
https://hu.berlin/sk
https://www.stat.de/faqs
https://hu.berlin/mmstat
https://hu.berlin/mmstat-ar

__
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] diamonds data set from ggplot2

2023-04-25 Thread Sigbert Klinke

Hi,

is there any information about the source of this data set?

1.) I read the question of Marina Doucerain in 2012 about the time and 
Hadley Wickhams answer "I believe it was 2008."


2.) In kaggle someone said "It's a Tiffany & Co's snapshot pricelist 
from 2017."


So, where the data set stems from? Which year?

Thanks Sigbert

__
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] insert hyperlink into svg graphic

2023-03-08 Thread Sigbert Klinke

Hi,

maybe it would be a good idea to extend plotmath by a href command.

Sigbert

Am 08.03.23 um 22:46 schrieb Paul Murrell:

Hi

On 8/03/23 15:27, Rusty Travis wrote:

On 3/7/23 13:12, Paul Murrell wrote:

Hi

I think the main issue here is that you are *drawing* text on the 
graphics device, so I would only expect to see literal XML text 
output in the result.

'''

Hope that helps


Thank you for your consideration of the matter, but that seems 
extraordinarily overly-complicated for the results of "help(svg)". 
I'll just print the text of the link instead of constructing a link, 
as the resultant R-produced *.svg file is about 10 times the size of a 
manual screen-print *.png of X11() same.


Yes, it is not completely straightforward :)
Though once you have a code template it is not hard to repeat.
Yes, the generated SVG is verbose.
Though SVG can be compressed.

I'll let the user type the title() noaa.gov uri into their browser 
instead of providing a clickable link.


Glad you have a solution!

Paul


Thank you all.


 > On 2023-03-07, at 10:33, Bert Gunter  wrote:
 >
 > Perhaps this thread on stackoverflow (from a search on "include 
hyperlink

 > in svg graphic") may be of use:
 >
 > 
https://stackoverflow.com/questions/41970535/a-hyperlink-in-svg-use 


 >
 > Cheers,
 > Bert
 >
 > On Tue, Mar 7, 2023 at 12:34 AM Rusty Travis 
 wrote:

 >
 >> Greetings,
 >>
 >> I am creating plots of weather data and wish to include a link 
to the
 >> data source into a title() object in the plot. My syntax must be 
wrong

 >> though, as the hyperlink doesn't display, just the text and tags.
 >>
 >>> svg("/tmp/temps.svg", width=9, height=6)
 >>> #plot created here
 >>> title(sub="produced by Rusty Travis \nusing data from  >> xlink:href=https://www.ncei.noaa.gov/cdo-web/ 
>test ", line=-1.5,

 >> adj=1)
 >>> dev.off()
 >>
 >> The goal is to create a hyperlink of the word "test" in the above
 >> example. What is the correct syntax, please?
 >>
 >> [[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.








--
https://hu.berlin/sk
https://www.stat.de/faqs
https://hu.berlin/mmstat
https://hu.berlin/mmstat-ar

__
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] legend: interplay between title and y.intersp

2023-03-06 Thread Sigbert Klinke

Hi,

that is perfect.

Thanks Sigbert

Am 06.03.23 um 13:08 schrieb Uwe Ligges:

What about

  plot(c(0,1), c(0,1), type="n")
  legend("top", legend=c("", "a", ""), col=c("blue", "red", "green"), 
title="test", y.intersp=c(1,-0.4), lwd=1)


(in recent versions of R)

Best,
Uwe



--
https://hu.berlin/sk
https://www.stat.de/faqs
https://hu.berlin/mmstat
https://hu.berlin/mmstat-ar

__
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] legend: interplay between title and y.intersp

2023-03-06 Thread Sigbert Klinke

Hi,

I think you are right, legend cannot do it. I have now created my own 
legend function where I changed only one line and now it works the way I 
want it to. But I'm not sure if that might not have other side effects.




I have the impression that the legend and the title start at the same 
y-position (try y.intersp=0). Only if y.intersp is big enough, then it 
leads to a non-overlap of title and legend.


Thanks a lot

Sigbert

Am 05.03.23 um 16:20 schrieb Bert Gunter:

Don't think you can do that.
But maybe someone else will show that I'm wrong.

-- Bert

On Sat, Mar 4, 2023 at 11:39 PM Sigbert Klinke 
wrote:


Hi,

thanks, but this does not solve the problem. If I make y.intersp large
enough then it works properly. Maybe I was not clear enough: I want to
have the small distance between the lines and no overlap between the
title and the lines.

Sigbert

Am 04.03.23 um 17:59 schrieb Bert Gunter:

Set the legend position explicitly with x and y values and add xpd = TRUE
to the legend call to clip the plot to the figure region and not the plot
region (the default). Something like this (you may have to fool around

with

y.intersp, etc. to allow enough space between the legend lines):

plot(c(0,1), c(0,1), type="n")

legend(x = .4, y = 1.25, legend=c("", "", "a"), col=c("blue", "red",
"green"), xpd = TRUE, lty = 1, y.intersp= .75, title = 'test')

Cheers,
Bert

Cheers,
Bert


On Sat, Mar 4, 2023 at 7:45 AM Sigbert Klinke 
Hi,

my MWE is not working as expected:

plot(c(0,1), c(0,1), type="n")

legend("top", legend=c("", "", "a"), col=c("blue", "red", "green"),
title="test", y.intersp=0.2, lwd=1)

The lines are not below the title. I want (nearby) lines as in the plot,
but below the title. Is there a way to achieve this?

Thanks Sigbert

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





--
https://hu.berlin/sk
https://www.stat.de/faqs
https://hu.berlin/mmstat
https://hu.berlin/mmstat-ar






--
https://hu.berlin/sk
https://www.stat.de/faqs
https://hu.berlin/mmstat
https://hu.berlin/mmstat-ar
__
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] legend: interplay between title and y.intersp

2023-03-04 Thread Sigbert Klinke

Hi,

thanks, but this does not solve the problem. If I make y.intersp large 
enough then it works properly. Maybe I was not clear enough: I want to 
have the small distance between the lines and no overlap between the 
title and the lines.


Sigbert

Am 04.03.23 um 17:59 schrieb Bert Gunter:

Set the legend position explicitly with x and y values and add xpd = TRUE
to the legend call to clip the plot to the figure region and not the plot
region (the default). Something like this (you may have to fool around with
y.intersp, etc. to allow enough space between the legend lines):

plot(c(0,1), c(0,1), type="n")

legend(x = .4, y = 1.25, legend=c("", "", "a"), col=c("blue", "red",
"green"), xpd = TRUE, lty = 1, y.intersp= .75, title = 'test')

Cheers,
Bert

Cheers,
Bert


On Sat, Mar 4, 2023 at 7:45 AM Sigbert Klinke 
wrote:


Hi,

my MWE is not working as expected:

plot(c(0,1), c(0,1), type="n")

legend("top", legend=c("", "", "a"), col=c("blue", "red", "green"),
title="test", y.intersp=0.2, lwd=1)

The lines are not below the title. I want (nearby) lines as in the plot,
but below the title. Is there a way to achieve this?

Thanks Sigbert

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





--
https://hu.berlin/sk
https://www.stat.de/faqs
https://hu.berlin/mmstat
https://hu.berlin/mmstat-ar

__
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: interplay between title and y.intersp

2023-03-04 Thread Sigbert Klinke

Hi,

my MWE is not working as expected:

plot(c(0,1), c(0,1), type="n")

legend("top", legend=c("", "", "a"), col=c("blue", "red", "green"), 
title="test", y.intersp=0.2, lwd=1)


The lines are not below the title. I want (nearby) lines as in the plot, 
but below the title. Is there a way to achieve this?


Thanks Sigbert

__
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] Palettes {grDevices} - wrong number of colors returned?

2023-02-23 Thread Sigbert Klinke

Hi,

I would have expected that I get always 3 colors as result which is not 
true:


hcl.colors(3, alpha=c(0, 0.5, 1)) # 3 colors

rainbow(3, alpha=c(0, 0.5, 1))# 3 colors

heat.colors(3, alpha=c(0, 0.5, 1))# 3 colors

terrain.colors(3, alpha=c(0, 0.5, 1)) # 6 colors

cm.colors(3, alpha=c(0, 0.5, 1))  # 6 colors

topo.colors(3, alpha=c(0, 0.5, 1))# 9 colors

R-Version and platform:
R version 4.2.2 Patched (2022-11-10 r83330) -- "Innocent and Trusting"

Copyright (C) 2022 The R Foundation for Statistical Computing

Platform: x86_64-pc-linux-gnu (64-bit)

Bug or feature?

Sigbert

--
https://hu.berlin/sk
https://www.stat.de/faqs
https://hu.berlin/mmstat
https://hu.berlin/mmstat-ar

__
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] gmp::bigq vs. MASS::fractions

2023-01-11 Thread Sigbert Klinke

Hello,

Am 07.01.23 um 17:55 schrieb Ivan Krylov:
> What do you need the fractions for?
>

When writing tasks for statistics exams, I try to avoid non-terminal 
intermediate results. Students might round them and arrive at a final 
result that might be slightly different from the true value. Although 
the exam package supports a tolerance for checking the result, this 
could be problematic. To check if a number is non-terminal, I calculate 
a fraction representation and check if the denominator can be expressed 
by 2^p 5^q.


@Enrico: When I started developing assignments a few years ago, I was 
not familiar with gmp. :(


Thanks Sigbert

__
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] gmp::bigq vs. MASS::fractions

2023-01-07 Thread Sigbert Klinke

Hi,

has someone experience which routine should be used for creating 
fractional numbers? The two conversion routines deliver different results


> x <- (0:7)/7

> MASS::fractions(x)

[1]   0 1/7 2/7 3/7 4/7 5/7 6/7   1

> gmp::as.bigq(x)

Big Rational ('bigq') object of length 8:

[1] 0 
2573485501354569/18014398509481984 2573485501354569/9007199254740992


[4] 7720456504063707/18014398509481984 2573485501354569/4503599627370496 
 6433713753386423/9007199254740992


[7] 7720456504063707/9007199254740992  1

Following the example I would compute my fractional numbers with 
MASS::fractions and store them for further processing as Big Rational.


Thanks Sigbert

__
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] rio: list of extensions for supported formats

2022-11-05 Thread Sigbert Klinke

Hi,

is there a function in the package rio to get the file extensions listed 
in the vignette under supported formats?


Thanks Sigbert

__
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] aplpack / bagplot

2022-09-21 Thread Sigbert Klinke

Hi,

I get an error when I use bagplot from the package aplpack. Any ideas 
what theproblem is with the data set?


library("aplpack")

x <- c(5, 2, 1, 6, 3, 5, 4, 7, 4, 4, 3, 4, 5, 4, 6, 3, 3)

y <- c(2, 3, 4, 6, 7, 8, 10, 11, 12, 13, 1, 14, 17, 18, 19, 20, 22)

bagplot(y,x) # works

bagplot(x,y) # Error in pg[segm.no, 2] : (subscript) boolean index too long

Thanks Sigbert

--
https://hu.berlin/sk
https://www.stat.de/faqs
https://hu.berlin/mmstat
https://hu.berlin/mmstat-int
https://hu.berlin/mmstat-ar

__
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] binom.test & p-value

2022-04-03 Thread Sigbert Klinke

Hi,

for the specific example binom.test(x=6, n=26, p=0.1) I get as p-value 
0.03986. The default approach to decide whether I can reject the null or 
or not is to compare the p-value with the given significance level. 
Using a significance level of 0.05 this will lead to reject the null 
hypothesis.


However, computing things by hand it turned out that the critical values 
are 0 and 6. Since the test statistic is also 6 I can not reject the 
null hypothesis.


I found the discussion under 
https://stat.ethz.ch/pipermail/r-help/2009-February/380341.html and I 
understand that a p-value is not well defined if we have a asymmmetric 
(discrete) distribution under the null.


At least I would have expected some hint in the documentation for 
binom.test.


Sigbert

--
https://hu.berlin/sk
https://www.stat.de/faqs
https://hu.berlin/mmstat
https://hu.berlin/mmstat-int
https://hu.berlin/mmstat-ar

__
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] roxygen2 & markdown & math

2021-01-12 Thread Sigbert Klinke

Hi,

thanks a lot, but maybe I was to vague.

I do not want to replace \eqn{...} and \deqn{...} by \mjseqn{...} and 
\mjsdeqn{...}. I would like to use $...$ and $$...$$ as in Rmarkdown to 
get something better readable.


Best Sigbert

Am 12.01.21 um 10:41 schrieb Viechtbauer, Wolfgang (SP):

Dear Sigbert,

The mathjaxr package provides this:

https://cran.r-project.org/package=mathjaxr
https://github.com/wviechtb/mathjaxr

Best,
Wolfgang


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sigbert
Klinke
Sent: Tuesday, 12 January, 2021 9:14
To: r-help@r-project.org
Subject: [R] roxygen2 & markdown & math

Hi,

I like to make my package documentation with markdown which is supported
since roxygen2 6.0.0 . I used a math expression like $t_n \appox N(0,1)$
which leads in the package check to "unknown macro '\approx'".

I guess I get the warning because math is not supported in markdown. Are
there any plans to support something like $...$ or $$...$$? Or there are
general problems?

Best Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat
https://hu.berlin/mmstat-int
https://hu.berlin/mmstat-ar



--
https://hu.berlin/sk
https://hu.berlin/mmstat
https://hu.berlin/mmstat-int
https://hu.berlin/mmstat-ar

__
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] roxygen2 & markdown & math

2021-01-12 Thread Sigbert Klinke

Hi,

I like to make my package documentation with markdown which is supported 
since roxygen2 6.0.0 . I used a math expression like $t_n \appox N(0,1)$ 
which leads in the package check to "unknown macro '\approx'".


I guess I get the warning because math is not supported in markdown. Are 
there any plans to support something like $...$ or $$...$$? Or there are 
general problems?


Best Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat
https://hu.berlin/mmstat-int
https://hu.berlin/mmstat-ar

__
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] serialize does not work as expected

2020-08-29 Thread Sigbert Klinke

Hi,

is there in R a way to "normalize" a vector from 
compact_intseq/compact_realseq to a "normal" vector?


Sigbert

Am 29.08.20 um 18:13 schrieb Duncan Murdoch:

Element 1
A
3
262146
197888
5
UTF-8
238
2
1
262153
14
compact_intseq
2
1
262153
4
base
2
13
1
13
254
14
3
3
1
1
254

Element 2
A
3
262146
197888
5
UTF-8
238
2
1
262153
15
compact_realseq
2
1
262153
4
base
2
13
1
14
254
14
3
3
1
1
254

Element 3
A
3
262146
197888
5
UTF-8
14
3
1
2
3



--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] serialize does not work as expected

2020-08-29 Thread Sigbert Klinke

Hi,

if I create a list with

l <- list(1:3, as.numeric(1:3), c(1,2,3))

and applying

lapply(l, 'class')
lapply(l, 'mode')
lapply(l, 'storage.mode')
lapply(l, 'typeof')
identical(l[[2]], l[[3]])

then I would believe that as,numeric(1:3) and c(1,2,3) are identical 
objects. However,


lapply(l, serialize, connection=NULL)

returns different results for each list element :(

Any ideas, why it is like that?

Best Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] regular expression, stringr::str_view, grep

2020-04-28 Thread Sigbert Klinke

Hi,

we gave students the task to construct a regular expression selecting 
some texts. One send us back a program which gives different results on 
stringr::str_view and grep.


The problem is "[^[A-Z]]" / "[^[A-Z]" at the end of the regular 
expression. I would have expected that all four calls would give the 
same result; interpreting [ and ] within [...] as the characters `[` and 
`]`. Obviously this not the case and moreover stringr::str_view and grep 
interpret the regular expressions differently.


Any ideas?

Thanks Sigbert

---

aff <- c("affgfking", "fgok", "rafgkahe","a fgk", "bafghk", "affgm",
 "baffgkit", "afffhk", "affgfking", "fgok", "rafgkahe", "afg.K",
 "bafghk", "aff gm", "baffg kit", "afffhgk")

correct_brackets <- "af+g[^m$][^[A-Z]]"
missing_brackets <- "af+g[^m$][^[A-Z]"

library("stringr")
grep(correct_brackets, aff, value = TRUE) ### result: character(0)
grep(missing_brackets, aff, value = TRUE) ### correct result
str_view(aff, correct_brackets) ### correct result
str_view(aff, missing_brackets) ### error: missing closing bracket

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

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


[R] R Markdown & chunk extraction in R

2020-04-08 Thread Sigbert Klinke

Hi,

exists a possibility to extract chunks from a R Markdown file and to 
return them as (named) list in R?


Thanks Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] Strange behaviour of R?

2020-01-17 Thread Sigbert Klinke

Hi,

You probably have a function defined in your global environment that is 
named FUN and acts like mean.


You are right.

Thanks Sigbert


--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] Strange behaviour of R?

2020-01-17 Thread Sigbert Klinke

Hi,

Am 17.01.20 um 08:42 schrieb Rainer M Krug:
> Not for me - macOS, R 3.6.2

Sorry, I forgot to add: Ubuntu 18.04.3 LTS, R 3.6.2

Best Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] Strange behaviour of R?

2020-01-16 Thread Sigbert Klinke

Hi,

I wrote a function like

test <- function(FUN, args) {
  print(FUN)
  FUN(args)
}

When I call it lieke this

test(mean, 1:10)
test(NULL, 1:10)

then the second call still uses mean, although I set FUN to NULL. Is 
that ok?


Actually, I used something like

test(mean, list(x=1:10, na.rm=TRUE))

which actually crashed R, but I can not reproduce it. Of course, when I 
replaced FUN(args) with do.call(FUN, args) then everything works fine.


Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] read_dta & .name_repair

2019-10-24 Thread Sigbert Klinke

Hi,

I can not read in a data set from Stata. When I try I get the first 
error. If I follow the advice then I get "unused argument error".


How do I use .name_repair?

Best Sigbert



> library("haven")
> packageVersion("haven")

[1] ‘2.1.1’

> xp <- read_dta("XXX.dta")

Fehler in df_parse_dta_file(spec, encoding) :
  Evaluation error: Column name `Merge` must not be duplicated.
Use .name_repair to specify repair..

> mynr <- function(nms) { }
> xp <- read_dta("XXX.dta", .name_repair=mynr)

Fehler in read_dta("XXX.dta", .name_repair = mynr) :
  unbenutztes Argument (.name_repair = mynr)


--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] shinyWidgets::sliderTextInput

2019-08-09 Thread Sigbert Klinke

Hi Erin,

do you see the difference between sliderTextInput and selectInput? I 
would like to have the selectInput behaviour (list element name in 
display, but result as value of list element) in sliderTextInput as well.


Best Sigbert

---

library("shiny")
library("shinyWidgets")

ui <- fluidPage(
  br(),
  sliderTextInput(
inputId = "mySliderText",
label = "My House",
choices = list("choice 1" = 1,"choice 2" =2,
   "choice 3" = 3)
  ),
  selectInput(inputId="slope", label="selectInput",
   choices=list("Choice 1" = "A","Choice 2" = "B",
"Choice 3" = "C")),
  verbatimTextOutput(outputId = "result")
)


server <- function(input, output, session) {

  output$result <- renderPrint({
str(input$mySliderText)
str(input$slope)
  })
}

shinyApp(ui = ui, server = server)


--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] shinyWidgets::sliderTextInput

2019-08-07 Thread Sigbert Klinke

Hi,


Is there a label argument, please? I think that might be it.


In my example I had a label, but this not the problem since

> choices=list("choice1"=1, "choice2"=2,"choice3"=3)
> as.character(choices)
[1] "1" "2" "3"

delivers the result as it is used in sliderTextInput. I was hoping there 
was a way to bypass that behaviour without changing the sliderTextInput 
function ;)
The default action of selectInput using a list for choices is to show in 
the UI element the list names, but to deliver to the shiny app the 
number if one is selected.


Thanks Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] shinyWidgets::sliderTextInput

2019-08-06 Thread Sigbert Klinke

Hi,

I'am using

sliderTextInput('myinput', choices=list("choice1"=1, "choice2"=2, 
"choice3"=3))


But in the shiny app the UI element shows '1', '2', instead of 
'choice1', 'choice2' etc.


I think the reason is that in shinyTextInput is done

if (!is.character(choices)) {
choices <- as.character(choices)
}

Any idea if I could achieve my wished behaviour?

Best Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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 with rio/haven

2019-07-30 Thread Sigbert Klinke

Hi,

I got the following error when reading a Stata file:

> library("rio")
> x <- import('XXX.dta')
Fehler in df_parse_dta_file(spec, encoding) :
  Evaluation error: Column name `Merge` must not be duplicated.
Use .name_repair to specify repair.

I understand that the column name "Merge" appears at least twice in the 
Stata file.


My problem is that I have created the data as data.frame in R and saved 
with the export command of rio. How could it be that I can save a data 
set but I'am not able to read in again?


Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] Rd files with duplicated alias 'plot'

2019-05-10 Thread Sigbert Klinke

Hi,

in package I have for two S3 classes plot routines: plot.ABC and 
plot.DEF. For appearing both under ?plot I added in each file a 
"@aliases plot".


This leads to the above warning message when calling devtools::check(). 
And only one of the routines appears under ?plot.


Any hint how to solve the problem?

Thanks Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] do.call, browser and traceback

2019-01-15 Thread Sigbert Klinke

Hi,

I run in the same problem, as discussed in 2006. Is there any solution 
by now?


Sigbert

Am 23.02.06 um 20:39 schrieb hadley wickham:

Did you mean that?  Both are errors.  Perhaps

f <- function(...) browser()
do.call(f, mtcars)


Sorry, yes, that is what I meant.


What is being used is

 Rprintf("Called from: ");
 PrintValueRec(cptr->call,rho);

in src/main/main.c.  We could certainly allow an option to limit the
deparse length, but I have to say that quite often the useful information
is well down the list of arguments.  There is currently no user control.


It would be nice to have some user control - I find the first 100
characters or so is usually sufficient, especially when the real
problem is further down the stack.  It is a real pain when you have
used do.call with a 10,000 row dataframe - and then it is basically
impossible to find the problem by manual inspection anyway.  Even
limiting to 1000 characters would be a big improvement.

Hadley

__
r-h...@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] Access function as text from package by name

2018-09-28 Thread Sigbert Klinke

Hi,

I guess I was not clear enough: the name of the function is stored as 
string. Solutions which use the object directly do not help unfortunately.


Thanks Sigbert

Am 27.09.2018 um 12:30 schrieb Sigbert Klinke:

Hi,

I want to have a function, e.g. graphics::box, as text.
Currently I'am using

deparse(eval(parse(text='graphics::box')))

It is important that '::' and ':::' can be used in the name.

Is there a simpler way?

Thanks

Sigbert



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




--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] Access function as text from package by name

2018-09-27 Thread Sigbert Klinke

Hi,

I want to have a function, e.g. graphics::box, as text.
Currently I'am using

deparse(eval(parse(text='graphics::box')))

It is important that '::' and ':::' can be used in the name.

Is there a simpler way?

Thanks

Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] Link from vignette to package documentation

2018-09-21 Thread Sigbert Klinke

Hi,

is it possible to make a link from a vignette to a (Rd) help files in my 
own or other packages?


Best Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] Extract function parameters from a R expression

2018-06-20 Thread Sigbert Klinke

Hi,

I have read an R program with

expr <- parse("myRprg.R")

How can I extract the parameters of a specifc R command, e.g. "library"?

So, if myprg.R containes the lines

library("xyz")
library("abc")

then I would like to get "xyz" and "abc" back from expr.

Thanks in advance

Sigbert

--
https://hu.berlin/sk


__
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] problems in converting numeric to character

2018-06-08 Thread Sigbert Klinke

sprintf("%.1f", x)
sprintf("%.2f", x)

Am 07.06.2018 um 17:12 schrieb 刘瑞阳:

Hi,
I am having trouble converting numeric to characters in the format I desire. To 
be more specific, I have a number of numeric as follows:

x<-c(1.0,2.0,2.00,2.1)
I want to convert them to characters so that the out put would be 
c(“1.0”,”2.0”,”2.00”,”2.1”).

However, I used as.character(x) and the output is:
"1"   "2"   "2"   “2.1"

The decimals are removed if the numeric ends with “.0”. Is there a way to 
circumvent this problem?

Thanks very much!

Sincerely,

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




--
Sprechstunde: Fr 12-13, SPA1, R308
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] Ubuntu 18.04 / R 3.4.4 / shinyjs / V8

2018-06-06 Thread Sigbert Klinke

Hi,

found myself a workaround:

Replaced the javascript functionality by calls of 
session$sendCustomMesssage(...) & Sys.sleep(...) and deleted 
library(shinyjs) from my code.


Best Sigbert

Am 06.06.2018 um 10:33 schrieb Sigbert Klinke:

Hi,

if I want to use shinyjs package then I need the V8 package.
Therefore I installed

apt-get install libv8-3.14-dev

and tried

install.packages("V8")

and get

** preparing package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) :
   kann shared object 
'/home/sigbert/R/x86_64-pc-linux-gnu-library/3.4/curl/libs/curl.so' 
nicht laden:
   /usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not 
found (required by 
/home/sigbert/R/x86_64-pc-linux-gnu-library/3.4/curl/libs/curl.so)

ERROR: lazy loading failed for package ‘V8’

I also tried to install curl3, but when I install R 3.4.4 then curl3 is 
replaced by curl4 :(


Any ideas what I could do?

Thanks

Sigbert



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




--
Sprechstunde: Fr 12-13, SPA1, R308
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] Ubuntu 18.04 / R 3.4.4 / shinyjs / V8

2018-06-06 Thread Sigbert Klinke

Hi,

if I want to use shinyjs package then I need the V8 package.
Therefore I installed

apt-get install libv8-3.14-dev

and tried

install.packages("V8")

and get

** preparing package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  kann shared object 
'/home/sigbert/R/x86_64-pc-linux-gnu-library/3.4/curl/libs/curl.so' 
nicht laden:
  /usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not 
found (required by 
/home/sigbert/R/x86_64-pc-linux-gnu-library/3.4/curl/libs/curl.so)

ERROR: lazy loading failed for package ‘V8’

I also tried to install curl3, but when I install R 3.4.4 then curl3 is 
replaced by curl4 :(


Any ideas what I could do?

Thanks

Sigbert

--
Sprechstunde: Fr 12-13, SPA1, R308
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] Syntax highlighting

2018-02-13 Thread Sigbert Klinke

Hi,

I would like know if there are any plans for some "standardized" syntax 
highlighting of R code?


* Currently I'm using minted for my LaTeX slides with pygmentize and I 
do not know what scheme is used for highlighting the R code.
* RStudio uses (as default) TextMate (Text editor for MacOS) 
highlighting for R code.
* The R package "highr" just defines CSS classes and does not provide 
any default CSS file, but embeds andre simons Highlight 3.42 Software


Of course, for my students I would like to have approximately the same 
highlighting in the slides, in RStudio and in shiny.


Best Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] devtools::check "hangs"

2017-07-12 Thread Sigbert Klinke

Hi,

checking my package with check from devtools leads to the output

Functions with \usage entries need to have the appropriate \alias
entries, and all their arguments documented.
The \usage entries must correspond to syntactically valid R code.
See chapter ‘Writing R documentation files’ in the ‘Writing R
Extensions’ manual.
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking examples ...

and that is the last thing I get. Since I write shiny apps, it may 
happen that somewhere an example expects some input/interactivity and is 
not in \dontrun environment. How I can see which example currently is 
checked?


Thanks in advance

Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] Misleading error message: XML content does not seem to be XML

2017-01-30 Thread Sigbert Klinke

Hi,

using the XML package reading an XML file

library("XML")
doc  <- xmlParse(file='abc.xml')

I got the above error message. The problem was that the file was located 
at a different directory. So the file was not found rather than 
containing invalid XML.


Best Sigbert

--
http://u.hu-berlin.de/sk

__
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] readRDS problem

2016-02-24 Thread Sigbert Klinke
Hi,

thanks, using

test <<- readRDS (name)

it worked. But why?

Best Sigbert

Am 24.02.2016 um 10:39 schrieb Michael Dewey:
> Try calling it something other than data.
> 
> On 24/02/2016 09:26, Sigbert Klinke wrote:
>> Hi,
>>
>> I have two scripts, one creates a data structure (a list of data frames
>> + some attributes) and saves it via saveRDS.
>>
>> The second script reads the RDS file (outside of any function) and
>>
>> data <- readRDS (name)
>>
>> works, but
>>
>> data <<- readRDS (name)
>>
>> creates the error
>>
>> Error: cannot change value of locked binding for 'data'
>>
>> Any idea what goes wrong?
>>
>> Thanks Sigbert
>>
> 


-- 
http://u.hu-berlin.de/sk
__
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] readRDS problem

2016-02-24 Thread Sigbert Klinke
Hi,

I have two scripts, one creates a data structure (a list of data frames
+ some attributes) and saves it via saveRDS.

The second script reads the RDS file (outside of any function) and

data <- readRDS (name)

works, but

data <<- readRDS (name)

creates the error

Error: cannot change value of locked binding for 'data'

Any idea what goes wrong?

Thanks Sigbert

-- 
http://u.hu-berlin.de/sk
__
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] Setting two default CRAN servers under Windows/RStudio

2015-06-25 Thread Sigbert Klinke
Hi,

I tried the following:

local({r - getOption(repos)
   r[CRAN]   - http://local.cran.server/;
   r[MIRROR] - http://cran.mirror/;
   options(repos=r)
})

But: R seems always to take the CRAN entry first, therefore I put our
local mirror there.

If a R session starts and the CRAN server is not available then a
package is taken from the MIRROR server. If the server comes up during
the session then the next install.packages will use the CRAN server.

But if the CRAN server becomes unavailable during a session then the
MIRROR server is not checked and I get an error message download of
package 'xyz' failed.

Any ideas?

Sigbert

Am 19.06.2015 um 15:32 schrieb Thierry Onkelinx:
 We have this in our Rprofile.site This works fine. It checks each mirror
 and installs (or updates) the latest version available on all mirrors. e.g.
 abc 0.1 on RStudio and abc 0.2 on RForge, then abc 0.2 from RForge gets
 installed/updated.
 
 options(
   repos = c(
 RStudio = http://cran.rstudio.com/;,
 RForge = http://r-forge.r-project.org;,
 Belgium = http://www.freestatistics.org/cran/;,
 CRAN = http://cran.at.r-project.org/;,
 Oxford = http://www.stats.ox.ac.uk/pub/RWin;
   ),
   install.packages.check.source = no
 )


-- 
http://u.hu-berlin.de/sk

__
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] Setting two default CRAN servers under Windows/RStudio

2015-06-19 Thread Sigbert Klinke
Hi,

we are running in our network a non-public CRAN mirror. I got it working
with the entry in Rprofile.site

local({r - getOption(repos)
   r[CRAN] - http://local.cran.server;
   options(repos=r)
})

In case that our CRAN mirror does not work we want to send the R/RStudio
users to a public server. I tried

1.
local({r - getOption(repos)
   r[CRAN] - c(CRAN=http://local.cran.server;, r)
   options(repos=r)
})

- install.packages offered the list of public mirrors

2.
local({r - getOption(repos)
   r[CRAN] - c(r, CRAN=http://local.cran.server;)
   options(repos=r)
})

- packages are taken from cran.rstudio.com

3.
local({r - getOption(repos)
   r[CRAN] - c(r[CRAN], CRAN=http://local.cran.server;,
r[CRANextra])
   options(repos=r)
})

- packages are taken from cran.rstudio.com

None of the solutions worked under RStudio, the packages are always
installed from the public servers. Any ideas?

Thanks Sigbert
__
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] Feature or bug?

2015-05-21 Thread Sigbert Klinke
Hi,

if I run

update - function (newtime) { ginput - list(time=newtime)}

server - function (input) {
  print(paste(Before, input$time))
  update(1)
  print(paste(After:, input$time))
}

ginput - list(time=0)
server(ginput)

then I get as result

[1] Before 0
[1] After: 0

If I uncomment the first print

update - function (newtime) { ginput - list(time=newtime) }

server - function (input) {
  #print(paste(Before, input$time))
  update(1)
  print(paste(After:, input$time))
}

ginput - list(time=0)
server(ginput)

then I get

[1] After: 1

Even when I use a side effect (by assign some new value to a global
variable) I would have expected the same behaviour in both cases.

Sigbert

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


Re: [R] R vs. RStudio?

2015-01-13 Thread Sigbert Klinke
On 12.01.2015 09:01, peter dalgaard wrote:
 
 On 11 Jan 2015, at 11:30 , Duncan Murdoch murdoch.dun...@gmail.com wrote:


 - I don't like the tiled display.  I find it doesn't give me enough space.

 
 This is a mixed blessing. For teaching purposes, it helps avoid shuffling 
 windows to uncover the editor, graph window, and terminal in order to 
 demonstrate various points. 
 (One can fairly quickly get used to do that for one's own purposes, but in 
 the classroom it becomes noise on the line.) However, the graph tile rather 
 too easily get into the Figure margins too large issue and readability of 
 the text tiles can become a problem.
 

For teaching purposes (Windows computers) I do not even introduce the R
GUI, I only use R Studio. I like the compact the view of the editor,
command line window, variables and graphics. Additionally it is
available for all OS's (Mac, Linux, Windows).

But a real pain in the editor is its cleverness about opening and
closing brackets, apostrophs and double apostrophs. Very often I when
run the program block/line there are too much or too few brackets,
apostrophs or double apostrophs :(

Best Sigbert
__
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] Localization of R script output

2014-06-27 Thread Sigbert Klinke
Hi,

I have written some R scripts for a server which display the result on a
webpage. I would like to localize the output to the webpage depending on
the users choice.

Therefore I prepared some po files. Exist some possibility to utilize
the gettext command of R? As far as I see I can not set the language
from within R.
Or exists a package to read in and handle mo files?

Thanks in advance

Sigbert

__
R-help@r-project.org mailing list
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] Mailing list for download

2010-07-29 Thread Sigbert Klinke
Hi,

is it possible to get all the mails of the mailing list / mail archives
for download (preferably in XML format)?

Thanks Sigbert

__
R-help@r-project.org mailing list
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] Access to R help database

2010-07-19 Thread Sigbert Klinke
Hi,

from the documentation of help.search I think that fields like concept
and keywords in the R help database exists. How can I access them from R?

If I do

 help-help.search(blabla)
 colnames(help$matches)
[1] topic   title   Package LibPath

then I get back only back these 4 fields.

Thanks Sigbert

__
R-help@r-project.org mailing list
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] cmdscale error message - k' must be in {1, 2, .. n - 1}

2010-02-22 Thread Sigbert Klinke
Hi,

I got the error message:

Error in cmdscale(1 - similarity, k = 1) :
  'k' must be in {1, 2, ..  n - 1}

It turned out that similarity was just a scalar and therefore n-1 = 0 :(

Maybe the error message could be improved.

Bset Sigbert

__
R-help@r-project.org mailing list
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] playwith error message

2010-02-01 Thread Sigbert Klinke
Hi,

I'am using the playwith library to write my own small GUI application.
But I get the following error under Windows and Linux (Ubuntu):

Error in if ((modeOK %in% c(Identify, Brush))  (actions$ident == :
  Fehlender Wert, wo TRUE/FALSE nötig ist

Under linux my R program simply continues, but under Windows it stops.
Since it is not in my code, has anyone an idea what goes wrong? I most
of the generated picture it is not possible to Brush or Identify.

Thanks in advance

Sigbert

__
R-help@r-project.org mailing list
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] playwith error message

2010-02-01 Thread Sigbert Klinke
Hi,

 Can you post a reproducible example that leads to this error?

myplot - function(x) {
  plot(x)
}

efaApp - function(data, ...)
{
playwith (myplot(data[,8:9]),
click.mode = Brush,
)
}

efaApp(as.data.frame(Boston))

My plot routines even return invisibly a list itself.

  Under linux my R program simply continues, but under Windows it stops.

I just saw that under Windows my program continues as well, just the
GTK+ window was minimized.

Thanks Sigbert

__
R-help@r-project.org mailing list
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] Move legend text to the left legend box border

2009-08-19 Thread Sigbert Klinke
Hi,

in legend I'am coloring my text rather than using symbols or lines:

legend(bottomleft, txt, text.col=col, cex=0.7)

However, between the left legend box border and the text in txt is a
large empty space. Can I somehow move the text more to the left and get
also a smaller legend box?

Thanx in advance

Sigbert

__
R-help@r-project.org mailing list
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] Correlation Network Diagram - Correction

2009-07-03 Thread Sigbert Klinke
Hi,

the igraph package will be able to do the job.

Yours sincerely

Sigbert Klinke

__
R-help@r-project.org mailing list
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] Function to eliminate blank space within strings?

2009-07-03 Thread Sigbert Klinke
Hi,

 Is there an specific function
 to eliminate blank space within
 strings?
 Thanks

gsub( , , txt)

Sigbert

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


Re: [R] How to replace values?

2009-04-30 Thread Sigbert Klinke
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

If the coding would start at 1 rather than 0 then +1's in the
penultimate line could be eliminated.

Sigbert

- ---

gene - c(YAR003W, YAR007C, YAR008W, YBL035C, YBL111C, YBL112C)
print(gene)
to   - c(0,1,3,2) # to   - c(1,2,4,3)
from - c(1,5,4,3) # from - c(2,6,5,4)
gene[to+1] - gene[from+1] # gene[to] - gene[from]
print(gene)
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD4DBQFJ+YKUWvYUYQkj1zkRAjlVAJ9NrHySXnFCUmyBS7XbBwgAeOu1XQCVHvCa
omPs62LERNyQJ/+I9uL52g==
=seex
-END PGP SIGNATURE-

__
R-help@r-project.org mailing list
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] Vizualization of points within sets

2009-04-21 Thread Sigbert Klinke
Hi,

 I have a visualization question regarding sets. My problem is as follows:

I would define a distance matrix for the points as

d_ij = 0 if the points in the same set and 1 if not

In case that points can be in more than two sets use an more appropriate
distance measure, e.g. Jaccard etc. Then run a nonmetric
(two-dimensional) multidimensional scaling (package: MASS, function:
isoMDS) to determine the point positions. But I'am not sure that it will
be easy to draw the set borders.

Yours sincerely

Sigbert Klinke

__
R-help@r-project.org mailing list
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] Factor Analysis Output from R and SAS

2009-03-31 Thread Sigbert Klinke
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

 I ran factor analysis using R and SAS. However, I had different outputs from
 R and SAS.
 Why they provide different outputs? Especially, the factor loadings are
 different.
 I did real dataset(n=264), however, I had an extremely different from R and
 SAS.
 Why this things happened? Which software is correct on?

factanal uses ML-method for estimating the loadings. SAS and SPSS use
the principal component method. Maybe you should better use princomp +
varimax. However, the rotated solutions are basically the same :)

Yours sincerely

Sigbert
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJ0gWdWvYUYQkj1zkRAi/NAJ9gHEcXbYzafE9MEbL8ZnCY/B8inwCeORuB
0vQ81ucg86IrkJl+EJSP1n0=
=lDR6
-END PGP SIGNATURE-

__
R-help@r-project.org mailing list
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] scope of variables in R

2009-03-31 Thread Sigbert Klinke
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

A) you should give and return the variables through input/output
parameter of the functions, e.g.

pwtset - function(n, inout) {
  if (n  100){
inout$ncof - n
  } else {
inout$ncof - n -100
  }
  ...
  return(inout)
}

ford - function(inout) {
  ...
  n - 104
  inout - pwtset(n, inout)
  print(inout$ncof)
  ...
  return (inout)
}

inout - list(ncof=0, ioff=0, joff=0, sig=0.0)
inout - ford(inout)
...

B) If you really need access to the global variables then use assign
and get

pwtset - function(n) {
  if (n  100){
ncof - n
  } else {
ncof - n -100
  }
  assign (ncof, ncof, envir=.GlobalEnv)
  ...
  return(inout)
}

ford - function(inout) {
  ...
  n - 104
  inout - pwtset(n, inout)
  ncof  - get(ncof, envir=.GlobalEnv)
  print(ncof)
  ...
}

...
ford()
...

This programing style has a serious disadvantage: Debugging can become
very difficult, since the value of ncof in .GlobalEnv might not be what
you expect.

Yours sincerely

Sigbert
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJ0g4jWvYUYQkj1zkRAiopAJ49Vo+NriS+R7/24QGwtPB43wI/HQCdGvYE
PjgZ+Vn0P30D5S3WvJrMX9s=
=e9rL
-END PGP SIGNATURE-

__
R-help@r-project.org mailing list
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] Graphic device graphics primitives

2009-01-29 Thread Sigbert Klinke

Hi,

I know that some graphics devices in R store graphics primitives such 
that a redraw is possible (e.g. when resizing the window). Is it 
possible to get the current number of stored graphic primitives?


Thanks in advance

Sigbert Klinke

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


Re: [R] R on a eeepc 901 ?

2008-09-17 Thread Sigbert Klinke

Hi,

it seems that the directions in
http://wiki.r-project.org/rwiki/doku.php?id=getting-started:installation:eeepc 



refer to installing R on a eeepc 701 and actually

Yes, it does :)


fail for a 901 at the first step.

What exactly failed? You are actually do not need the KDE desktop.

Greetings Sigbert

__
R-help@r-project.org mailing list
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.