Have you considered "Ecfun::asNumericChar" (and
"Ecfun::asNumericDF")?
DF <- data.frame(variable = c("12.6% ", "30.9%", "61.4%", "1"))
Ecfun::asNumericChar(DF$variable)
[1] 0.126 0.309 0.614 1.000
If you read the documentation including the examples, you will
see that many of the
Dear Don,
Have a look at the knit_expand() function. Then you can create two Rmd
files. One main file and one template file for the subsets. knit_expand()
will find and replace anything between double curly brackets ("{{x}}" in
the example below) with the value of the variable.
The main file:
--
## Don,
## This is how I would approach the task of a set of coordinated plots.
## I would place individual plots inside a table. The rows would index the
## datasets and there would be one or more data or description columns
## in addition to the column containing the graphs.
## I use the micro
Hello everyone,
I'm trying to generate tables of my data out of R for my report.
My data is setup in the format as follows and the example can be found at:
http://doylesdartden.com/R/ExampleData.csv
LocationDateYear GW_Elevation
127(I)5/14/2006 2006 752.46
Hello,
I'm trying to get a package to pass win-builder and have been having a
bit of trouble with Windows R and binary files (in my case a small
.tar.gz used in testing). After a little debugging, I think I've
narrowed it down to download.file() truncating files to the first '1a'
byte (often used f
Hello,
This is a very frequent question.
I could rewrite one or two answers taken from StackOverflow:
https://stackoverflow.com/questions/5890584/how-to-reshape-data-from-long-to-wide-format
But there you will have more options.
Hope this helps,
Rui Barradas
On 20/08/2018 20:17, David Doyl
I would like to use plotmath to annotate a plot with an expression that
includes a logical operator.
## works well
tmp <- expression(x >= 3)
plot(1)
mtext(tmp)
## not so well
tmp <- expression(x >= 3 & y <= 3)
plot(1)
mtext(tmp)
Although the text that's displayed makes sense, it won't be obvi
Please ignore my last post/inquiry... I have solved the problem. Thanks
again for the help!
On Sun, Aug 19, 2018 at 5:43 PM Sparks, John wrote:
> I agree with Jeff. The data type is the problem. I wrote what I wrote
> without looking at the problem very carefully.
>
>
> --JJS
>
>
> --
Dear all,
I have the following function
kdenor <- function(aa,q=NULL){
a=sample(aa,500,replace=F)
ab=quantile(a, p=0.75)-quantile(a, p=0.25)
h=(0.9*min(var(a),ab))/(1.34*n^(1/5))
if(is.null(q)) {
q = seq(min(a)-3*h, max(a)+3*h, length.out=length(a))
}
nx = length(a)
nq = length(q)
xmat = matrix
Hi David,
As you want the _values_ of Year from the initial data frame appended
to the _names_ of GW_Elevation, you can't do it the easy way:
dddf<-read.table(text="LocationDateYear GW_Elevation
127(I)5/14/2006 2006 752.46
119(I)5/14/2006 2006
This is clumsy and probably subject to considerable improvement, but does
it work for you:
left <- quote(x >= 3)
right <- quote(y <= 3) ## these can be anything
## the plot:
plot(1)
eval(substitute(mtext(expression(paste(left, " & ",right))), list(left =
left, right = right)))
## Expression eval
If departing from base R into contributed territory, tidyr::spread is
well-suited to this.
library(dplyr)
library(tidyr)
dta <- read.csv( "http://doylesdartden.com/R/ExampleData.csv";
, header = TRUE
, as.is = TRUE
)
result <- ( dta # starting with
Thanks Bert!
It certainly works for the example (and shows a much deeper understanding of
eval, substitute, etc. than I have). But it doesn't appear to generalize very
well in the way I need (which of course I didn't think of mentioning until
after I sent the email -- sorry).
Suppose subs is a
As I understand it, the problem is:
"A mathematical expression must obey the normal rules of syntax for
any *R* expression,
but it is interpreted according to very different rules than for normal *R*
expressions."
I believe this means that you cannot do what you wanted to using plotmath.
Cheers,
A generalization of Bert's suggestion is
plotSubset <- function (data, subset, qsubset = substitute(subset))
{
sdata <- data[eval(qsubset, data), ]
with(sdata, plot(x, y, main = subsetToPlotmath(expr = qsubset)))
}
subsetToPlotmath <- function(expr) {
# Argument 'expr': an expression
Hello,
One of those would be with package reshape2.
dta <- read.csv( "http://doylesdartden.com/R/ExampleData.csv";)
subdta <- dta[, c("Location", "Year", "GW_Elevation")]
res <- reshape2::dcast(subdta, Location ~ Year, value.var = "GW_Elevation")
names(res)[-1] <- paste("GW_Elevation", names
Sorry, there is no need to subset the data frame,
reshape2::dcast(dta, etc)
will do the same.
Rui Barradas
On 21/08/2018 05:10, Rui Barradas wrote:
Hello,
One of those would be with package reshape2.
dta <- read.csv( "http://doylesdartden.com/R/ExampleData.csv";)
subdta <- dta[, c("Locat
## I would use microplot in this situation.
## This example produces a pdf file containing the graph.
library(lattice)
library(microplot)
## Hmisc options for pdflatex
## graphics files are .pdf
latexSetOptions()
RtoLatex <- function(subset , subset.char=substitute(subset)) {
## you might need
Hello,
I have a list of lists. The lists in the list of lists are file names. I
use lapply to read and merge the contents of each list in the list of lists
(3 merged contents in this case which will be the content of 3 files).
Then, I have to change the name of the 3 resulting files and final
19 matches
Mail list logo