Displaying 20 results from an estimated 10000 matches similar to: "From strings to numbers"
2008 May 19
3
Rank Values in a Matrix
Dear All,
a short and maybe simple question:
I have to rank all values in a matrix from 0 to X,
[1] [2] [3] [4]
[1] 0.1 2 0 3
[2] 50 3 3 1
[3] 100 1 1 0
[4] 100 2 2 0
0->0
0.1->1
2->2
3->3
50->4
100->5 (X=5)
is there any function for this? i have looked in several packages
(vegan, labdsv etc.) because I am working with species by site tables,
2008 Nov 06
3
unlist & dataframes
Dear all,
I would like to know whether it is possible to unlist elements and keep the
original format of the data.
To make it more clear, let me give an exemple:
I have a list l of dataframes that I created with apply but which looks like
this:
x1=data.frame(Name=LETTERS[1:2],Age=1:2)
x2=data.frame(Name=LETTERS[3:4],Age=3:4)
l=list(x1,x2)
l
[[1]]
Name Age
1 A 1
2 B 2
[[2]]
Name
2011 May 19
1
Creating a "shifted" month (one that starts not on the first of each month but on another date)
Hello!
I have a data frame with dates. I need to create a new "month" that
starts on the 20th of each month - because I'll need to aggregate my
data later by that "shifted" month.
I wrote the code below and it works. However, I was wondering if there
is some ready-made function in some package - that makes it
easier/more elegant?
Thanks a lot!
# Example data:
2008 Apr 23
3
select rows from data based on a vector of char strings
Hi,
I have loaded a dataset in R :
data =
label freq1 freq2
news 54 35
fun 37 21
milk 19 7
food 3 3
.... etc
And I have a vector
flist<-c("fun","food")
Now I want to use the vector 'flist' for selecting these values from 'data'
so that I get the following dataset :
label freq1 freq2
fun 37 21
food
2010 May 13
3
How ls() only functions or anything else but functions?
Hello,
How ls() only functions or only data objects (basically anything other than
functions) such as data.frame, numeric ...?
John
[[alternative HTML version deleted]]
2008 Apr 14
3
Power curves
Hi,
I am trying to create a power curve to show how the power of a t-test varies depending on the mean. Any ideas how I should go about this?
Louisa
_________________________________________________________________
[[alternative HTML version deleted]]
2008 Mar 31
2
convert delimited string to vector
Hi R Users,
Simple question: How might I convert the text "a, b, c" (or for that matter "a
b c" with any delimiter - space, comma, etc.) into a 3-element character
vector?
[1] a b c
Thanks,
Brad
2007 Jan 27
3
how to handle a longitudinal data
i have a data set with repeated measures on same people, structure like
below:
id x1 x2 ...
001 10 20 ...
001 8 45 ...
001 4 2 ...
002 ....
002 ...
002 ....
002 ....
003 ....
.......
what is the easist way to show how many observations for each subject id?
[[alternative HTML version deleted]]
2009 Jun 12
3
Replacing 0s with NA
Hello
I have a dataset in which I would like to replace 0s with NAs. There is a
lot of information on how to replace NAs with 0, but I have struggled to
find anything with regards to doing the reverse. Any recommendations would
be great.
Cheers
Christine
2006 Oct 22
1
how to convert multiple dummy variables to 1 factor variable?
Dear Listers,
I am wondering how to convert multiple dummy variables to 1 factor variable.
Thanks.
wensui
2008 Aug 07
6
multiple tapply
Hi folk,
I tried this and it works just perfectly
tapply(iris[,1],iris[5],mean)
but, how to obtain a single table from multiple variables?
In tapply x is an atomic object so this code doesn't work
tapply(iris[,1:4],iris[5],mean)
Thanx and great summer holidays
Gianandrea
--
View this message in context: http://www.nabble.com/multiple-tapply-tp18868063p18868063.html
Sent from the R help
2010 Mar 01
3
setting the steps for x axis labels on plot
Hello, I'm new to R, I've been working with it for the last 2 weeks. I
am plotting some data and not getting the labels on the x axis I am
expecting on my plot.
my code reads
#hours in the day
h <- c(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23)
#hp is a data frame with a pivot table of 25 columns (label and data
for 24 hours)
plot(h, as.matrix(hp[1,2:25]),
2008 Jun 06
5
request: a class having max frequency
Dear R users
I have a very basic question. I tried but could not find the required result. using
dat <- pima
f <- table(dat[,9])
> f
0 1
500 268
i want to find that class say "0" having maximum frequency i.e 500. I used
>which.max(f)
which provide
0
1
How can i get only the "0". Thanks and
best regards
Muhammad Azam
Ph.D. Student
Department of
2009 Dec 02
4
Finding cases in one subset that are closet to another subset
Good afternoon
Running R2.10.0 on Windows
I have a data frame that includes (among much else) a factor (In_2006) and a continuous variable (math_3_4). I would like to find the 2 cases for In_2006 = 0 that are closest to each case where In_2006 = 1.
My data looks like
In_2006 math_3_4
0 55.1
1 51.6
1 18.1
1 26.6
1 14.1
2009 Dec 31
1
xyplot - help with multiple Y's vs. X of a member data in multiple panels
Dear R experts,
Wish you all a HAPPY NEW YEAR!
How do I go about plotting (using lattice) overlays of an ID (group=ID)
observed, fitted data in each panel of a multiple panel plot (each panel
identified by DS1 + DS2 + DS3)? "x" variable is X1 in the accompanying
section of a dataset. each individual is identified by color and Y's are
identified by "pch" or "lty".
2007 Dec 19
3
median of binned values
Dear list,
I have a vector (array, table row, whatever is best) of frequency values
for categories (or bins), and I need to find the median category.
Trivial to do by hand, but I was wondering if there is a means to do it
in R in an elegant way.
The obvious medioan(vector) returns the median frequency for the binns,
and that is not what I want. i.e,:
freq
cat1 1
cat2 10
2008 Jul 29
1
Problem reading a particular file with read.spss()
Hi All:
I have a seemingly typical SPSS data file with 219 rows and 486
variables. When I attempt to read this file into R with read.spss() in
the foreign package, I consistently get a "crash". This is the sequence
of events:
> library(foreign)
> sessionInfo()
R version 2.7.1 Patched (2008-07-24 r46120)
i386-pc-mingw32
locale:
LC_COLLATE=English_United
2008 Feb 24
3
Newbie: Where is lmFit function?
Hi Everyone,
I am trying to use lmFit function; however, i cannot find it function
anywhere.
I have been trying to find the function in Bioconductor and elsewhere. I
re-install bioconductor source, update package and update R as well. no luck
Is there a command in R where i can just type, and it will download it for
me?
--
View this message in context:
2007 Sep 19
2
By() with method = spearman
I have a data set where I want the correlations between 2 variables
conditional on a students grade level.
This code works just fine.
by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor,
use='complete', method='pearson')
However, this generates an error
by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor,
use='complete',
2010 Jan 20
5
standardizing one variable by dividing each value by the mean - but within levels of a factor
Hello!
I have a data frame with a factor and a numeric variable:
x<-data.frame(factor=c("b","b","d","d","e","e"),values=c(1,2,10,20,100,200))
For each level of "factor" - I would like to divide each value of
"values" by the mean of "values" that corresponds to the level of
"factor"
In other