Re: [R] Mixed format

2020-01-20 Thread Rui Barradas
Hello, The following strategy works with your data. It uses the fact that most dates are in one of 3 formats, dmy, mdy, ymd. It tries those formats one by one, after each try looks for NA's in the new column. # first round, format is dmy DFX$dnew <- lubridate::dmy(DFX$ddate) na <-

[R] Mixed format

2020-01-20 Thread Val
Hi All, I have a data frame where one column is a mixed date format, a date in the form "%m-%d-%y" and "%m/%d/%Y", also some are not in date format. Is there a way to delete the rows that contain non-dates and standardize the dates in one date format like %m-%d-%Y? Please see my sample data

Re: [R] "In sqrt(VS) : NaNs produced"

2020-01-20 Thread John Kane
As a follow-up to Michael's post, here is a link to some advice on how create the example. /http://adv-r.had.co.nz/Reproducibility.html "> How to write a reproducible example On Mon, 20 Jan 2020 at 08:49, Michael Dewey wrote: > Your script and data were stripped so we are none the wiser I am

Re: [R] (no subject)

2020-01-20 Thread Jeff Newmiller
Per the Posting Guide... stop sending HTML-formatted email to this mailing list. The formatting gets stripped out anyway and introduces confusion. Gmail _has_ this option, but you must specify it before you send the email. Also, try to use Reply-all when discussing the same topic to keep

Re: [R] (no subject)

2020-01-20 Thread Jeff Newmiller
Per the Posting Guide... stop sending HTML-formatted email to this mailing list. The formatting gets stripped out anyway and introduces confusion. Gmail _has_ this option, but you must specify it before you send the email. Also, try to use Reply-all when discussing the same topic to keep

Re: [R] Converting binary number to in Two´s complement representation

2020-01-20 Thread Rui Barradas
Hello, The function I included converts signed binary numbers into their decimal representation. They are negative if a) they are multiples of 8 bits and b) the most significant bit is a "1". If not just convert to integer. As for a) above, I assume that you will have 8 bit numbers. And the

[R] Binary Number To Two´s Complement Representation

2020-01-20 Thread Paul Bernal
Dear Rui, Based on the rules given in the link below, I want to transform the binary numbers into latitude and longitude coordinates (in degrees and minutes), so that is basically what I am trying to accomplish. The first integer gives the sign (positive or negative) of the number, and the rest

[R] (no subject)

2020-01-20 Thread Paul Bernal
Example of conversion to decimal of a signed binary number in two's complement representation Let's convert to decimal the following signed binary number: 10110010 10110010 = -1×27 + 0×26 + 1×25 + 1×24 + 0×23 + 0×22 + 1×21 + 0×20 = -128 + 32 + 16 + 2 = -78. that operation ilvoves base 2 raised

Re: [R] Converting binary number to in Two´s complement representation

2020-01-20 Thread Paul Bernal
Dear friend Rui, Hope you are doing great, thanks for your kind feedback. The challenge I currently have at hand is to decode AIS messages and obtain latitude and longitude values from those. So basically, I want to accomplish something like in the example below. I want to convert this binary

Re: [R] R package for meta-analysis from z scores

2020-01-20 Thread Michael Dewey
Dear James Your question really boil down to whether you can estimate tau^2, the between study variance of the effect sizes, if you only have p-values. As far as I can see the answer has to be no. Michael On 16/01/2020 13:10, james poweraid wrote: Hello, I have a set of Z scores from an

Re: [R] "In sqrt(VS) : NaNs produced"

2020-01-20 Thread Michael Dewey
Your script and data were stripped so we are none the wiser I am afraid. You need to embed the script in your post and give a minimal data-set which exhibits the problem using dput() and embed that in the post too. Michael On 19/01/2020 08:25, Atul Saini wrote: Hello R, I am

[R] survival::clogit - how to construct data and use sampling weights

2020-01-20 Thread Valerio Leone Sciabolazza
Dear list users, I need some guidelines to run a conditional logistic regression with fixed effects. Let me give you some background. I have a survey where each respondent is asked the same question once a year for three consecutive years. There is no apriori on the extent to which choice at

Re: [R] Strange behaviour of R?

2020-01-20 Thread Rainer Krug via R-help
Hi > On 17 Jan 2020, at 08:33, Sigbert Klinke wrote: > > 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

[R] R package for meta-analysis from z scores

2020-01-20 Thread james poweraid
Hello, I have a set of Z scores from an N=2 studies and I need to run a meta-analysis across the two Z scores for many N variables. I do not have effect sizes and SEs. I realize there are many different meta analysis packages in R, but I only have Z scores and it seems to me this is limiting. I

[R] "In sqrt(VS) : NaNs produced"

2020-01-20 Thread Atul Saini
Hello R, I am attaching the script and data please help me to solve the problem of "In sqrt(VS) : NaNs produced" with the p value of dumy$Mar Regards, __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

Re: [R] Converting binary number to in Two´s complement representation

2020-01-20 Thread Rui Barradas
Sorry, missunderstood the problem. Here it goes: fun <- function(x){ res <- sapply(x, function(y){ if(nchar(y) %% 8 != 0 || substr(y, 1, 1) == "0"){ strtoi(y, base = 2) }else{ y <- unlist(strsplit(y, "")) -sum((y != "1")*2^((length(y) - 1):0)) - 1 } })

Re: [R] Converting binary number to in Two´s complement representation

2020-01-20 Thread Rui Barradas
Hello, Is this what you want? x <- "10110010" strtoi(x, base = 2) #[1] 178 Hope this helps, Rui Barradas Às 16:31 de 16/01/20, Paul Bernal escreveu: Dear friends, How can I convert the following binary number in two´s complement representation in R? 10110010 Any help and/or guidance

Re: [R] Extracting a particular column from list

2020-01-20 Thread Eric Berger
> u <- list(a=1:5, b=letters[1:3]) > u # $a # [1] 1 2 3 4 5 # # $b # [1] "a" "b" "c" > u[["a"]] [1] 1 2 3 4 5 On Thu, Jan 16, 2020 at 1:04 PM Faheem Jan via R-help wrote: > Hi. How to extract a column from the list.. I will be thanks full.. > > Sent from Yahoo Mail on Android >

Re: [R] How to save multiple values of a variable in a json file in R

2020-01-20 Thread Eric Berger
I have had success using the fromJSON() function in the rjson package. On Thu, Jan 16, 2020 at 4:22 PM Ioanna Ioannou wrote: > hello everyone, > > and happy new year! > > I have this problem: I want to save the name of the 'countries', the > 'taxonomy_gem' and the 'minimum_im' and 'maximum_im'

[R] Converting binary number to in Two´s complement representation

2020-01-20 Thread Paul Bernal
Dear friends, How can I convert the following binary number in two´s complement representation in R? 10110010 Any help and/or guidance will be greatly appreciated, Best regards, Paul [[alternative HTML version deleted]] __

[R] Error in annotate

2020-01-20 Thread Ana Marija
Hello, my code used to work and now I am getting this error which does not display my annotation df <- data.frame("prop" = c(102.73,260.65), "Name" = c("All Genes \n 31385","Glucose Response Genes \n 103")) p <- ggplot(data = df, aes(x = Name, y = prop, fill = Name)) + geom_bar(stat =

[R] how to add annotate horizontal line between bars and decrease size and space between bars?

2020-01-20 Thread Ana Marija
Hello, I have a code like this: p <- ggplot(data = df, aes(x = Name, y = prop, fill = Name)) + geom_bar(stat = "identity") + labs(x = "", y = "EQTL / gene") + scale_fill_brewer(palette="Greens",name = "Number of cis EQTL") + theme(legend.position = "none") p which produces the attached

Re: [R] How to save multiple values of a variable in a json file in R

2020-01-20 Thread Jim Lemon
Hi Ioanna, Assuming your input file is named "ii.json" and contains the text in your original post: library(jsonlite) a2<-fromJSON("ii.json",flatten=TRUE) a2$fields$geo_applicability$fields$countries[,"fields.name"] You can find this yourself by progressively checking names and extracting

Re: [R] how to add annotate horizontal line between bars and decrease size and space between bars?

2020-01-20 Thread Ana Marija
I tried doing this but it didn't help p <- ggplot(data = df, aes(x = Name, y = prop, fill = Name)) + geom_bar(stat = "identity") + labs(x = "", y = "EQTL / gene") + scale_fill_brewer(palette="Greens",name = "Number of cis EQTL") + theme_classic()+ theme(panel.grid.major.x =

Re: [R] Strange behaviour of R?

2020-01-20 Thread Gabor Grothendieck
Normally one uses match.fun to avoid such problems. This will give the error shown even if FUN is defined in the global environment. test <- function(FUN, args) { FUN <- match.fun(FUN) print(FUN) FUN(args) } test(NULL, 1:10) ## Error in match.fun(FUN) : 'NULL' is not a

Re: [R] Fwd: Extracting a particular column from list

2020-01-20 Thread Bert Gunter
Trickier, but shorter: > lapply(u,'[',1) $a [1] 1 $b [1] "a" Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Jan 17, 2020 at 10:04 PM Eric Berger

Re: [R] How to save multiple values of a variable in a json file in R

2020-01-20 Thread Richard O'Keefe
In your example, these keys occur 1 countries 1 maximum_im 1 minimum_im 61 name 66 pk -- many of these pertain to countries, some do not 1 taxonomy_gem It is not clear what you mean by 'the name of the countries'. There appear to be 61 countries each with two