Displaying 20 results from an estimated 4000 matches similar to: "sum the values in a vector as a complete number"
2011 Jan 06
4
Creating a Matrix from a vector with some conditions
Hi
Suppose we have an object with strings:
A<-c("a","b","c","d")
Now I do:
B<-matrix(A,4,4, byrow=F)
and I get
a a a a
b b b b
c c c c
d d d d
But what I really want is:
a b c d
b c d a
c d a b
d a b c
How can I do this?
thank you
A. Dias
--
View this message in context:
2011 Jan 01
3
How to make this script ask again
Hi,
as an example I have made this script to give the user the answer if a
number is odd or even:
{
cat("Please, enter a number (Zero ends)")
n<-scan(n=1)
if(n==0)break
i<-("The number is odd")
p<-("The number is even")
if (n%%2==0)
p else i
}
If you run this script it will only work once, I mean, after it gives you
the answer is won't ask for
2011 Jan 04
5
Help with "For" instruction
Hi,
I am having a problem in doing something similar to this example:
Suppose I have this vector a, and from it I wish to create 5 other vector
each one with less one value than what object a has
So I have "a"
a<-c(1,2,3,4,5)
and I want
a1 that shoud have (2,3,4,5)
a2 that should have (1,3,4,5)
a3 that should have (1,2,4,5)
a4 that should have (1,2,3,5)
a5 that should have
2011 Jan 18
4
Relative frequency on a character vector
Hi,
I have this character vector:
A<-c("Tell me how many different letter this vector has?")
Is there a way with R that it can let me know how many different letters I
have on this vector?
If I use nchar(A) que gives me the number 50. With this function he is
counting all the letters present and also spaces between the words. Can we
also not count the spaces between words?
Then
2011 Jan 06
2
Help with IF operator
Hi,
I am with a problem on how to do a comparison of values. My script is as
follows:
repeat{
cat("How many teams to use? (to end write 0) ")
nro<-scan(n=1)
if(nro==0)break
cat("write the", nro, "teams names \n")
teams<-readLines(n=nro)
if (teams[1]==teams[2)next
else print(teams)
}
On this example I only compare teams 1 name with teams 2 name, and if they
2011 Feb 02
2
matrix and a function - apply function
Hi
I have this function and this matrix:
function(x,y) x+y/x
m<-matrix(c(1,2,4,2,10,8),3,2)
> m
[,1] [,2]
[1,] 1 2
[2,] 2 10
[3,] 4 8
each row represent a point (x,y) in a chart and I want via my fucntion to
calculate the image in order to get this results:
for point (1,2) I would get 1+2/1 = 3
for point (2,10) I would get 2+10/2 = 7
for point (4,8) I would get
2012 Aug 27
3
String Handling() for Split a word by a letter
Hi,
here im unable to run a string handle function called unpaste().
for eg:- a<- "12345_mydata"
Actually my requirement what is i need to get , only 12345. Means that , i
need the all letter as a word which is before of first " _ " - symbol of
"a". i tried to do with unpaste, it says function not found. After that i
tried with "strsplit() ". it
2005 Oct 28
3
splitting a character field in R
Dear R users,
I have a dataframe with one character field, and I would like to create two
new fields (columns) in my dataset, by spliting the existing character
field into two using an existing substring.
... something that in SAS I could solve e.g. combining substr(which I am
aware exist in R) and "index" for determining the position of the pattern
within the string.
e.g. if my
2005 Oct 20
5
spliting an integer
Hi there,
From the vector X of integers,
X = c(11999, 122000, 81997)
I would like to make these two vectors:
Z= c(1999, 2000, 1997)
Y =c(1 , 12 , 8)
That is, each entry of vector Z receives the four last digits of each entry of X, and Y receives "the rest".
Any suggestions?
Thanks in advance,
Dimitri
[[alternative HTML version deleted]]
2008 Jan 26
1
Loosing IAX/SIP user's registration with asterisk as no-root
Hello list, hope some one could help me find the answer.
Asterisk 1.4.16.2 installd as no-root user
The main issue is that every now and then, cd * box seems to loose the
user's registrations, there is nothing in the console, absolutely no
messages, only when another friend trys to dial an extension I can see this
on messages logs
[Jan 26 10:35:46] WARNING[23015] app_dial.c: Unable to
2009 Apr 10
4
split a character variable into several character variable by a character
Dear Mao Jianfeng,
"r-help-owner" is not the place for help, but:
r-help at r-project.org
(CC-ed here)
In any case, strsplit() does the job, i.e.:
> unlist(strsplit("BCPy01-01", "-"))
[1] "BCPy01" "01"
You can work with the whole variable, like:
splitpop <- strsplit(df1$popcode, "-")
then access the first part with
>
2001 Oct 11
2
Can we encrypt copied files on target machine?
The problem
-----------
I want to copy a file from machine A (master) to machine B (backup) but I would
like to stop root user on machine B to easily look at the file contents. So I
encrypt the file to send at machine A and send just the encrypted version to
machine B (which has no means to decrypt the file).
Then I make a small change in the file in the machine A and want to send the
new
2010 Mar 30
2
Need help to split a given matrix is a "sequential" way
I need to split a given matrix in a sequential order. Let my matrix is :
> dat <- cbind(sample(c(100,200), 10, T), sample(c(50,100, 150, 180), 10,
> T), sample(seq(20, 200, by=20), 10, T)); dat
[,1] [,2] [,3]
[1,] 200 100 80
[2,] 100 180 80
[3,] 200 150 180
[4,] 200 50 140
[5,] 100 150 60
[6,] 100 50 60
[7,] 100 100 100
[8,] 200 150 100
[9,]
2007 Dec 13
6
spliting strings ...
Hi everyone,
I have a vector of strings, each string made up by different number of words. I want to get a new vector which has only the first word of each string in the first vector. I came up with this:
str <- c('aaa bbb', 'cc', 'd eee aa', 'mmm o n')
str1 <- rep(1, length(str))
for (i in 1:length(str)) {
str1[i] <- strsplit(str, "
2009 Oct 27
3
Optional filter files
Is it possible to call rsync and tell it to use a filter file if it
exists, but otherwise continue without errors?
If I pass "--filter=. .rsync-filter", it will fail if .rsync-filter
doesn't exist.
I know you can pass "--filter=: /.rsync-filter" to search for filter
files in each directory. That won't fail if there aren't any such
files. But I'm only
2011 Oct 18
2
About an integral univariate problem
Hello all R users
I want to calculate this univariate integral:
exp(-x)*sum(y^x) respect to x from 0 to 3 where y is a vector y=(2,3,5).
In fact, the original y vector has a large number of elements but I propose
with 3 elements.
I know that I can resolve this problem doing
fun <- function(x) exp(-x)*(2^x+3^x+5^x)
integrate(fun,0,3)
When the y vector has a large number of elements the
2006 Sep 20
3
Spliting a huge vector
Dear R users,
I have a huge vector that I would like to split into
unequal slices. However, the only way I can do this is
to create another huge vector to define the groups
that are used to split the original vector, e.g.
# my vector is this
a.vector <- seq(2, by=5, length=100)
# indices where I would like to slice my vector
cut.values <- c(30, 50, 100, 109, 300, 601, 803)
# so I have to
2010 Dec 31
1
Silhouette function problem
Hi,
I am using code below to get a plot that will show me on the X axis the
number of clusters and on the Y axis the cluster average widths. However I
am getting this error:
Error in summary(silhouette(cutree(d, x), dist(iris[, -5])))$si.summary :
$ operator is invalid for atomic vectors
the code I am using is:
avgs<-sapply(1:20,function(x)
summary(silhouette(cutree(d,x),
2006 Sep 08
2
subsetting a data set
I have a data set called GQ1, which has 20 variables one of which is a
factor called Status at thre levels "Expert", "Ecol" and "Stake"
I have managed to evaluate some of the data split by status using commands
like:
summary (Max[Status=="Ecol"])
BUT how do I produce asummary for Ecol and Expert combined, the only
example I can find suggsts I could use
2005 Apr 13
3
PXElinux and configs
I'm just wondering if there is an easy way to do this...
My pxelinux.cfg/default is getting very long... and I'd like to make it
shorter by spliting it up into sections which would load other config
files.
So basically I want to do something like the grub:
"configfile (nd)/other.lst"
Is there an easy way?
--
Cheers
Paul