similar to: How to replace '$' sign?

Displaying 20 results from an estimated 10000 matches similar to: "How to replace '$' sign?"

2017 Aug 02
4
Extracting numeric part from a string
Hi again, I am struggling to extract the number part from below string : "\"cm_ffm\":\"563.77\"" Basically, I need to extract 563.77 from above. The underlying number can be a whole number, and there could be comma separator as well. So far I tried below : > library(stringr) > str_extract("\"cm_ffm\":\"563.77\"",
2013 Mar 23
4
Converting a character vector to numeric
Hello again, Let say I have following vector: Vec <- c("0.0365780769", "(1.09738648244378)", "(0.812507787221523)", "0.5778069963", "(0.452456601362355)", "-1.8900812605", "-1.8716093762", "0.0055217041", "-0.4769192333", "-2.4133018880") Now I want to convert this vector to numeric vector. I
2017 Jul 18
4
Creating/Reading a complex string in R
Thanks for your pointer. Is there any way in R how to replace " ' " with " /' " programmatically? My actual string is quite lengthy, so changing it manually may not be possible. I am aware of gsub() function, however not sure I can apply it directly on my original string. Regards, On Tue, Jul 18, 2017 at 10:27 PM, John McKown <john.archie.mckown at gmail.com>
2013 Jan 15
2
Regular expression
Hello again, I am having a problem on Regular expression. Let say I have following code: > gsub("[',]", "", "'asd'f") [1] "asdf" This is perfect. However I am having problem if I include "" (i.e. the double quote) in the first argument as the pattern search: > gsub("[',"]", "",
2017 Aug 03
0
Extracting numeric part from a string
> On Aug 2, 2017, at 6:59 PM, Christofer Bogaso <bogaso.christofer at gmail.com> wrote: > > Hi again, > > I am struggling to extract the number part from below string : > > "\"cm_ffm\":\"563.77\"" > > Basically, I need to extract 563.77 from above. The underlying number > can be a whole number, and there could be comma separator
2013 Mar 27
2
find and replace characters in a string
Hi, I have a string of text as follows "LOI ." How do I replace the dot with "(%)" gsub(".","(%)",LOI .) gives "(%)(%)(%)(%)(%)" Thanks -- Shane [[alternative HTML version deleted]]
2013 Feb 06
2
Omitting repeated occurrence in a string
Hello again, I was looking for some way on How to delete repeated appearance in a String. Let say I have following string: Text <- "ahsgdvasgAbcabcsdahj" Here you see "Abc" appears twice. But I want to keep only 1 occurrence. Therefore I need that: Text_result <- "ahsgdvasgAbcsdahj" (i.e. the first one). Can somebody help me if it is possible using some R
2017 Jul 18
3
Creating/Reading a complex string in R
Hi again, Let say I have below string (arbitrary) <html> <head> <script type="text/javascript" <script type="text/javascript"> mystatement('current', {'pac':['']}); mystatement; I want to pass above string to some R variable for further analysis. So I have tried below : String = '<html>
2012 Apr 10
7
How to remove $ (Dollar sign) from string
How do I remove a "$" character from a string sub() and gsub() with "$" or "\$" as pattern do not work. > sub("$","","ABC$DEF") [1] "ABC$DEF" > sub("\$","","ABC$DEF") Error: '\$' is an unrecognized escape in character string starting "\$" >
2018 Jan 03
2
Help with Regular expression
Hi, I was working on following expression : "\":\"03-JAN-2018 16:00:00\"" This is basically a combination of Date and Time mixed with some Noise. I want to extract only Date and Time part i.e. "03-JAN-2018 16:00:00 I tried following : gsub("![0-9][0-9]-[a-zA-Z][a-zA-Z][a-zA-Z]-[0-9][0-9][0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]", "",
2017 Jul 19
0
Creating/Reading a complex string in R
It was suggested to quote your string with *backticks* (` ... `) rather than single quotes. String <- `<html> <head> ... ` On 7/18/2017 1:05 PM, Christofer Bogaso wrote: > Thanks for your pointer. > > Is there any way in R how to replace " ' " with " /' " programmatically? > > My actual string is quite lengthy, so changing
2012 Dec 14
5
A question on list and lapply
Dear all, let say I have following list: Dat <- vector("list", length = 26) names(Dat) <- LETTERS My_Function <- function(x) return(rnorm(5)) Dat1 <- lapply(Dat, My_Function) However I want to apply my function 'My_Function' for all elements of 'Dat' except the elements having 'names(Dat) == "P"'. Here I have specified the name
2011 Nov 10
5
A question on Programming
Dear all. Let say I have a group of codes which will be used in many places in my overall R-code files. These group of codes will be used within a for-loop (with a big length, like 10000 times) and also many other places outside of that for loop. As this group of codes are being used in many places, I thought to put them within a user-defined function. Here my question is, is there any speed
2012 Jan 21
2
replacing "+" in string
I am trying to replace "+" in a string with another character I am getting odd results using sub and gsub > X<-"one + two" > gsub("+","plus",X) [1] "plusoplusnpluseplus plus+plus plustpluswplusoplus" > sub("+","plus",X) [1] "plusone + two" > X<-"one ~ two" it seems to work fine with other
2012 Mar 03
3
How to read this data properly?
Dear all, I have been given a data something like below: Dat = "2 3 28.3 3.05 8 3 3 22.5 1.55 0 1 1 26.0 2.30 9 3 3 24.8 2.10 0 3 3 26.0 2.60 4 2 3 23.8 2.10 0 3 2 24.7 1.90 0 2 1 23.7 1.95 0 3 3 25.6 2.15 0 3 3 24.3 2.15 0 2 3 25.8 2.65 0 2 3 28.2 3.05 11 4 2 21.0 1.85 0 2 1 26.0 2.30 14 1 1 27.1 2.95 8 2 3 25.2 2.00 1 2 3 29.0 3.00 1 4 3 24.7 2.20 0 2 3 27.4 2.70 5 2 2 23.2 1.95
2009 May 28
4
How this addition works?
I have following addition : > 1:2 + 1:10 [1] 2 4 4 6 6 8 8 10 10 12 I could not understand how R adding those two unequal vector? Any help? [[alternative HTML version deleted]]
2018 Mar 04
3
Change Function based on ifelse() condtion
Below is my full implementation (tried to make it simple as for demonstration) Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) { if (Apply_MC) { return(mclapply(X, FUN, ...)) } else { if (any(names(list(...)) == 'mc.cores')) { myList = list(...)[!names(list(...)) %in% 'mc.cores'] } return(lapply(X, FUN, myList)) } } Lapply_me(as.list(1:4), function(xx) { if (xx ==
2010 Jul 10
7
Need help on date calculation
Hi all, please see my code: > library(zoo) > a <- as.yearmon("March-2010", "%B-%Y") > b <- as.yearmon("May-2010", "%B-%Y") > > nn <- (b-a)*12 # number of months in between them > nn [1] 2 > as.integer(nn) [1] 1 What is the correct way to find the number of months between "a" and "b", still
2018 Mar 04
0
Change Function based on ifelse() condtion
The reason that it works for Apply_MC=TRUE is that in that case you call mclapply(X,FUN,...) and the mclapply() function strips off the mc.cores argument from the "..." list before calling FUN, so FUN is being called with zero arguments, exactly as it is declared. A quick workaround is to change the line Lapply_me(as.list(1:4), function(xx) { to Lapply_me(as.list(1:4),
2018 Mar 04
2
Change Function based on ifelse() condtion
My modified function looks below : Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) { if (Apply_MC) { return(mclapply(X, FUN, ...)) } else { if (any(names(list(...)) == 'mc.cores')) { myList = list(...)[!names(list(...)) %in% 'mc.cores'] } return(lapply(X, FUN, myList)) } } Here, I am not passing ... anymore rather passing myList On Sun, Mar 4, 2018 at 10:37 PM,