Anupam,
This is very general, and it also depends on the scientific domain.
Factors do solve the value labels, but they drop the (original) values.
They also lose the connection to the different types of missing values (an
important topic in the social sciences).
Base R provides as much as it can
<- "fa\xE7ile"
> > xx <- iconv(x, "latin1", "UTF-8")
> > iconv(xx, "UTF-8", "ASCII", "c99")
> [1] "fa\\u00e7ile"
> >
> ```
>
> For future reference, you can find this in section Examples of the
&
Dear list,
Building on the example from ?iconv:
x <- "fa\xE7ile"
xx <- iconv(x, "latin1", "UTF-8") # "façile"
and:
iconv(xx, "UTF-8", "ASCII", "Unicode")
# "faile"
This is the type of result I sometimes get from an R script that I cannot
reproduce here, because it depends on a terminal process
Dear R-list,
It gives me great pleasure to announce the release of version 0.18 of
package declared, that makes a difference between empty missing values (the
current NAs in R) and declared missing values (NAs with a reason).
Besides an automatic detection of such values by most base R operations
Dear community,
Version 0.12 of the package declared has just made it on CRAN.
Apart from the usual functions to declare labels for regular and missing
values, this version has a suite of new functions to calculate various
weighted frequencies and summaries.
The weighted versions are heavily ins
s and season's greetings,
Adrian
On Tue, 21 Dec 2021 at 21:45, Avi Gross wrote:
> I wonder if the package Adrian Dușa created might be helpful or point you
> along the way.
>
> It was eventually named "declared"
>
> https://cran.r-project.org/web/packages/declar
On Fri, 24 Dec 2021 at 17:35, Rich Shepard wrote:
> On Fri, 24 Dec 2021, Rasmus Liland wrote:
>
> > If you want to look at Rdata-files in a quick way in the
> > terminal, use this little gem in your .zshrc.local:
> >
> > readrdata() { Rscript -e "options(width=$COLUMNS); load('$1');
> sapply(ls()
Dear All,
A new package called 'declared' has made it to CRAN (platform specific
binaries in due course). This might be useful for social scientists, where
multiple (types of) missing values are declared for any given variable.
The package has a similar functionality to packages 'haven' and 'labe
Does this helps?
> formatC(x, digits = 1, format = "f")
[1] "1.0" "2.0" "2.0" "2.1"
On Thu, Jun 7, 2018 at 10:08 PM 刘瑞阳 wrote:
> 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.0
One solution, among many, involving recoding. There is a function in
package QCA called recode()
(similar, but in my opinion more flexible than the same function recode()
in package car)
> library(QCA)
> ind.davis$Ageclass <- recode(ind.davis$Ageclass, "adult = Adult; Juvanile
= Juvenile; sub-adu
There is no bug, of course, this is a common floating point arithmetic
misunderstanding.
> print(2.01, digits = 20)
[1] 2.0097868
Please search for "What every scientist should know about floating-point
arithmetic" and you'll hopefully understand what the "bug" is.
Hth,
Adrian
On
Two methods, among others:
seq1 <- paste("DQ", sprintf("%0*d", 6, seq(060054, 060060)), sep = "")
or
seq1 <- paste("DQ", formatC(seq(060054, 060060), dig = 5, flag = 0), sep =
"")
Hth,
Adrian
On Mon, Feb 6, 2017 at 3:50 AM, Nabila Arbi
wrote:
> Dear R-Help Team!
>
> I have some trouble with
Granted,, there are better solutions than my "KISS" (keep it simple and
stupid) example.
Hopefully, Christoph will have learned from both.
Best,
Adrian
On 10 Oct 2016 13:44, "PIKAL Petr" wrote:
> Hi
>
>
>
> Given this example data, you can get same answer with less typing and
> without loops.
This is an example of how a reproducible code looks like, assuming you have
three columns in your dataset named S (store), P (product) and W (week),
and also assuming they have integer values from 1 to 19, 1 to 22 and 1 to
157 respectively:
#
mydata <- expand.grid(seq(19), seq(22), seq(15
It would help to have a minimal, reproducible example.
Unless revealing the structure of your FD object, it is difficult to
understand how a column having 61327 values would be "consistent over an 1
to 157 interval": is this interval cyclic until it reaches 61327 values?
>From your example using F
quot; bar <- \"don't ; use
semicolons\""
[3] " foo <- '3;4'" " ls("
Excellent, thanks very much,
Adrian
On Mon, Sep 19, 2016 at 3:19 PM, Duncan Murdoch
wrote:
> On 19/09/2016 7:59 AM, Adrian Dușa wrote:
On Sun, Sep 18, 2016 at 12:34 AM, Peter Langfelder <
peter.langfel...@gmail.com> wrote:
> On Sat, Sep 17, 2016 at 2:12 PM, David Winsemius
> wrote:
> > Not entirely clear. If you were intending to just get character output
> then you could just use:
> >
> > strsplit(txt, ";")
>
> You would want t
:
[1] "print(2)" "ls("
I hope this explains the situation,
Adrian
On Thu, Sep 15, 2016 at 11:02 PM, Adrian Dușa wrote:
> On Thu, Sep 15, 2016 at 10:28 PM, William Dunlap
> wrote:
>
>> The most reliable way to split such lines is with parse(text=x).
>> Regu
On Thu, Sep 15, 2016 at 10:28 PM, William Dunlap wrote:
> The most reliable way to split such lines is with parse(text=x).
> Regular expressions don't do well with context-free grammars.
>
Oh, that's right of course.
> as.character(parse(text = x))
[1] "foo <- \"3;4\"""bar <-
Dear R-helpers,
When parsing a text, I would like to separate commands written on the same
line, by a semicolon.
Something like:
x <- "foo <- '3;4'; bar <- \"don't ; use semicolons\""
Ideally, that would translate to these two commands in a character vector
of length 2:
foo <- '3;4'
bar <- "don'
n 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, Sep 4, 2016 at 11:45 PM, Adrian Dușa
> wrote:
> > On Mon, Sep 5, 2016 at 2:52 AM, Bert Gunte
On Mon, Sep 5, 2016 at 5:33 PM, Bert Gunter wrote:
>
> I'm sharing this with r-help, as your detailed response might help
> others help you.
Oh, my bad (thought I had replied to all).
I wanted to add anyways the intended result seems to be possible. If
pasting the code here...:
http://www.tutori
Dear R users,
I am trying to simulate a pseudo R console, evaluating commands. This is a
simple example of a series of command lines which get evaluated:
foo <- function(x) {
print(x)
}
print)foo)
foo(2)
If I copied and pasted this example in an R console, this is the result to
replicate (a
See:
?read.fwf
Example:
> ff <- tempfile()
> cat(file = ff, "10030614911608", "10030614911608", sep =
"\n")
> read.fwf(ff, widths = c(2,8,10), colClasses = "character")
V1 V2 V3
1 10 03061490 000116
2 10 03061490 000116
> unlink(ff)
Hth,
Adrian
On Thu,
I think you are not using the best function for what your intentions are.
Try:
> by(data=mtcars, INDICES=list(as.factor(mtcars$am)), FUN=colMeans)
: 0
mpg cyldisp hpdrat wt
qsec vs
17.1473684 6.9473684 290.3789474 160.2631579 3.286
onment(object)) {
> object <- as.list(object)
> names <- names(object)
> for (i in seq_along(object)) {
> str.language(object[[i]], ..., level = level + 1,
> name = names[i])
> }
> }
> a$names <- NUL
ring anyways (which is parsed by other functions).
On Tue, Apr 12, 2016 at 6:20 PM, Richard M. Heiberger
wrote:
> Would making it regular function %=>%, using "%" instead of quotes,
> work for you?
>
> On Tue, Apr 12, 2016 at 11:09 AM, Adrian Dușa
> wrote:
> >
On Tue, Apr 12, 2016 at 2:08 PM, Duncan Murdoch
wrote:
> [...]
>
> It never gets to evaluating it. It is not a legal R statement, so the
parser signals an error.
> If you want to pass arbitrary strings to a function, you need to put them
in quotes.
I see. I thought it was parsed inside the funct
I have a simple function such as:
foo <- function(x) {
call <- lapply(match.call(), deparse)
testit <- capture.output(tryCatch(eval(x), error = function(e) e))
if (grepl("Error", testit)) {
return(call$x)
}
}
and I would like to detect a formula when x is not an object:
#
I suspect it is a problem related to locales: R and the base Ubuntu might
be using different locales, hence the source of the different sorting.
Can't say if this is the problem in your case, but it might be.
Adrian
On Sat, Apr 9, 2016 at 12:18 AM, Maria Ninova wrote:
> Hello, I came across the
Yes, that does have to do with floating point representation.
I use this function for these types of comparisons (works with values as
well as with vectors):
check.equal <- function(x, y) {
check.vector <- as.logical(unlist(lapply(x, all.equal, y)))
check.vector[is.na(check.vector)] <- FAL
Sun, Feb 21, 2016 at 11:37 AM, Adrian Dușa
> wrote:
>
>> Oh, thanks Peter, good example for Mac, but indeed not working on Windows.
>> For a completely cross-platform solution (that is, including Windows which
>> is what Zahra wants), I believe shiny is the right tool.
>
("exit")
>
> Make it executable (chmod +x foo.app) and you can double-click it in the
> Finder. (Notice that as written, there is nothing to shut down the tkwait
> loop, so you'll have to force quit it.)
>
> Peter D.
>
> > On 19 Feb 2016, at 23:36 , Adrian Dușa
I don't know about RGtk2, never tried it, but I assume it is similar to
Tcl/Tk situation: you need to open an R console to make it work.
My approach works, only because I am using the package shiny, and R's web
server can be started via a script in the terminal.
I might be wrong of course, but I ha
de
> you've written?
>
> ------
> * From: * Adrian Dușa ;
> * To: * Greg Snow <538...@gmail.com>;
> * Cc: * simon0...@yahoo.com ; r-help@r-project.org <
> r-help@r-project.org>;
> * Subject: * Re: [R] How to create an executable file from R GUI?
> * Sent: * Thu
Simon, Greg,
That is the very reason why I've given up on Tck/Tk, in favor of shiny.
The user interface opens up in a webpage, without opening the normal R
console (it only opens a Terminal window).
To exemplify, package QCAGUI has a function called runGUI(), and on Windows
it's a simple matter o
On Wed, Feb 17, 2016 at 12:04 PM, Jan Kacaba wrote:
> In my original data a csv file I have missing values. If I use read.table
> the missing values are replaced by NAs.
>
That is the normal way of dealing with missing values, in R.
Is it possible to get object where missing values aren't repl
Try this:
mylist <- list("pc_m2_45_ssp3_wheat", "pc_m2_45_ssp3_wheat", "ssp3_maize",
"m2_wheat")
mylist <- lapply(mylist, function(x) unlist(strsplit(x, split="_")))
allstrings <- unique(unlist(mylist))
lapply(mylist, function(x) allstrings[match(allstrings, x)])
[[1]]
[1] "pc""m2""45"
Dear R users,
I would like to announce a new package that has just the appeared on CRAN,
called "venn" version 1.0:
http://cran.r-project.org/web/packages/venn/
(binaries will appear in one or two days)
Although there are quite a few packages that draw Venn diagrams, there are
a number of reasons
splines can be made similar to Bezier curves
> (but not exactly the same). The function returns a set of coordinates
> (when draw=FALSE) that represent line segments for drawing the
> approximate curve.
>
> On Wed, Jan 6, 2016 at 6:43 AM, Adrian Dușa wrote:
> > I just found
I just found the package "bezier".
Trying to find the needle, I missed the haystack...
On Wed, Jan 6, 2016 at 9:56 AM, Adrian Dușa wrote:
> Dear All,
>
> I am interested into transforming Bezier curves (or general splines) to a
> series of line segments.
> For simplici
Dear All,
I am interested into transforming Bezier curves (or general splines) to a
series of line segments.
For simplicity, the Bezier curves are either cubic (arches, no inflection
points) or they have at most one inflection point.
The entry parameters are exactly four points (with x and y coor
it hypo-caffeinated ... ;-)
>
> Regards,
>
> Marc
>
>
> > On Dec 11, 2015, at 9:12 AM, Adrian Dușa wrote:
> >
> > Thanks very much, Marc and Jeff.
> > Jeff's solutions seem to be simple one liners. I really need to learn
> these
> > things, too
e hardly R-specific.
>
> --
> Sent from my phone. Please excuse my brevity.
>
> On December 11, 2015 5:50:28 AM PST, "Adrian Dușa"
> wrote:
>>
>> For the regexp aficionados, out there:
>>
>> I need a regular expression to extract either everything with
For the regexp aficionados, out there:
I need a regular expression to extract either everything within some
brackets, or everything outside the brackets, in a string.
This would be the test string:
"A1{0}~B0{1} CO{a2}NN{12}"
Everything outside the brackets would be:
"A1 ~B0 CO NN"
and everythi
Hi Greg,
On Wed, Dec 2, 2015 at 10:28 PM, Greg Snow <538...@gmail.com> wrote:
>
> Adrian,
>
> Draw the polygon once without the border and the whole in it, then go
> back and draw the border around the outer polygon without any fill.
I thought about it too, but this only works on a Windows machin
On Wed, Dec 2, 2015 at 10:38 PM, Michael Sumner wrote:
>
> On Wed, 2 Dec 2015 at 23:10 Adrian Dușa wrote:
>
>> Dear All,
>>
>> I know how to fill a polygon, using a basic R graphics device:
>>
>> par(mai=c(0, 0, 0, 0))
>> plot(1:100, type="
On Wed, Dec 2, 2015 at 5:19 PM, David L Carlson wrote:
>
> Using only base graphics, one solution would be to embed the inner
polygon in the outer one and turn off the border:
>
> par(mai=c(0, 0, 0, 0))
> plot(1:100, type="n")
> polygon(c(0, 100, 100, 0, 0, 20, 80, 80, 20, 20, 0),
> c(0, 0, 1
Dear All,
I know how to fill a polygon, using a basic R graphics device:
par(mai=c(0, 0, 0, 0))
plot(1:100, type="n")
polygon(c(20, 80, 80, 20), c(20, 20, 80, 80), col="lightblue")
But let's say I have an outer polygon like this:
polygon(c(0,100,100,0), c(0,0,100,100))
Is it possible to fill t
On Fri, Nov 27, 2015 at 4:03 PM, Dirk Eddelbuettel wrote:
>
> On 27 November 2015 at 15:43, Adrian Duşa wrote:
> | Is there a method to detect the computer's drives?
> | That would include USB sticks, when they are recognised by the operating
> | system.
>
> That is very obviously OS-dependent am
Dear All,
Is there a method to detect the computer's drives?
That would include USB sticks, when they are recognised by the operating
system.
I believe to have read somewhere it's possible, but I am unable to find
that message.
Thank you for any hint,
Adrian
--
Adrian Dusa
University of Bucha
Dear list,
Probably not the best subject line, but hopefully I can explain.
I would like to use R and open a connection to a (system) command line base
chess engine
(for example, there is an open source one at stockfishchess.org)
In the Terminal window (using MacOS), I can type two commands:
$ .
On Thu, Mar 12, 2015 at 9:52 PM, John McKown
wrote:
> [...]
> One problem is that Adrian wanted, for some reason, to exclude numbers
> such as "2." but accept "2.0" . That is, no unnecessary trailing
> decimal point. as.numeric() will not fail on "2." since that is a
> number. The example grep() s
: optional minus, followed by one or more digits, optionally
> followed by (a period with one or more ending digits).
>
>
> On Wed, Mar 11, 2015 at 2:27 PM, Adrian Dușa wrote:
>> Hi everyone,
>>
>> I need a regular expression to find those positions in a character
&
Hi everyone,
I need a regular expression to find those positions in a character
vector which contain something which is not a number (either positive
or negative, having decimals or not).
myvector <- c("a3", "N.A", "1.2", "-3", "3-2", "2.")
In this vector, only positions 3 and 4 are numbers, the
On Tue, Jun 3, 2014 at 8:44 PM, David Winsemius wrote:
>
> On Jun 3, 2014, at 11:03 AM, Adrian Dușa wrote:
>
>> Dear All,
>>
>> I should be knowing this, but not get it right...
>
> I'm a little surprised to see you ask this, too, but we each have lacunae
Dear All,
I should be knowing this, but not get it right... For a string like this:
"Man\Woman"
I would like to detect the escape character "\" and replace it with "/".
Tried various ways using gsub(), but don't get it right yet. Any suggestion
would be highly welcomed...
Thank you,
Adrian
--
That would be:
MyAnova$"Pr(>F)"
and since that is an Anova table, you actually only need the first value:
MyAnova$"Pr(>F)"[1]
Hope this helps,
Adrian
On Mon, Nov 4, 2013 at 4:10 PM, Anders Tisell wrote:
>
> Hi,
>
> I have created a mixed linear model with one fixed factor and two
> random fact
58 matches
Mail list logo