similar to: Relative frequency on a character vector

Displaying 20 results from an estimated 10000 matches similar to: "Relative frequency on a character vector"

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 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 Feb 01
3
sum the values in a vector as a complete number
Hi I am trying to create a function that is able to calculate this sum: a<-c(2,3,5) b<-(8,7) with "a" meaning 235 and "b" 87. So the result of this sum would be 235 + 87 = 322. I've searched a function like strsplit but that worked for integers and in reverse - not spliting but combining. Can you give me a hand on this please? thanks AD -- View this message in
2010 Dec 30
2
Analysing Character Strings for subsequent frequency analysis
Hi I'm trying to get to grips with R and establish R as a teaching medium in my secondary school. I would like to use R to analyse text so I can produce frequency analysis of the text for subsequent examination of ciphers. I can produce code in VBA but I am struggling when writing in R to examine each character. There must be a clear method using the vectorised format of R. Furthermore,
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
2008 Dec 12
7
character count
Dear list, I have a variable that consists of typed responses. I wish to compute a variable equal to the number of characters in the original variable. For example: > x <- c("convert this to 32 because it has 32 characters", "this one has 22 characters", "12 characters") [Some magic function here] > x [1] 32 22 12 Any ideas?
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
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
2012 Aug 27
4
?nchar ?strsplit
Hi, my data frame is x<-data.frame(ID=c("abc/def","abc/def/ghi","abc","mno/pqr/st/ab")) I want to split my column ID using "/" as the place to split. How can I do that without telling the code how many sub-columns. I could use nchar(gsub("[^/]","",x$ID)) to get how many "/" are in each row of the column, but could
2005 Jun 22
10
How to read an excel data into R?
Hi all, Does anybody know the easiest way to import excel data into R? I copied and pasted the excel data into a txt file, and tried read.table, but R reported that Error in read.table("data_support.txt", sep = " ", header = T) : more columns than column names Thanks! Ling
2011 Jun 10
2
Counting the Number of Letters in a row
I'm trying to find the total number of letters in a row of a data frame. Let's say I have the following data frame. f1 <- data.frame(keyword=c("I live in Denver", I live in Kansas City, MO", "Pizza is good")) The following function gives me the number of characters in each string. So for "I live in Denver", I get 1, 4, 2, and 6. However, I want to
2013 Apr 18
5
Subsetting a large number into smaller numbers and find the largest product
Hello, I have a big number lets say of around hundred digits. I want to subset that big number into consecutive number of 5 digits and find the product of those 5 digits. For example my first 5 digit number would be 73167. I need to check the product of the individual numbers in 73167 and so on. The sample number is as follows:
2012 Nov 16
1
Split data frame and create a new column
I need to split a data frame into 3 columns. The column I want to split contains indices of lag (prefix L1 or L2 and suffix 01, 03, 04), station name (shown in the sample data as capitalized G, P and S) and pollutant name. Names with no ?L? prefix or 01/04 suffix are lag 0. Lag 01 is average of lag 0 and 1, and 04 is average of 0 to 4 days. How can one do that in R? I will ignore the other
2007 Aug 07
2
Embedded nuls in strings
Hi, ?rawToChar 'rawToChar' converts raw bytes either to a single character string or a character vector of single bytes. (Note that a single character string could contain embedded nuls.) Allowing embedded nuls in a string might be an interesting experiment but it seems to cause some troubles to most of the string manipulation functions. A string with an embedded 0:
2006 Aug 29
3
Substring and strsplit
Dear R People: I am trying to split a character vector into a set of individual letters: Ideal: x3 <- c("dog") "d" "o" "g" I tried the following: > strsplit(x3) Error in strsplit(x3) : argument "split" is missing, with no default > strsplit(x3,1) [[1]] [1] "dog" I know that this is incredibly simple, but what am I doing
2004 Jun 01
1
converting text coordinates to decimal degrees
I receive GPS readings in a text string such as "0121.6723S 03643.6893E" and need the coordinates as decimal degrees in two separate variables: "-1.361205" and "36.728155". How do I do this in R? mikkel
2008 Dec 09
4
extract the digits of a number
Hello, Anyone knows how can I do this in a cleaner way? mynumber = 1001 as.numeric(unlist(strsplit(as.character(mynumber),""))) [1] 1 0 0 1 Thanks in advance, Gustavo
2003 Jul 21
1
Inconsistent handling of character NA?
[R 1.7.1 on Windows XP Pro] Since R allows missing values for character variables, why are NA's not propagated by character manipulation functions? For example: > temp <- c("a", NA) > temp [1] "a" NA > is.na(temp) [1] FALSE TRUE > paste(temp[1], temp[2]) [1] "a NA" > substr(temp, 1, 1) [1] "a" "N" >
2004 Oct 20
7
Q about strsplit and regexp
Dear R-help, This one is probably a piece of cake for regexp masters. I'd like to split a character vector (for simplicity, say of length one for now) that contains fields that are delimited by arbitrary number of white spaces (e.g., " a b c "). How do I get the character vector that contain the fields? In the example I gave, I've tried: > strsplit(" a b c
2013 Jun 07
1
cannot load pbdMPI package after compilation
Hello, I try to install pbdMPI. Compilation successful, but load fails with segfault. Is anyone can help me? R version 3.0.0 pbdMPI version 0.1-6 Intel compiler version 13.1.1 OpenMPI version 1.6.4-1 CPU Intel x86_64 # R CMD INSTALL pbdMPI_0.1-6.tar.gz .. .... checking for gcc... icc -std=gnu99 checking whether the C compiler works... yes checking for C compiler default output file name...