Displaying 20 results from an estimated 5000 matches similar to: "gsub() with unicode and escape character"
2012 Jul 22
5
Reorder in decreasing order
reorder() is probably the best way to order the levels in a vector
without manually specifying the order. But reorder() orders by default
in an increasing order: "The levels are ordered such that the values
returned by ?FUN? are in increasing order."
Is there a way to do what reorder() does, but order the levels
according to a _decreasing_ order of the values?
Sverre
2011 Jul 14
1
Export Unicode characters from R
Dear helpers,
I am not able to export Unicode characters from R. Below is an example
where the Unicode character is correctly rendered as long as I am stay
within R. When I export it, the character appears only with its basic
code, and the same happens when I import it back into R . I'm using R
2.13.1 in Windows XP.
> funny.g <- "\u1E21"
> funny.g
[1] "?"
>
2011 Jul 11
2
Extract only the values from a row
Dear helpers,
how can I extract only the values from a row in a data frame? Using
[X,] doesn't do the trick:
> data.frame(letters[1:10],letters[11:20])->my.data
> my.data[1,]
letters.1.10. letters.11.20.
1 a k
I would like to be able to extract only the values "a" and "k" without
getting the row names and column names with them.
2011 Aug 02
7
Extract names from vector according to their values
Dear helpers,
I can create a vector with the priority of the packages that came with
R, like this:
> installed.packages()[,"Priority"]->my.vector
> my.vector
base boot class cluster codetools
"base" "recommended" "recommended" "recommended" "recommended"
compiler datasets
2011 Aug 03
1
Extract rows from a matrix according to value in column
Dear helpers,
I'm trying to extract certain rows from a matrix according to the
values the rows have in a certain column. I've been googling for a
while without result.
Here's a reproducible example of a matrix (and the one I was playing
with initially):
> myrepo<-getOption("repos")
>
2011 Aug 15
1
update() ignores object
Hi all,
I'm extracting the name of the term in a regression model that
dropterm specifies as the least significant one, and I'm assigning
this name to an object. However, when I use update(), it ignores this
object. Is there a way I can make it not ignore it? A reproducible
example is below:
> lm(x1~1+y1*y2+y3+y4,data=anscombe)->my.lm
>
2011 Aug 09
1
embedFonts() does not embed fonts?
Dear helpers,
I'm trying out the embedFonts() to embed fonts into my pdf files.
However, when I inspect the new pdf with a program designed to look
for embedded fonts, I see that the fonts have in fact not been
embedded. Below are my calls.
R version 2.13.1 (2011-07-08)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i386-pc-mingw32/i386 (32-bit)
2013 Nov 09
1
Support writing UTF-8 output in Windows
As recently discussed on Stack Overflow, R for Mac OS and Ubuntu (so
probably all Unix systems) can correctly write files with UTF-8
encoding, but R for Windows cannot:
http://stackoverflow.com/questions/19877676/write-utf-8-files-from-r
I strongly suggest that R for Windows should support this feature in
upcoming versions.
Sverre
2018 Feb 17
2
readLines interaction with gsub different in R-dev
I was told to re-raise this issue with R-dev:
In the documentation of R-dev and R-3.4.3, under ?gsub
> replacement
> ... For perl = TRUE only, it can also contain "\U" or "\L" to convert the rest of the replacement to upper or lower case and "\E" to end case conversion.
However, the following code runs differently:
tempf <- tempfile()
2018 Feb 17
2
readLines interaction with gsub different in R-dev
| Confirmed for R-devel (current) on Ubuntu 17.10. But ... isn't the regexp
| you use wrong, ie isn't R-devel giving the correct answer?
No, I don't think R-devel is correct (or at least consistent with the
documentation). My interpretation of gsub("(\\w)", "\\U\\1", entry,
perl = TRUE) is "Take every word character and replace it with itself,
converted to
2012 Sep 30
3
How to escape a forward slash with gsub, also does interpolation work with gsub?
I am trying this:
I want to replace all the text in between java comments:
/* start */
replace this text here
/* end */
I''m trying:
text.gsub(//* start */(.*)/* end *//im, replace_with)
But i''m getting errors relating to expecting keyword_end.
How should I be escaping /* and */ ?
Also, does string interpolation work in gsub regex? Say I had variables
like:
start_tag =
2008 Jan 10
0
gsub With unicode characters
Hi
I am writing a RoR application that needs to work with a database full
of french unicode characters, unfortunately whenever I try to display a
field with those values in a show I just get a question mark or no
character displayed.
So I decided to run a gsub (there''s only 2 fields with this problem) on
the field before displying it to replace the characters with their HTML
2015 Jan 08
0
gsub with perl=TRUE results in 'this version of PCRE is not compiled with Unicode property support' in R-devel
Why are you reporting that your PCRE library does not have something
which the R-admin manual says it should preferably have? To wit,
footnote 37 says
'and not PCRE2, which started at version 10.0. PCRE must be built with
UTF-8 support (not the default) and support for Unicode properties is
assumed by some R packages. Neither are tested by configure. JIT support
is desirable.'
That
2018 Feb 17
0
readLines interaction with gsub different in R-dev
I think the problem in R-devel happens when there are non-ASCII characters
in any
of the strings passed to gsub.
txt <- vapply(list(as.raw(c(0x41, 0x6d, 0xc3, 0xa9, 0x6c, 0x69, 0x65)),
as.raw(c(0x41, 0x6d, 0x65, 0x6c, 0x69, 0x61))), rawToChar, "")
txt
#[1] "Am?lie" "Amelia"
Encoding(txt)
#[1] "unknown" "unknown"
gsub(perl=TRUE,
2005 Apr 07
2
PDC: Logging out from Windows XP SP2 takes a long time
I have samba set up as primary domain controller, and have problems with
my Windows XP SP2 machines. Logging in is quick, but most of the time
(nine out of ten times) the logout process takes a long time - I do end
up rebooting, but once I let it stay and it took a whole hour before it
was logged out. It seems to act the same way for all users.
Possible sources already eliminated:
- I have
2013 Mar 23
1
Character change to Unicode format escape character when create a data frame
Hi,
I want to create a data frame including a column containing some special characters, like "ø". when I print that data frame out, the content change to <U+00F8>, and when save the data frame to a txt file, the content keep in that style, but I need it in its original form, anybody can explain?
> x <- data.frame(part = c("målløs", "ny"))
> x
2012 Dec 17
2
Formatting a path for unix with gsub
I have a path:
path = "/nfs/users/nfs_n/ns9/
Phenotype Analysis/Results/Run_AmplRatio_neg
BinaryAll trained without akapn+tnik.csv"
I wish to replace the spaces with "\ " so that it can be read by a system
call to unix.
Using gsub I try:
> gsub(" ","\\ ",path)
[1] "/nfs/users/nfs_n/ns9/Phenotype Analysis/Results/Run_AmplRatio_neg
BinaryAll
2010 Jun 26
1
predict newdata question
Hi:
I am using a subset of the below dataset to predict PRED_SUIT for
the whole dataset but I am having trouble with 'newdata'. The model
was created with 153 records and want to predict for 208 records.
wolf2 <- structure(list(gridcell = c(367L, 444L, 533L, 587L, 598L, 609L,
620L, 629L, 641L, 651L, 662L, 674L, 684L, 695L, 738L, 748L, 804L,
805L, 872L, 919L, 929L, 938L, 950L, 958L,
2009 Oct 05
2
Visualizing some data
Hi all,
I have an easy data set. It has three columns: Subject, Condition, dprime. A
small excerpt follows, in order to illustrate:
Subject Condition dprime
HY s 3.725846
CM s 2.877658
EH s 5
HY st 2.783553
CM st 2.633955
EH st 5
I want to visualize this. What I thought of was having dprime on the y-axis
(scale 0-5), Subject on the x-axis, and then two lines plotted to show the
dprime value for
2009 Nov 29
3
How to z-standardize for subgroups?
Hi folks,
I have a dataframe df.vars with the follwing structure:
var1 var2 var3 group
Group is a factor.
Now I want to standardize the vars 1-3 (actually - there are many
more) by class, so I define
z.mean.sd <- function(data){
return.values <- (data - mean(data)) / (sd(data))
return(return.values)
}
now I can call for each var
z.var1 <- by(df.vars$var1, group,