Displaying 20 results from an estimated 10000 matches similar to: "string manipulation"
2010 Nov 26
2
get list index
Hi R-users,
I have a list
mylist <- list(c(0.79, 0.92, 0.91, 0.86, 0.96, 0.96, 0.95, 0.94, 0.99),
c(0.28, 0.45, 0.59, 0.69, 0.80, 0.87, 0.95, 0.94, 0.98), c(0.29, 0.39,
0.59, 0.69, 0.68, 0.80, 0.93, 0.95, 0.98))
Is there a way to find the index of the list element that contains the
lowest value among all the other elements? As the lowest value in each
element is the first, the
2010 Jul 13
2
modifying vector elements
Hello R-users,
I have a very large vector (a) containing elements consisting of numbers
and letters, this is the i.e.
a
[1] "1.11.2a" "1.11.2d" "1.11.2e" "1.11.2f" "1.11.2x1"
"1.11.2x1b"
[7] "1.11.2x2" "1.11.2x2a" "1.11.2x2b" "1.11.2x3" "1.11.2x4"
2010 Aug 11
2
storing the results of an apply call
Hi R-users,
I have a function (myfun) that I want to apply to the rows of a matrix.
Basically, "myfun" takes the values from the matrix ("exp.des"), which
represent the different combinations of my experimental design, and pass
them as arguments to some other functions (fun1 and fun2). As I want to
replicate the results of fun1 and fun2 a certain number of time (e.g.
5), I
2010 Sep 27
3
name ONLY one column
Hi R-users
I can not change the name of one column only of my matrix.
my_matrix <- matrix (1:12,ncol=3)
colnames(my_matrix)[1] <- 'myname'
Error in dimnames(x) <- dn :
length of 'dimnames' [2] not equal to array extent
thank you for your help
Lorenzo
[[alternative HTML version deleted]]
2010 Oct 05
2
accessing elements located after $ symbol
Hi R-users
I am having troubles accessing elements after the $ symbol. Reproducible
example:
>test <- data.frame (first=1:10, second=11:20, third=21:30)
>test$first #this works fine
but when I try
>interest <- "first"
>test$interest # does not seem to work
Could you tell me why that happens and show how to do instead?
Thanks so much
Lorenzo
2011 Apr 05
1
do not execute newline command
Hi R-users,
To automate the creation of scripts, I converted the code (example below) into a character string and wrote the object to a file:
Repeat <- "
myvec <- c(1:12)
cat('vector= ', myvec, '\n')
"
write (Repeat, 'yourpath/test.R')
the problem is that one line of the code is a "cat" command. In the output file (i.e. test.R), the newline
2011 May 05
1
lapply, if statement and concatenating to a list
Hi R users
I was wondering on how to use lapply & co when the applied function has a conditional statement and the output is a 'growing' object.
See example below:
list1 <- list('A','B','C')
list2 <- c()
myfun <- function(x,list2)
{
one_elem <- x
cat('one_elem= ', one_elem, '\n')
random <- sample(1:2,1)
show(random)
2010 Oct 11
1
running R script on linux server
Hi R-users,
I have a problem running my R code on a Linux cluster. What I did was
write a .pbs file to instruct the cluster on what to do and how:
#!/bin/sh
#PBS -m ae
#PBS -M uqlcatta@uq.edu.au
#PBS -A uq-CSER
#PBS -N job1_lollo
#PBS -l select=1:ncpus=1:NodeType=fast:mem=8GB
#PBS -l walltime=999:00:00
cd $PBS_O_WORKDIR
source /usr/share/modules/init/bash
module
2010 Oct 18
1
paste an unevaluated expression
Hi R-users,
I would like to create an expression without evaluating it. Then paste
that expression to an object. Example:
Result <- paste('Result', 1, sep="")
paste(Result, substitute(apply(exp.des[1:10,], 1, one.row,
parms=parameters)), sep="<-")
However this pastes EACH element of the unevaluated expression. Instead
I just would like the expression
2010 May 17
3
applying quantile to a list using values of another object as probs
Hi r-users,
I have a matrix B and a list of 3x3 matrices (mylist). I want to
calculate the quantiles in the list using each of the value of B as
probabilities.
The codes I wrote are:
B <- matrix (runif(12, 0, 1), 3, 4)
mylist <- lapply(mylist, function(x) {matrix (rnorm(9), 3, 3)})
for (i in 1:length(B))
{
quant <- lapply (mylist, quantile, probs=B[i])
}
But quant
2010 Sep 22
3
extracting random effects from model formula
Hi R-users
I would like to extract the random effects ("1|SITE", "1+SPECIES|SITE"
and "BA|SITE") from this model formula:
Full_model <- formula (VAR ~ (1|SITE) + (1+SPECIES|SITE) + (BA|SITE) +
HEIGHT + COND + NN_DIST)
I tried:
terms(Full_model)
labels(terms(Full_model))
but I could not distinguish between random and fixed effects.
thanks
2010 Nov 03
2
memory allocation problem
Hi R users
I am trying to run a non linear parameter optimization using the
function optim() and I have problems regarding memory allocation.
My data are in a dataframe with 9 columns. There are 656100 rows.
>head(org_results)
comb.id p H1 H2 Range Rep no.steps dist aver.hab.amount
1 1 0.1 0 0 1 100 0
0.2528321
2011 Feb 02
2
automatic coercion to character
Hi R users
I am wondering how I can avoid automatic coercion of my numeric vector
elements to character
init <- c(age='N', R=as.numeric(0.5), S=as.numeric(0.8))
I have used as.numeric() but it does not seem to work
Thank you
Lorenzo
[[alternative HTML version deleted]]
2005 Jan 06
2
autoscaling plot font size in Sweave output possible?
Hi,
I was wondering if it's possible to have fonts in plots to be
autoscaled to the same font size used by LaTeX in a surrounding
Sweave document.
Here's a short example in which the fonts of the first plot are
barely readable:
--8<------------------------schnipp------------------------->8---
\documentclass{article}
\usepackage{graphicx}
\newcommand{\mytext}{Some normal sized
2005 Nov 30
1
\dQuote{} in \code{} not processed
Just wondering if this is the expected behaviour.
I was wanting to produce quoted text within \code{}, without manually
entering the '"'. \dQuote{} seems advisable after reading the Writing R
Extensions manual, so I tried \code{\dQuote{mytext}} expecting it to
produce "mytext" in monospace font (with ' ' round it in the R help
files) but it appears that
2018 Sep 28
4
Simple bash question
I am calling a bash script and passing in somestring that includes a "$"
myscript "$plusmore"
I want to assign in the myscript the $1 arg to something like
MYTEXT="$1"
when I do that I dont get what I'm expecting. if I do
MYTEXT='$1'
I still dont get what I'm expecting.
On the first assignment of MYTEXT I do not want the "$" to be
2019 Feb 13
3
Problem writing to ADS with cifs mounted windows share on Linux
Hi,
We are facing difficulties writing to Alternate Data Streams (ADS) on a
Windows CIFS mount on CentOS/RHEL Linux.
Steps followed on both machine:
--------------------------------------------
On RHEL(cifs.ko version: 1.68)
1. Created sample.txt file using vim with come content inside the
Windows CIFS share mounted on linux.
2. Then wrote some content with “vim
2012 Dec 12
2
long margin text below lattice plot - how to wrap lines?
Hello,
I've got a lattice plot and need to add text into the bottom margin of the plotting area (below the bottom legend).
This seems to work in principle using grid.arrange, yet the text to be added is rather long. As a consequence, it gets clipped:
require(lattice)
require(grid)
myplot <- xyplot(1~1)
mytext <- textGrob("This is such a very very long text that it goes on forever
2010 Oct 23
1
bind matrices by row
Hi R-users
I have a series of matrices and I would like to bind them together by
column using a loop (i.e. not writing cbind(matrix1,
matrix2,matrix3....)). The reason is because in my real data set I have
a very large number of matrices.
Example:
matrix1 <- matrix (1:12,4,3)
matrix2 <- matrix (13:24,4,3)
matrix3 <- matrix (25:36,4,3)
matrix4 <- matrix (37:48,4,3)
2017 Mar 14
2
[cfe-dev] proposal - pragma section directive in clang
Thanks Reid/Jonathon for your replies.
Reid,
An important case against module level flags is that it wont allow changing or resetting section names e.g.
int a;
#pragma clang section bss = "xyz"
int b;
In case above, users would like to see only 'b' placed in 'xyz' and not 'a' as well.
Link pointed to by Jonathon seems to require same behavior.