Displaying 20 results from an estimated 9000 matches similar to: "sequence of equal-length numbers (for filenames)"
2009 Feb 12
3
trunc/floor a number -- strange bahaviour
Hi everybody,
given a fresh rgui.exe load on winxp OS, I enter (a minimal exaple)
n <- 12.357531
Then the following command:
n <- (n - floor(n))*10; n
gives the following outputs:
[1] 3.57531
[1] 5.7531
[1] 7.531
[1] 5.31
[1] 3.1
[1] 1 === still as expected
[1] 10 === not expected, count with me: 1 - floor(1) is zero, times
10 gives 0, not 10!!!!
[1] 10 === should
2009 Apr 10
3
Determine the Length of the Longest Word in a String
Hi Everyone,
I'm new to programming R and have accomplished my goal, but feel that there
is probably a more efficient way of coding this. I'd appreciate any
guidance that a more advanced programmer can provide.
My goal --
I would like to find the length of the longest word in a string containing
many words separated by spaces.
How I did it --
I was able to find the length of the
2009 May 19
5
exists function on list objects gives always a FALSE
Dear R-users,
in a minimal example exists() gives FALSE on an object which obviously does
exist. How can I check on that list object anyway else, please?
> SmoothData <- list(exists=TRUE, span=0.001)
> SmoothData
$exists
[1] TRUE
$span
[1] 0.001
> exists("SmoothData")
TRUE
> exists("SmoothData$span")
FALSE
> exists("SmoothData[[2]]")
FALSE
2003 Aug 29
2
length() and nchar()
I would propose to add "
See also:
`nchar' for counting the number of character in
character vectors.
"
to the helpfile of length(),
because it is rather difficult
to find nchar() if one has only
search terms as "length", "len",
"strlen" in mind.
Sincerly
Wolfram Fischer
2008 Nov 06
1
How to get the length of an UTF-8 string
Hi there,
I am intending to get the length of an UTF-8 string which contains
some Japanese characters (let's say, rstr) in R language.
I try to use the nchar(rstr) to get its length, however, it returns
the "NA" for it contains some multi-byte characters.
Is there any alternatives to return the length of this rstr?
Any suggestion is appreciated.
Long
2008 Apr 07
2
"\0" gives no warning "unknown escape sequence" (PR#11107)
Full_Name: Volkmar Klatt
Version: 2.6.2
OS: linux
Submission from: (NULL) (84.147.0.178)
Hello,
the documentation article
?Quotes
from package:base could be improved by discussing
the meaning of "\0" escape sequence.
In R (currently used: R-2.6.2), a "\0" in a string will
silently terminate that string, just as it would in C code.
There is no warning about an unknown escape
2016 Jun 06
2
readlines() truncates text file with Codepage 437 encoding
Hello r-devel,
The attached Code page 437-encoded file contains 245 characters
(including the final newline), but readLines only reads 242 of them:
> test_text <- readLines(file('437__characters.txt', encoding='437'))
Warning message:
In readLines(file("437__characters.txt", :
incomplete final line found on '437__characters.txt'
> test_text
[1]
2005 Dec 08
1
kronecker(... , make.dimnames=TRUE)
Hi
I'm using kronecker() with a matrix and a vector. I'm interested in
the column names that kronecker() returns:
> a <- matrix(1:9,3,3)
> rownames(a) <- letters[1:3]
> colnames(a) <- LETTERS[1:3]
> b <- c(x=1,y=2)
> kronecker(a,b,make.dimnames=TRUE)
A: B: C:
a:x 1 4 7
a:y 2 8 14
b:x 2 5 8
b:y 4 10 16
c:x 3 6 9
c:y 6 12 18
>
The
2005 Oct 25
1
performance of nchar
Hi,
Is nchar function knowingly slow in R? I'm doing some string
formatting that requires multiple call to nchar, and nchar seems to be
very slow.
Experiment 1, pass nchar inside sprintf, and it takes 0.7 seconds
> system.time(for (i in 1:10000)
+ str = sprintf('0005%020d', nchar(op))
+ )[3]
[1] 0.7
Experiment 2, get the length of op separately using nchar, and then pass
2008 Jul 10
4
Turn any vector
Dear R-users,
I'd like to turn a vector so it starts with it's end. For better
understanding, this set of commands will do what I need:
i <- seq(1:10)
i_turned <- i
for (j in 1:length(i)) i_turned[j] <- i[length(i)-j+1]
now, i_turned is what I call turned. Is there a function which would make a
script lighter? Thank you upfront for any hint.
Best regards,
Zroutik
2008 Aug 11
4
A comprehensive manual on "How to plot" (a lot of graphical examples welcome)
Hi,
I'm looking for a manual (we based or pdf) which would explain in detail
with graphical examples what all the option can do in plot and par. Does
anybody now anything like this? A couple of manuals to R I went through do
have plot parameters mentioned, but sometimes it is hard to understand or
imagine what the parameter can do (the same with the related help page)
e.g. I met "From
2015 Oct 07
1
Error generated by .Internal(nchar) disappears when debugging
Malcolm,
I tested the code on a clean R 3.2.0 session. Not even in RStudio, just to
rule that out.
> sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5]
2009 Aug 24
1
nchar on factors
In R 2.9.1 Windows:
> nchar(factor(paste('sdf',1:10)))
[1] 1 1 1 1 1 1 1 1 2 1
so it appears that nchar is counting the number of characters in the numeric
representation, just like:
> nchar(as.numeric(factor(paste('sdf',1:10))))
[1] 1 1 1 1 1 1 1 1 2 1
but ?nchar says explicitly:
x: character vector, or a vector to be coerced to a character
vector.
2015 Oct 06
1
Error generated by .Internal(nchar) disappears when debugging
On 05/10/2015 8:25 PM, Matt Dowle wrote:
>
> On Mon, Oct 5, 2015 at 4:57 PM, Duncan Murdoch <murdoch.duncan at gmail.com
> <mailto:murdoch.duncan at gmail.com>> wrote:
>
> On 05/10/2015 7:24 PM, Matt Dowle wrote:
> > Joris Meys <jorismeys <at> gmail.com <http://gmail.com>> writes:
> >
> >>
> >> Hi all,
2015 Oct 05
2
Error generated by .Internal(nchar) disappears when debugging
Hi all,
I have a puzzling problem related to nchar. In R 3.2.1, the internal nchar
gained an extra argument (see
https://stat.ethz.ch/pipermail/r-announce/2015/000586.html)
I've been testing code using the package copula, and at home I'm still
running R 3.2.0 (I know, I know...). When trying the following code, I got
an error:
> library(copula)
> fgmCopula(0.8)
Error in
2006 Mar 10
2
ifelse problem
Dear all,
There is something I'm missing in order to understand the following behavior:
> aa <- c("test", "name")
> ifelse(any(nchar(aa) < 3), aa[-which(nchar(aa) < 3)], aa)
[1] "test"
> any(nchar(aa) < 3)
[1] FALSE
Shouldn't the ifelse function return the whole aa vector?
Using if and else separately, I get the correct result...
>
2011 Jan 05
2
vector of character with unequal width
Dear R users,
The best in this new year 2011.
I am dealing with a character vector (xx) whose nchar are not the same.
Ex.
nchar(xx)
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[38] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 4 4 4 4 4 4 4 4
[75] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ....... 9
I need xx to be nchar = 9
My
2009 Aug 11
1
Passing a list object to lapply
Hello,
I'm having difficulty passing an object name to a lapply function. Can
somebody tell me the trick to make this work?
#Works
T13702 <- TRACKDATA[["13702.xls"]][["data"]]
min(unlist(lapply(list(T13702), function(x) mdy.date(x[1, 2], x[1, 1],
x[1, 3]))))
16553
#Works
d<-2
assign(paste("T",substr(names(TRACKDATA)[d],1,(nchar(names(TRACKDATA)[d]
2010 Sep 23
1
scatterplot 3d equal axis sequence length limitation
I was wondering if anyone has a way out of the limitation that you must use
equal length
x,y, and z sequence lengths.
For instance,
x<-seq(1,100)
y<-seq(1,100)
z<-rnorm(100)
scatterplot3d(z,x,y)
works fine.
However, if I get some results that has a different y subset length, such as
x<-seq(1,100)
y<-seq(1,300)
z<-rnorm(100)
scatterplot3d(z,x,y)
I get the following error:
2008 Aug 11
1
line with of the symbols in the legend -- changable?
Dear R users,
I plot data with
points(my_data[x]~x, col = x, type = "o", lwd="4")
where x is an integer running from 1 to 10, I get points drawn at the plot.
When want to do a legend to this I try
legend(leg.txt[x], col = x, text.col = 1, pch = 1, bty = "n")
where leg.txt contains the names of the variable and x behaves the same. The
difference between the