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
Since 2008, Microsoft staff and guests have written about R at the Revolutions
blog (http://blog.revolutionanalytics.com) and every month I post a summary of
articles from the previous month of particular interest to readers of r-help.
In case you missed them, here are some articles related to R f
which() is unnecessary. Use logical subscripting:
... t$id[t$A ==x]
Further simplification can be gotten by using the with() function:
l <- with(t, sapply(unique(A), function(x) id[A ==x]))
Check this though -- there might be scoping issues.
Cheers,
Bert
On Thu, Jun 7, 2018, 6:49 AM Massimo
?formatC (digits, drop0trailing)
?sprintf (format %f)
?cat
?options (digits)
You appear to be confusing source code formatting with output formatting. The
internal representation of a numeric value has no notion of the number of
decimals that were used to enter it into memory from source code.
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
> Gerrit Eichner
> on Thu, 7 Jun 2018 09:03:46 +0200 writes:
> Hi, Chris, had the same problem (and first thought it was
> my fault), but there seems to be a typo in the code of
> pairs.default. Below is a workaround. Look for two
> comments (starting with #) in t
Here are two options:
> # for one occurrence
> help("help", help_type="html")
starting httpd help server ... done
>
> # to set the default for your R session
> options(help_type = "html")
> ?help
If you read the help file for help(), you will see all the possibilities.
Sarah
On Thu, Jun 7, 2018
Dear Sarah, dear David,
Thank you very much indeed, this is exactly what I needed.
Best,
Dmitri
On Thu, Jun 7, 2018 at 6:39 PM, Sarah Goslee wrote:
> Here are two options:
>
> > # for one occurrence
> > help("help", help_type="html")
> starting httpd help server ... done
> >
> > # to set the d
> On Jun 7, 2018, at 8:21 AM, Dmitri Popavenko
> wrote:
>
> Dear R users,
>
> I am sometimes using R from a Terminal (either from Linux but most often on
> MacOS).
> When looking at a help file using the question mark (e.g. ?sd) the help
> file opens in the Terminal itself.
>
> If possible,
> On Jun 7, 2018, at 7:18 AM, Veerappa Chetty wrote:
>
> I use solve(A,b) inside my function, myfun2; it works fine when I return
> one value or a list.
> I want use the return values in ggplot as below: ggplot(data.frame(
> x=c(0.1,0.8)),aes(x=x))+stat_function(fun=myfun.2,geom="line")
> I get
Dear R users,
I am sometimes using R from a Terminal (either from Linux but most often on
MacOS).
When looking at a help file using the question mark (e.g. ?sd) the help
file opens in the Terminal itself.
If possible, I would like to open the HTML version of the help file in a
webpage, but I am c
I use solve(A,b) inside my function, myfun2; it works fine when I return
one value or a list.
I want use the return values in ggplot as below: ggplot(data.frame(
x=c(0.1,0.8)),aes(x=x))+stat_function(fun=myfun.2,geom="line")
I get a blank graph. Would greatly appreciate help! Thanks.
Here are my c
#ok, finally this is my final "best and more compact" solution of the problem
by merging different contributions (thanks to all indeed)
t<-data.frame(id=c(18,91,20,68,54,27,26,15,4,97),A=c(123,345,123,678,345,123,789,345,123,789))
l<-sapply(unique(t$A), function(x) t$id[which(t$A==x)])
r<-dat
thank you for the help
this is my solution based on your valuable hint but without the need to pass
through the use of a 'tibble'
x<-data.frame(id=LETTERS[1:10], A=c(123,345,123,678,345,123,789,345,123,789))
uA<-unique(x$A)
idx<-lapply(uA, function(v) which(x$A %in% v))
vals<- lapply(idx, f
Hi,
Does this do what you want? I had to change the id values to something more
obvious. It uses tibbles which allow each variable to be a list.
library(tibble)
library(dplyr)
x <- tibble(id=LETTERS[1:10],
A=c(123,345,123,678,345,123,789,345,123,789))
uA <- unique(x$
Using which() to subset t$id should do the trick:
sapply(levels(t$A), function(x) t$id[which(t$A==x)])
Ivan
--
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567
sorry, but by further looking at the example I just realised that the posted
solution it's not completely what I need because in fact I do not need to get
back the 'indices' but instead the corrisponding values of column A
#please consider this new example
t<-data.frame(id=c(18,91,20,68,54,27
Thank you Ben, this also works! I have a copy of the Sarkar but,
usually, I don't work with histograms. I'll brush it up, then. Best
regards, Luigi
On Thu, Jun 7, 2018 at 1:43 PM Ben Tupper wrote:
>
> Hi again,
>
> I'm sort of pre-coffee still, but does this do it? The data frame only has
> one
Hi again,
I'm sort of pre-coffee still, but does this do it? The data frame only has one
variable, a factor where the order of the levels is specified.
library(lattice)
group <- c("a", "b", "c", "d", "e")
freq<- c(1, 2, 2, 5, 3)
x <- rep(group, freq)
df <- data.frame(group = fa
also, with this approach, I need to re-arrange the data. Is it
possible to work directly on a dataframe?
On Thu, Jun 7, 2018 at 12:48 PM Ben Tupper wrote:
>
> Hi,
>
> Is this what you are after?
>
> group <- c("a", "b", "c", "d", "e")
> freq <-c(1, 2, 2, 5, 3)
> x = rep(group, freq)
> barplot(tabl
exactly! Thank you!
but it is possible to do it with lattice? I might have an extra level
of information, for instance super-group, and in that case, I could
plot all the supergroup easily together.
On Thu, Jun 7, 2018 at 12:48 PM Ben Tupper wrote:
>
> Hi,
>
> Is this what you are after?
>
> group
Hi,
Is this what you are after?
group <- c("a", "b", "c", "d", "e")
freq <-c(1, 2, 2, 5, 3)
x = rep(group, freq)
barplot(table(x))
Cheers,
Ben
> On Jun 7, 2018, at 6:00 AM, Luigi Marongiu wrote:
>
> Dear all,
> I have a dataframe with a column representing the names of the
> elements (a, b
Dear all,
I have a dataframe with a column representing the names of the
elements (a, b, etc) and one with their frequencies.
How can I plot the frequencies so that each element has an associated
frequency value?
I have been thinking of a histogram, but I have found it difficult to
implement. I hav
How about this:
in2mm<-25.4 # scale factor to convert inches to mm
pdf("test.pdf",width=8.3,height=11.7)
pin<-par("pin")
plot(c(0,pin[1]*in2mm),c(0,pin[2]*in2mm), type="n", xaxs="i", yaxs="i")
lines(c(10,10),c(0,10))
text(11,5,"1 cm", adj=0)
lines(c(0,40),c(20,20))
text(20,24,"4 cm")
polygon(c(
Hi Ray,
Have you done any search at all? I did a search on "R package ROC latent
variable" and got several hits.
In particular the package randomLCA seems relevant
https://cran.r-project.org/web/packages/randomLCA/vignettes/randomLCA-package.pdf
I glanced at the documentation which mentions 2 oth
thanks for the help
I'm posting here the complete solution
t<-data.frame(id=1:10,A=c(123,345,123,678,345,123,789,345,123,789))
t$A <- factor(t$A)
l<-sapply(levels(t$A), function(x) which(t$A==x))
r<-data.frame(list_id=unlist(lapply(l, paste, collapse = ", ")))
r<-cbind(unique_A=row.names(r)
Your example is not reproducible.
Perhaps read [1]
[1]
http://rstudio-pubs-static.s3.amazonaws.com/3365_9573f6d661b99365fe1841ee65d3.html
On June 6, 2018 8:04:44 PM PDT, Veerappa Chetty wrote:
>HI,
>
>I use solve(A,b) inside my function, myfun2; it works fine when I
>return
>one value or a
Hi, Chris,
had the same problem (and first thought it was my fault), but there
seems to be a typo in the code of pairs.default. Below is a workaround.
Look for two comments (starting with #) in the code to see what I
have changed to make it work at least the way I'd expect it in one of
your e
28 matches
Mail list logo