Displaying 20 results from an estimated 3000 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
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
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
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,]
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
>
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
2009 Sep 07
2
syslinux config file size
Hello All,
Sorry if this has be discussed already, I have a syslinux config which
is rather big [7000+ char] and I see that the menu system "menu.c32"
shows only part of the menu configured.
Also the last entry in the menu contains only half of the
configuration. Is there a limit to the size of config file for the
menu ?
I tried to work around the problem by spliting the config file
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]]
2010 Nov 02
1
splitting First 10 words in a string
Hi Steven,
Thank you for the help. I get an error though when i do this :
>lit<-read.csv("litologija.csv", sep=";", dec=".")
>sent <-data.frame(sentence=lit$Opis,stringsAsFactors=FALSE)
>str(sent)
>sentV<-rep(sent,10)
>str(sentV)
>first=second=third=fourth=fifth=sixth=seventh=eighth=ninth=tenth<-vector(length=10)
>DF
2009 Sep 08
1
Character manipulation using "strsplit" & vectorization
Dear R users,
Suppose I have a data set with inconsistent names for a field.
I desire to make these to consistent names.
i.e
"University of New Jersey", "New Jersey Uni", "New Jersey University" (3
different inconsistent names) to "The University of New Jersey" (consistent
name)
Below are arbitrary data set produced from "state.name" (built
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
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 Jul 14
5
Splitting one column value into multiple rows
Hi i have the data in the following format:
rent,100,1,common,674
pipe,200,0,usual,864
car,300,1,uncommon,392:jump,700,0,common,664
car,200,1,uncommon,864:snap,900,1,usual,746
stint,600,1,uncommon,257
pull,800,0,usual,594
where as i want the above 6 lines data into 8 lines as below (Spliting row 3
& 4 at : and sending to a new row):
rent,100,1,common,674
pipe,200,0,usual,864