Hello,
I can't provide too much help without knowing which packages `hotspot` and
`levelplot` come from. It might be something as simple as
`as.data.frame(matrixaa)` instead of `matrixaa`.
On Wed, Jul 7, 2021 at 10:04 AM Ahmed Elbeltagi
wrote:
> Dear,
> I have a problem in the last
Hello,
I would suggest something like `tools::file_path_sans_ext` instead of
`strsplit` to remove the file extension. This is also vectorized, so you
won't have to use a `sapply` or `vapply` on it. I hope this helps!
On Wed, Jul 7, 2021 at 9:28 PM Kai Yang via R-help
wrote:
> Hello List,
> I
Hello,
I've been writing a package that allows a script to know its path, and I've
been struggling to get it working for 'R.app' on macOS.
For 'Rgui' on Windows, I used 'utils::getWindowsHandles' to get the
script's path
[image: image.png]
but it's only on Windows, and even if it wasn't, it
Hello,
I have a C function in which I want to return a result visibly or invisibly
(depends on the arguments provided). My current implementation was to
return a list like 'withVisible' does, where element "value" is the value
the function returns, and element "visible" is TRUE or FALSE
gt; GSMnames <- gsub(pattern = ".txt", replacement = "", GSMnames)
>
> #make a vector of the list of files to aggregate
> files <- list.files("~/Desktop/GSE162562_RAW", full.names = TRUE)
>
>
> but it is not running as after running utils::untar(FIL
Hello,
I'm not so sure this is a bug, it appears to be behaving as intended from
the documentation. I would suggest using argument 'physical' from 'setkey'
to avoid reordering the rows. Something like:
x <- data.table::data.table(V1 = 9:0)
y <- data.table::copy(x)
data.table::setkey(x, V1,
Hello,
Package 'officer' has a function 'read_xlsx', so when you attach those
packages in that order, it returns 'read_xlsx' from package 'officer'
instead of 'readxl'. To avoid the confusion, instead of
eth <- read_xlsx("c:/temp/eth.xlsx")
try
eth <- readxl::read_xlsx("c:/temp/eth.xlsx")
Hello,
I think I've found a solution, but it's not producing the same answer as
what you're expecting. I think you might've mixed up row and column a few
times, but you should be able to alter the following to your needs. Also,
see ?.bincode:
EB <- matrix(data = c(
1, 271, 179, 359, 178,
Hello,
I'm assuming you're reading from an "*.xlsx" file. I'm not sure which
package you're using for this scenario, but my preference is 'openxlsx'. If
this is the package you're using, you could set argument 'detectDates' to
'TRUE', and then it should read them correctly.
FILE <-
Hello,
I would suggest something like:
date <- seq(as.Date("2020-01-01"), as.Date("2020-12-31"), 1)
time <- sprintf("%02d:%02d", rep(0:23, each = 12), seq.int(0, 55, 5))
x <- data.frame(
date = rep(date, each = length(time)),
time = time
)
x$cfs <- stats::rnorm(nrow(x))
ies/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar
> "
>
> but it is not giving me any file
>
> On Mon, Aug 23, 2021 at 11:42 PM Andrew Simmons
> wrote:
>
>> Hello,
>>
>>
>> I don't think you need to use a system command directly, I think
>> '
Hello,
I don't think you need to use a system command directly, I think
'utils::untar' is all you need. I tried the same thing myself, something
like:
URL <- "https://exiftool.org/Image-ExifTool-12.30.tar.gz;
FILE <- file.path(tempdir(), basename(URL))
utils::download.file(URL, FILE)
Hello,
I would use something like:
x <- c(1:5, NaN) |> sample(100, replace = TRUE) |> matrix(10, 10) |>
as.data.frame()
x[] <- lapply(x, function(xx) {
xx[is.nan(xx)] <- NA_real_
xx
})
This prevents attributes from being changed in 'x', but accomplishes the
same thing as you have
> List of 1
> $ sd_ef_rash_loc___palm: logi NA
> ```
> What am I getting wrong?
> Thanks
>
> On Thu, Sep 2, 2021 at 3:30 PM Andrew Simmons wrote:
> >
> > Hello,
> >
> >
> > I would use something like:
> >
> >
> > x <-
ngiu
wrote:
> Sorry,
> still I don't get it:
> ```
> > dim(df)
> [1] 302 626
> > # clean
> > df <- lapply(x, function(xx) {
> + xx[is.nan(xx)] <- NA
> + xx
> + })
> > dim(df)
> NULL
> ```
>
> On Thu, Sep 2, 2021 at 3:47 PM Andrew Sim
You could use 'split' to create a list of data frames, and then apply a
function to each to get the means and sds.
cols <- "cfs" # add more as necessary
S <- split(discharge[cols], format(discharge$sampdate, format = "%Y-%m"))
means <- do.call("rbind", lapply(S, colMeans, na.rm = TRUE))
sds
I think you're trying to do something like:
`padding<-` <- function (x, which, value)
{
which <- match.arg(which, c("bottom", "left", "top", "right"),
several.ok = TRUE)
# code to pad to each side here
}
Then you could use it like
df <- data.frame(x=1:5, y = sample(1:5, 5))
padding(df,
ere would be
> any effects when including +Inf (or -Inf).
>
>
> Leonard
>
>
> On 9/18/2021 1:14 AM, Andrew Simmons wrote:
>
> While it is not explicitly mentioned anywhere in the documentation for
> .bincode, I suspect 'include.lowest = FALSE' is the default to keep
Regarding your first point, argument 'include.lowest' already handles this
specific case, see ?.bincode
Your second point, maybe it could be helpful, but since both 'cut.default'
and '.bincode' return NA if a value isn't within a bin, you could make
something like this on your own.
Might be worth
ere not included and run
> that test.
>
>
> Leonard
>
>
> On 9/18/2021 12:53 AM, Andrew Simmons wrote:
>
> Regarding your first point, argument 'include.lowest' already handles this
> specific case, see ?.bincode
>
> Your second point, maybe it could be helpful, but since bot
gested will serve you far better. I hope this helps.
On Wed, Sep 15, 2021 at 2:26 AM Leonard Mada wrote:
> Hello Andrew,
>
>
> On 9/15/2021 6:53 AM, Andrew Simmons wrote:
>
> names(x) <- c("some names")
>
> if different from
>
> `names<-`(x, va
3:
> The option you mentioned.
>
>
> Independent of the method: there are still weird/unexplained behaviours
> when I try the initial code (see the latest mail with the improved code).
>
>
> Sincerely,
>
>
> Leonard
>
>
> On 9/13/2021 6:45 PM, Andr
form
> the subsetting;
>
>
> However, in the case of a non-subsetted expression:
> r(x) <- 1;
> It would make sense to evaluate lazily r(x) if no subsetting is involved
> (more precisely "r<-"(x, value) ).
>
> Would this have any impact on the current code?
>
>
c("some names"))
x <- `*tmp*`
Another example,
y <- `names<-`(x, value = c("some names"))
now y will be equivalent to x if we did
names(x) <- c("some names")
except that the first will not update x, it will still have its old names.
On Mon, Sep 13, 2021
'is.numeric' is a function that returns whether its input is a numeric
vector. It looks like what you want to do is
VPN_Sheet1 <- VPN_Sheet1[!vapply(VPN_Sheet1$HVA, "is.numeric", NA), ]
instead of
VPN_Sheet1 <- VPN_Sheet1[!is.numeric(VPN_Sheet1$HVA), ]
I hope this helps, and see ?vapply if
I'd like to point out that base R can handle a list as a data frame column,
it's just that you have to make the list of class "AsIs". So in your example
temp <- list("Hello", 1, 1.1, "bye")
data.frame(alpha = 1:4, beta = I(temp))
means that column "beta" will still be a list.
On Wed, Sep 15,
Hello,
First, `ls` does not support `!=` for pattern, but it's actually throwing a
different error. For `rm`, the objects provided into `...` are substituted
(not evaluated), so you should really do something like
rm(list = ls(pattern = ...))
As for all except "con", "DB2", and "ora", I would
Hello,
There are two convenient ways to access a column in a data.frame using `$`
and `[[`. Using `df` from your first email, we would do something like
df <- data.frame(VAR = 1:3, VAL = c("value is blue", "Value is red",
"empty"))
df$VAL
df[["VAL"]]
The two convenient ways to update / /
You're missing a comma, this should fix it
df[(df$Y>0.2) & (df$X<10),][2, ]
On Thu, Oct 14, 2021, 03:51 Luigi Marongiu wrote:
> Hello,
> I have selected a subset of a dataframe with the vector syntax (if
> this is the name):
> ```
> > df[(df$Y>0.2) & (df$X<10),]
> YX
> 10
Hello,
The issue comes that 'apply' tries to coerce its argument to a matrix. This
means that all your columns will become character class, and the result
will not be what you wanted. I would suggest something more like:
sapply(d, function(x) all(x[!is.na(x)] <= 3))
or
vapply(d, function(x)
You've just got the brackets in the wrong spot:
creditsub <- read.csv(unz(here::here("Data.zip"), "creditcardsub.csv"))
instead of
creditsub <- read.csv(unz(here::here("Data.zip", "creditcardsub.csv")))
Also, you probably want to save that connection and close it manually.
creditsub <-
I think what you're looking for is 'strwrap', it's in package base.
On Tue, Sep 28, 2021, 22:26 Leonard Mada via R-help
wrote:
> Dear R-Users,
>
>
> Does anyone know any package or library that implements functions for
> word wrapping?
>
>
> I did implement a very rudimentary one (Github link
ep("ab", 7), collapse=""), 7)
> # [1] "ababababababab"
>
>
> Can I set an absolute maximum width?
>
> It would be nice to have an algorithm that computes a penalty for the
> split and selects the split with the smallest penalty (when no obvious
>
Hello,
I think you have to use 'matches' instead of 'starts_with', I believe
starts_with does not accept a regular expression whereas matches does.
On Tue, Oct 5, 2021 at 12:15 PM Anne Zach wrote:
> Dear R users,
>
> I have a dataframe that contains several variables, among which 105
>
The class of 'eth' must be incorrect. You could try 'as.data.frame' or
possibly 'as.list' to convert 'eth' to an acceptable form.
On Thu, Aug 26, 2021, 11:53 Kai Yang via R-help
wrote:
> Hello List,
> I got an error message when I submit the code below
> ggplot(eth, aes(ymax=ymax, ymin=ymin,
nrow() is just the numbers of rows in your data frame, use seq_len(nrow())
or seq(nrow()) to loop through all row numbers
On Wed, Dec 22, 2021, 12:08 Kai Yang via R-help
wrote:
> Hello R team,I want to use for loop to generate multiple plots with 3
> parameter, (y is for y axis, c is for color
y, c, and f only exist in the context of mac2
If you want to use them, you'll have to write mac2$y, mac2$c, or mac2$f (or
the [[ versions mac2[["y"]], mac2[["c"]], or mac2[["f"]])
Combining that with index i would then look like mac2$y[[i]] or mac2[[i,
"y"]]
Also, I think you want to use
I've tried a bunch of different R versions, I can't seem to replicate what
you described. Here's the code I used:
R.pattern <- paste0("^R-", .standard_regexps()$valid_R_system_version, "$")
x <- list.files(dirname(R.home()), pattern = R.pattern, full.names = TRUE)
x <- x[file.info(x, extra_cols
type to 'Date', however, the date is reconfigured.
> For instance, 15/01/2010 (15 January 2010), becomes 0015-01-20.
> >
> > I've tried ```data_long$Date <- as.Date(data_long$Date, format =
> "%d/%m.%y")```, and also ```tryformat c("%d/%m%y")```, but either the error
&
I would usually use 'tapply'. It splits an object into groups, performs
some function on each group, and then (optionally) converts the input to
something simpler.
For example:
tapply(dat$wt, dat$Year, mean) # mean by Year
tapply(dat$wt, dat$Sex , mean) # mean by Sex
tapply(dat$wt,
If you're thinking about using environments, I would suggest you initialize
them like
x <- new.env(parent = emptyenv())
Since environments have parent environments, it means that requesting a
value from that environment can actually return the value stored in a
parent environment (this isn't
You probably want to use cat and print for these lines. These things won't
print when not run at the top level, so if you want them to print, you must
specify that.
On Tue, Nov 2, 2021, 13:18 Rich Shepard wrote:
> I've read ?sink and several web pages about it but it's not working
> properly
>
cat in R behaves similarly to cat in unix-alikes, sends text to a stdout.
Usually, that stdout would be a file, but usually in R it is the R Console.
I think it might also help to note the difference between cat and print:
x <- "test\n"
cat(x)
print(x)
produces
> cat(x)
test
> print(x)
[1]
First, your signature for names.pm is wrong. It should look something more
like:
names.pm <- function (x)
{
}
As for the body of the function, you might do something like:
names.pm <- function (x)
{
NextMethod()
}
but you don't need to define a names method if you're just going to call
If you want to use the 'methods' package, you could do something like:
replace <- function (p1, p2, ...)
{
stop(gettextf("cannot 'replace' with arguments of class %s and %s",
sQuote(class(p1)[1L]), sQuote(class(p2)[1L])))
}
methods::setGeneric("replace")
It might not be random, depending upon a seed being used (usually by
set.seed or RNGkind).
However, it's the best method for generating a random number within a
specified range without weights.
If you want weights, there are many other random number generation
functions, most notably rnorm. You
This is because + dispatches on the class attribute, which a string like
"test" has set to NULL, so it doesn't dispatch. You can add the class
yourself like structure("test", class = "character") and that should work.
I'm not sure where it's explained, but most primitive functions dispatch on
the
> classes which UseMethod() uses, is available as .class2(x) since R
> version 4.0.0. (This also applies to S4 objects when S3 dispatch is
> considered, see below.)"
>
> I think this is the "official" explanation, but I find it rather opaque.
>
> Thanks t
It seems like the headers are misnamed, that should be a comma between
sampdate and param, not a period
On Tue, Nov 30, 2021, 09:35 Rich Shepard wrote:
> A short data file:
> site_nbr,sampdate.param,quant,unit
> 31731,2005-07-12,temp,19.7,oC
> 31731,2007-03-28,temp,9,oC
>
I think you have to not put the word degree in quotes, something like:
graphics::plot(
x = 1,
xlab = quote(
32 * degree
)
)
works for me, though yours seems like a good solution too
On Tue, Nov 30, 2021 at 3:31 PM Rich Shepard
wrote:
> On Tue, 30 Nov 2021, Rich Shepard
Excuse my brevity, but take a look at ?plotmath
It has tons of tips for making pretty labels
On Tue, Nov 30, 2021, 14:05 Rich Shepard wrote:
> I want to present the temperature on the Y-axis label as 'Water Temperature
> (oC)' with the degree symbol as a superscript.
>
> My web search found a
sertion of "standard" symbols.
>
> NOTE: As I am far from an expert on all of this, I would appreciate
> clarification or correction of any errors or misstatements in the
> above.
>
> Bert Gunter
>
>
> On Tue, Nov 30, 2021 at 11:34 AM Andrew Simmons
> wrote:
>
Hello,
>From playing around with your numbers, it seems like you are using Excel
1904 Date System, which isn't a problem, it just means that your numbers
are days from 1904-01-01 instead of 1900-01-01.
The following is my solution:
times <- c(42935.5625,42935.569444)
as.POSIXlt((
#
Hello,
I was wondering if anyone has a way to test if a package is currently being
installed. My solution was to check if environment variable "R_INSTALL_PKG"
was unset, something like:
"R CMD INSTALL-ing" <- function ()
!is.na(Sys.getenv("R_INSTALL_PKG", NA))
Unfortunately, I couldn't find
Hello,
First, your statement can be re-written as
sort(x,partial=p)[p]
since n - (n - p) is p. Second, you need to look at
?sort
And look at section "Arguments" subsection "partial", that should have the
details you're looking for. From what I understand, it guarantees that the
indices of
The NOTE saying 'Possibly misspelled words in DESCRIPTION' can probably be
ignored (though I would probably put the name of your package in single
quotes).
The NOTE 'Non-standard files/directories found at top level' means that you
should move the non-standard files to a different location OR
It should also be noted that format(x, digits = 17) instead of
as.character(x) won't lose any accuracy.
On Thu, Feb 17, 2022, 17:41 Marius Hofert
wrote:
> Dear expeRts,
>
> I'm familiar with IEEE 754. Is there an easy way to explain why even
> just printing of small numbers fails?
>
> 1e-317 #
It seems like the current version of lubridate is 1.8.0, which does
raise a warning for an invalid timezone, just like as.POSIXct. This is
what I tried:
print(lubridate::parse_date_time("1970-01-01 00:01:00", "ymd
HMS" , tz = "PST"))
print(as.POSIXct("1970-01-01
?regex is a nice starting point, it's got plenty of details on meta
characters and characters classes, if you need more advanced stuff you'll
probably have to look at the perl regex documentation, I believe it's
linked in ?regex.
I might try something like
grep("^[xz]\\.")
or
grep("^[xz][.]")
You can use getAnywhere
On Sun, Jun 19, 2022, 13:23 Christofer Bogaso
wrote:
> Hi,
>
> I am trying to see the source code of rstandard function. I tried below,
>
> > methods('rstandard')
>
> [1] rstandard.glm* rstandard.lm*
>
> What do I need to do if I want to see the source code of
I think you have to use print(df$price, digits = 14)
On Tue, May 24, 2022, 10:01 maithili_shiva--- via R-help <
r-help@r-project.org> wrote:
> Dear Forum
> In my code, I am trying to compute Value at risk.
> I have an issue as mentioned below:
> I have defined
>
>
> options(digits = 14)
> But my
A sequence where 'from' and 'to' are both integer valued (not necessarily
class integer) will use R_compact_intrange; the return value is an integer
vector and is stored with minimal space.
In your case, you specified a 'from', 'to', and 'by'; if all are integer
class, then the return value is
I like package openxlsx, with the function openxlsx::read.xlsx()
Another common package that people use readxl
On Tue., Aug. 23, 2022, 7:51 p.m. Anas Jamshed,
wrote:
> I have .xlsx files with gene names in first column.How can read and load in
> R?
>
> [[alternative HTML version
1 and 2 are not valid identifiers in R, so you need to surround them with
backticks to make them valid, the same as quoting a string:
switch(Stst, `1` = print("NO"), `2` = print("YES"))
On Wed., Sep. 7, 2022, 14:35 akshay kulkarni, wrote:
> Dear members,
> The
You can specify multiple indexes to replace at once, so you can avoid
a for loop entirely like this:
M <- matrix(nrow = 10, ncol = 10)
M[1:4, 5: 6] <- M[5: 6, 1:4] <- m[1, 2]
M[1:4,7] <- M[ 7, 1:4] <- m[1, 3]
M[1:4, 8:10] <- M[8:10, 1:4] <- m[1, 4]
M[5:6,7] <- M[ 7, 5:6] <- m[2, 3]
The error comes from the expression not being wrapped with braces. You
could change it to
if (is.matrix(r)) {
r[w != 0, , drop = FALSE]
} else r[w != 0]
or
{
if (is.matrix(r))
r[w != 0, , drop = FALSE]
else r[w != 0]
}
or
if (is.matrix(r)) r[w != 0, , drop = FALSE] else
'base' ), what is the "first argument"?
>
> On Mon, Oct 24, 2022 at 12:29 PM Andrew Simmons
> wrote:
> >
> > require(), similarly to library(), does not evaluate its first argument
> UNLESS you add character.only = TRUE
> >
> > require( packages_i_wan
require(), similarly to library(), does not evaluate its first argument
UNLESS you add character.only = TRUE
require( packages_i_want_to_use[1], character.only = TRUE)
On Mon, Oct 24, 2022, 12:26 Kelly Thompson wrote:
> # Below, when using require(), why do I get the error message "Error
> in
I would suggest using strwrap(), the documentation at ?strwrap has
plenty of details and examples.
For paragraphs, I would usually do something like:
strwrap(x = , width = 80, indent = 4)
On Fri, Oct 28, 2022 at 5:42 PM Leonard Mada via R-help
wrote:
>
> Dear R-Users,
>
> text = "
> What is the
partial match attr is for something like
attr(data.frame(), "cla")
which will partially match to "class".
On Sun, Oct 30, 2022, 12:55 Joshua Ulrich wrote:
> For what it's worth, I set these options to warn me about partial matches:
>
> options(warnPartialMatchArgs = TRUE,
>
$ does not evaluate its second argument, it does something like
as.character(substitute(name)).
You should be using
lapply(list, function(x) x$a)
or
lapply(list, `[[`, "a")
On Thu, Oct 27, 2022, 12:29 Hilmar Berger wrote:
> Dear all,
>
> I'm a little bit surprised by the behavior of the $
nt()))
})
The part that matters is that the function body is wrapped with
braces. `if` statements inside braces or parenthesis (or possibly
brackets) will continue looking for `else` even after `cons.expr` and
a newline has been fully parsed, but will not otherwise.
On Fri, Oct 21, 2022 at 10
In the first scenario, your object is class AB, then class A with distance
1, then class B with distance 2. This means that method A is preferable
since it is less distance away than method B.
However, in your second function, both methods are a total distance of 3
away, so (as far as I know) it
If you're running it from Rscript, you'll have to specify the encoding like
this:
Rscript --encoding UTF-8 file
If you're using R for Windows, I'm surprised this issue would come up since
R 4.2.0 added support for UTF-8. At least on my own Windows machine, I can
run exactly what you wrote and
In general, you should be using inherits(netwotks, "matrix") or
is(networks, "matrix") instead of class() ==
Your function fails because your object has multiple classes so class==
returns multiple logical values so if will fail.
But inherits or is will return one logical value, so if will not
Hello,
I'm working on a function envvars() which I'd like to get, set, and
remove environment variables in a manner similar to options(). At the
R level, I have this function:
envvars <- function (...)
.External2(C_envvars, pairlist(...))
and then at the C level:
#define set_R_Visible(X)
Hello,
I'm going to quote the tempdir() doc page: "By default, tmpdir will be the
directory given by tempdir(). This will be a subdirectory of the
per-session temporary directory found by the following rule when the R
session is started. The environment variables TMPDIR, TMP and TEMP are
checked
What you're asking for doesn't make sense: 9098 and 09098 are the same
9098L == 09098L
If you mean specifically while printing, you could use sprintf:
cat(sprintf("%05d", 9098))
On Sun., Sep. 11, 2022, 14:58 akshay kulkarni,
wrote:
> Dear Tim,
> So there is no way to coerce
To install the packages from source, you need to install make, gcc, and g++:
sudo apt install make
sudo apt install gcc
sudo apt install g++
then try installing them again
On Thu, Oct 6, 2022 at 2:54 AM Rhon Calderon, Eric
wrote:
>
> Hi,
>
> I am using R in my HPC terminal. After many
1. The execution environment for a script is the global environment. Each R
script run from a shell will be given its own global environment. Each R
session has exactly one global environment, but you can have several active
R sessions.
2. Using return in a script instead of a function will throw
I converted `date` to a factor and it seemed to work:
```
library(ggplot2)
library(cowplot)
date <- c("12-29","12-30","01-01")
date <- factor(date, labels = unique(date))
PT <- c(.106,.130,.121)
data <- data.frame(date,PT)
ggplot(data, aes(x=date,y=PT,group=1))+
geom_point(size=4)+
ions unfortunately did not work:
>
> integrate(function(x) x^3 / sin(x), -pi/2, pi/2, subdivisions=4097) # or 4096
>
>
> Sincerely,
>
>
> Leonard
>
>
> On 1/8/2023 5:32 AM, Andrew Simmons wrote:
>
> You're dividing 0 by 0, giving you NaN, perhaps you should try
You're dividing 0 by 0, giving you NaN, perhaps you should try
function(x) ifelse(x == 0, 0, x^3/sin(x))
On Sat, Jan 7, 2023, 22:24 Leonard Mada via R-help
wrote:
> Dear List-Members,
>
> I encounter a problem while trying to integrate the following function:
>
> integrate(function(x) x^3 /
Returning the last value of { is the basis of functions not needing a
return statement. Before R invokes a function (specifically a closure), it
creates a new context. When R evaluates a call to return, it looks for a
context to return from and finds the context of function, ending the
context and
exists() is for bindings in an environment, not for names in a list. try
"T1A1" %in% names(E$L[[i]])
instead
On Tue, Dec 27, 2022, 12:36 akshay kulkarni wrote:
> Dear members,
> I have the following code:
> > E <- new.env()
> > E$L <- list()
> > i <- 1
> >
try
gregexpr('b+', target_string)
which looks for one or more b characters, then get the attribute
"match.length"
On Fri, Dec 2, 2022, 18:56 Evan Cooch wrote:
> Was wondering if there is an 'efficient/elegant' way to do the following
> (without tidyverse). Take a string
>
> abaaabbabaaab
This seems to be a bug. I tried creating this function in the global
environment:
str.pdMat <- function (object, ...)
{
if (nlme::isInitialized(object)) {
NextMethod()
}
else {
cat(" Uninitialized positive definite matrix structure of class ",
For print(), digits is the minimal number of significant digits. In
your case, rounding the first column to the 3rd decimal place gives at
least 2 sigfigs and rounding the second column to the 2nd decimal
place.
If you want to print all numbers to two significant digits, regardless
of what other
You'll want to use grep() or grepl(). By default, grep() uses extended
regular expressions to find matches, but you can also use perl regular
expressions and globbing (after converting to a regular expression).
For example:
grepl("^yr", colnames(mydata))
will tell you which 'colnames' start with
I tried this again with R 2.15.3, the oldest version I have installed,
and I still got the same behaviour. It extracts the first exact match,
then the only partial match, then NULL.
On Tue, Jan 24, 2023 at 5:04 PM Rolf Turner wrote:
>
>
> Has something changed, but I missed it?
>
> My
junk$y extracts the element named "y" because it found an exact match for
the name.
junk$yu extracts nothing because it does not find an exact match and finds
multiple partial matches.
junk$yuc or junk$yur would work because it finds no exact match and then
exactly one partial match.
On Tue,
grep(value = TRUE) just returns the strings which match the pattern. You
have to use regexpr() or gregexpr() if you want to know where the matches
are:
```
x <- "abaca"
# extract only the first match with regexpr()
m <- regexpr("a.*?a", x)
regmatches(x, m)
# or
# extract every match with
>
> I need to have the same number of backticks in the opening and closing
> marker. So I make the pattern more complicated, and it doesn't work:
>
>pattern2 <- "\n([`]{3,})html\n.*?\n\\1\n"
>
> This matches all of x:
>
>> pattern2 <- &q
R converts floats to strings with ~15 digits of accuracy, specifically
to avoid differentiating between 1 and 1 + .Machine$double.eps, it is
assumed that small differences such as this are due to rounding errors
and are unimportant.
So, if when making your factor, you want all digits, you could
I would use replicate() to do an operation with random numbers repeatedly:
```
mysim <- replicate(10, {
two.mat <- matrix(rnorm(4), 2, 2)
four.mat <- matrix(rnorm(16), 4, 4)
list(two.mat = two.mat, four.mat = four.mat)
})
```
which should give you a matrix-list. You can slice this
put print() around x^2
On Mon, Nov 7, 2022, 12:18 akshay kulkarni wrote:
> Dear members,
> I have the following code and output:
>
> > TP <- 1:4
> > lapply(TP,function(x){print(x);x^2})
> [1] 1
> [1] 2
> [1] 3
> [1] 4
> [[1]]
> [1] 1
>
> [[2]]
> [1] 4
>
> [[3]]
>
>
> [[3]]
> [1] 9
>
> [[4]]
> [1] 16
>
> Basically, lapply() is implemented by a for loop. So there must be some way
> right?
>
> tHanking you,
> Yours sincerely,
> AKSHAY M KULKARNI
>
> From: Andrew Simmons
> Sent: Mo
In an R session, run this:
writeLines(normalizePath(R.home("bin")))
Right click your .R file > Open with > Choose another app > Check the box
"Always use this app to open .R files" > Look for another app on this PC
Paste the directory found above, then select "Rgui.exe"
On Fri, Nov 4, 2022,
It says that nser requires the most recent version of magrittr that you do
not have installed. You must update magrittr before attempting to install
nser:
update.packages(oldPkgs = "magrittr")
or at the prompt you were presented before, choose to update magrittr
before installing nser.
On Sun,
It is not possible, apply() converts its argument to an array. You might be
able to use split() and lapply() to solve your problem.
On Tue, Feb 7, 2023, 07:52 Naresh Gurbuxani
wrote:
>
> > Consider a data.frame whose different columns have numeric, character,
> > and factor data. In apply
1 - 100 of 102 matches
Mail list logo