> identical(as.list(x), xz)
[1] TRUE
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Oct 26, 2015 at 6:31 PM, Erin Hodgess wrote:
> Hello!
>
> The following (which is a toy example) works fine, but I wonder if there is
> a better or more elegant way than to do the loop:
>
> xz <- vector("l
Beautiful
Thanks so much!
Erin
On Mon, Oct 26, 2015 at 8:47 PM, Fox, John wrote:
> Dear Erin,
>
> How about
>
> > x <- 6:9
> > as.list(x)
> [[1]]
> [1] 6
>
> [[2]]
> [1] 7
>
> [[3]]
> [1] 8
>
> [[4]]
> [1] 9
>
> Best,
> John
>
> -
> John Fox, Professor
> McMast
Dear Erin,
How about
> x <- 6:9
> as.list(x)
[[1]]
[1] 6
[[2]]
[1] 7
[[3]]
[1] 8
[[4]]
[1] 9
Best,
John
-
John Fox, Professor
McMaster University
Hamilton, Ontario
Canada L8S 4M4
Web: socserv.mcmaster.ca/jfox
> -Original Message-
> From: R-help [mailto
Hello!
The following (which is a toy example) works fine, but I wonder if there is
a better or more elegant way than to do the loop:
xz <- vector("list",length=4)
x <- 6:9
for(i in 1:4)xz[[i]] <- x[i]
xz
[[1]]
[1] 6
[[2]]
[1] 7
[[3]]
[1] 8
[[4]]
[1] 9
This does exactly what I want, but th
Hello Jean!
Thanks very much for your help and assistence! Works very fine!
All best,
Raoni
2015-10-26 17:02 GMT-02:00 Adams, Jean :
> Raoni,
>
> You could write your own function to do this. For example, using the period
> class from the R package lubridate, you could do something like this:
Just to elaborate on Marc's comment:
> set.seed(42)
> x <- runif(1)
> dput(x) # What R is storing as x
0.914806043496355
> print(x)# Ways to display an approximation of x
[1] 0.914806
> print(x, digits=3)
[1] 0.915
> round(x, 2)
[1] 0.91
> signif(x, 4)
[1] 0.9148
> library(
Hi Alexander,
I suspect that when you write "try" you mean that you try to run the
function with some value for "pid". The "unexpected symbol" error message
usually includes the offending symbol and that will probably identify the
problem.
Jim
On Mon, Oct 26, 2015 at 1:20 PM, wrote:
> Hello,
>
Thanks for this. I knew that na.exclude() existed, but never understood how to
combine it with naresid().
David C
-Original Message-
From: William Dunlap [mailto:wdun...@tibco.com]
Sent: Monday, October 26, 2015 1:46 PM
To: David L Carlson
Cc: Martin Canon; R help
Subject: Re: [R] y2z q
On 26/10/2015 12:43 PM, Judson wrote:
> How do I control the number of digits to display,
> say, in a matrix, without rounding or losing accuracy
> in subsequent calculations?
> round() of course reduces accuracy.
>
> Also, if all my results
> are really fractions, is there a way to displ
> On Oct 26, 2015, at 11:43 AM, Judson wrote:
>
> How do I control the number of digits to display,
> say, in a matrix, without rounding or losing accuracy
> in subsequent calculations?
> round() of course reduces accuracy.
>
> Also, if all my results
> are really fractions, is there a
> myMatrix <- outer(c(1,24,30,75,96), 20:25, "/")
> print(myMatrix, digits=3)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 0.05 0.0476 0.0455 0.0435 0.0417 0.04
[2,] 1.20 1.1429 1.0909 1.0435 1. 0.96
[3,] 1.50 1.4286 1.3636 1.3043 1.2500 1.20
[4,] 3.75 3.5714 3.4091 3.2609 3.1250 3.00
[5,] 4
Show us the output of
str(tmp_df)
Your problem could be caused by the Democratic column being
a character or factor column instead of a numeric column:
"71" > "227" but 71 < 227.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Oct 26, 2015 at 9:08 AM, Jim Burke wrote:
> tmp_df[order(tmp_
Dear Judson,
Perhaps the following example would give you some ideas:
R> options(digits = 4)
R> rnorm(5)
#[1] -0.57089 -0.14759 0.05717 -0.04935 2.22123
R> options(digits = 3)
R> rnorm(5)
#[1] 0.789 0.616 0.156 -1.315 -1.090
R> options(digits = 2)
R> rnorm(5)
#[1] -1.04 -0.58 -0.50 0.30 0.
tmp_df[order(tmp_df$Democratic),]
Precinct Last.Name Democratic Republican.Total Registered.Voters
2 2904 Open Seat 1015
NA 2903 Open Seat227 245 2035
3 2905 Open Seat 71 202
How do I control the number of digits to display,
say, in a matrix, without rounding or losing accuracy
in subsequent calculations?
round() of course reduces accuracy.
Also, if all my results
are really fractions, is there a way to display
them as fractions of integers rather than
decim
Raoni,
You could write your own function to do this. For example, using the
period class from the R package lubridate, you could do something like this:
days2 <- function(x) {
h1 <- 24*x
h <- floor(h1)
m1 <- 60*(h1 - h)
m <- floor(m1)
s <- round(60*(m1 - m))
new_period(second=s, minu
Hello R-Helpers!
I have a vector of times of events that time is fraction of 1, because
it was calculated in excel. Are there some way to format a period
greater than 24h in a format like excel [h]:mm:ss?
Exemple:
test = c(1.424708, 0.028674)
> chron (times. = test [2], format = "h:m:S")
[1] 00
You can also use the na.exclude function, which is like na.omit but attaches
an attribute, "na.action", telling which rows were removed. Then use the
naresid function to insert NA's into the right places in the output of
the function
that only works properly on NA-less data. E.g.,
cleanData <- n
On 26/10/2015 11:43 AM, Ming-Lun Ho wrote:
Hi All,
So, coming back to the original point, how do I get the info to change
the documentation to someone who has the capability to do so? For all I
know, that could be one of you who responded, but I wouldn't know.
Posting the suggestion here i
On 26/10/2015 12:38 PM, peter dalgaard wrote:
pmax() should work even without the fancy stuff. However, as Petr pointed out, so should
the ifelse construct, unless there is more to the issue than we have been told. So I
think Jennifer needs to elaborate on the "didn't work" aspect...
Her synt
pmax() should work even without the fancy stuff. However, as Petr pointed out,
so should the ifelse construct, unless there is more to the issue than we have
been told. So I think Jennifer needs to elaborate on the "didn't work" aspect...
-pd
On 26 Oct 2015, at 13:02 , Erich Neuwirth wrote:
>
Thank you, David.
This solves the problem.
Regards,
Martin
On Sun, Oct 25, 2015 at 12:53 PM, David L Carlson wrote:
> It looks like the y2z() function strips NA's so that the vector lengths do
> not match any longer. The simplest workaround is to remove the NA's. You
> could do that by using
Hello again,
Thanks for your reply and sorry for my own late reply! I am writing from a
normal yahoo account so i don't know why it behaves like this. I was looking to
avoid the expand.grid command because my matrices are of size 800x800 (i have
some filters that exclude out some elements, so i
Hi All,
So, coming back to the original point, how do I get the info to change
the documentation to someone who has the capability to do so? For all I
know, that could be one of you who responded, but I wouldn't know.
Thanks.
--Ming
On Sun, Oct 25, 2015, 08:11 peter dalgaard wrote
Hello R-Helpers!
I have a vector of times of events that time is fraction of 1, because it
was calculated in excel. Are there some way to format a period greater than
24h in a format like excel [h]:mm:ss?
Exemple:
test = c(1.424708, 0.028674)
> chron (times. = test [2], format = "h:m:S")
[1] 00
I have not used W10, but for quite awhile the *administrator" account (not the
hidden one named "Administrator") has merely had the right to "Run As
Administrator"... but doing so explicitly is not recommended unless you
definitely know what you are doing (in which case you should not be asking
I uninstalled all versions of R on my computer and killed all R directories (I
think).
I am wondering that since I “upgraded” to Windows 10 is it possible that I
should create a user separate from the administrator account? My previous
version of Windows was 7 Home I think.
Here is a longer v
Hhi Ujjwal
As Jim says a lot of people don't like the barplot with error bars approach see
http://biostat.mc.vanderbilt.edu/wiki/Main/DynamitePlots and links for some of
the reasons why.
Besides, in Tufte's terms most of a barplot is 'chart junk'.
John Kane
Kingston ON Canada
> -Origina
> From: Omar André Gonzáles Díaz
> Subject: [R] regex not working for some entries in for loop
>
> I'm using some regex in a for loop to check for some values in column
> "source",
> and put a result in column "fuente".
Your regexes are on multiple lines and include whitespace and linefeeds. F
data <- within(data,variable3=pmax(variable1,variable2))
also should work if your variables are numeric.
using dplyr and magrittr (which I recommend to all my students)
it could be
library(dplyr)
library(magrittr)
data %<>% mutate(variable3=pmax(variable1,variable2))
> On 26 Oct 2015, at 12:53
Hi
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan
> Murdoch
> Sent: Monday, October 26, 2015 11:58 AM
> To: Lorenz, Jennifer; r-help@r-project.org
> Subject: Re: [R] Creating new variables in R
>
> On 26/10/2015 6:24 AM, Lorenz, Jennifer wrote
On 25/10/2015 7:44 PM, Boris Steipe wrote:
> Ming is right. I can't imagine other discipline's standards are substantially
> different from ours, but e.g. the ACS style manual is very explicit to
> require ...
>
>"Label each axis with the parameter or variable being measured and the
> units
On 25/10/2015 10:20 PM, alexander.thoma...@louisville.edu wrote:
> Hello,
>
> I'm following an example in the book, analyzing baseball data with R, but
> it's not working for me. The example is:
We don't know what "the book" is. If this is the textbook for your
class, you should ask your instru
On 26/10/2015 6:24 AM, Lorenz, Jennifer wrote:
> Hi,
>
> I have a question regarding the creation of new variables on the basis of
> existing ones in R.
>
> I have two variables containing information on parents' educational degree
> (e.g. 1 'high school degree', 2 'college degree', etc.). I w
Dear Forum,
I have series of say 100 (say equity) instrument prices. From these prices, for
each of these 100 instruments, I generate returns using ln(current price /
previous price).
Assuming originally I had 251 prices available for each of these 100
instruments over last one year period,
Hello,
I'm following an example in the book, analyzing baseball data with R, but it's
not working for me. The example is:
compute.hr <- function(pid){d <- subset(Batting.60, playerID==pid)
sum(d$HR)}
Every time I try this, it says there's an unexpected symbol. Any idea on what
the unexpected s
On Mon, Oct 26, 2015 at 10:44 AM, Boris Steipe
wrote:
> Ming is right.
...
Having started all this trouble, I suppose I should offer a modest
explanation.
The OP was indeed "right" in the sense that the column heading did not
indicate the correct _units_ for the values. I suppose that "kilopou
Hi,
I have a question regarding the creation of new variables on the basis of
existing ones in R.
I have two variables containing information on parents' educational degree
(e.g. 1 'high school degree', 2 'college degree', etc.). I would like to create
a new variable for 'parents' highest edu
Hi Ujjwal,
Given that you have asked about a barplot and included standard errors, you
probably want something like the following:
uk.df<-read.table(text=
"habitat,proportion_use,proportion_use_SE,selectivity_index,selectivity_index_SE
grassland,0.56,0.22,0.72,0.29
sal_forest,0.11,0.04,-0.43,0
No worries. Just use:
abline(h=0)
Jim
On Mon, Oct 26, 2015 at 6:32 PM, Ujjwal Kumar
wrote:
> Thank you Jim for your Kind help
> The second code suits my need.
> Just another query If I need to put another line (horizontal, same as x-
> axis that passes through zero (0.0), and actually divide n
40 matches
Mail list logo