Displaying 20 results from an estimated 10000 matches similar to: "populating an array"
2010 May 04
4
timing a function
Hi,
I want to time how long a function takes to execute. Any clues on what to
search for to achieve this?
Thanks in advance.
--
View this message in context: http://r.789695.n4.nabble.com/timing-a-function-tp2126319p2126319.html
Sent from the R help mailing list archive at Nabble.com.
2010 Jul 29
2
how to 'stack' data frames?
I have 2 data frames (A & B) with some common column names.
A has 10 rows.
B has 20 rows.
How do I combine them so I end up with a data frame with 30 rows that only
contains the common columns.
I was trying 'merge' (Merge two data frames by common columns .....etc. )
but that is not giving me what I expect...
> a <- iris
> b <- iris
>
> c <-merge(a,b)
>
2010 Aug 01
3
finding max value in a row and reporting colum name
Hi,
Hopefully someone can point me in the right direction on how I would go
about solving the following.
I have some data and need to find the column name of the maximum value in
each row.
This could be the data...
> a <- data.frame(x = rnorm(4), y = rnorm(4), z = rnorm(4))
> a
x y z
1 1.6534561 0.11523404 0.2261730
2 -1.2274320 -0.24096054 1.5096028
2010 Jun 30
5
plot focus
I am doing calculations in a loop and then plotting the results by adding a
point to each of 2 charts at the end of the loop. Its very informative as
you can see the progression through time.
My problem is, if I have 2 plots, I don't know how to get the focus back to
the first plot.
layout(matrix(c(1,2)))
plot(iris[,1],col="red",) #plot1
plot(iris[,3],col="blue") #plot2
2010 Jul 10
4
eliminating constant variables
Hi all,
I have a large data set and want to immediately build a 'blind' model
without first examining the data. Now it appears in the data there are a lot
of fields that are constant or all missing values - which prevents the model
from being built.
Can someone point me the right direction as to how I can automatically purge
my data file of these useless fields.
Thanks in advance,
pdb
2009 Oct 12
1
field index given name.
Hi,
How do I access the index number of a field given I only know the field
name?
eg - I want to set the probability of the field 'species' higher than the
other fields to use in sampling.
> colprob <- array(dim=NCOL(iris))
> for(i in 1:NCOL(iris)){colprob[i]=0.5}
> colprob[iris$species] = 1 #this doesn't work
> colprob
[1] 0.5 0.5 0.5 0.5 0.5
--
View this
2009 Oct 10
1
field names as function parameters
Hi,
I am passing a data frame and field name to a function. I've figured out how
I can create the formula based on the passed in field name, but I'm
struggling to create a vector based in that field.
for example if I hard code with the actual field name
Y = df$Target, everything works fine.
but if I use the passed in parameter name, it doesn't give me what I want,
Y = df$mytarget
2013 Apr 02
2
Create a vector without using an external 'if statement'
Dear R-users,
suppose I have three dataframes like these
df1:
mydate min_temp
31032013 12
01042013 8
02042013 -999
df2:
mydate min_temp
31032013 10
01042013 11
02042013 14
df3:
mydate min_temp
31032013 4
01042013 3
02042013 5
where -999 means that the temperature data is not available (at the moment I cannot change it to NA because I am not the db administrator);
suppose also that oggi is
2009 Oct 31
2
Logistic and Linear Regression Libraries
Hi all,
I'm trying to discover the options available to me for logistic and linear
regression. I'm doing some tests on a dataset and want to see how different
flavours of the algorithms cope.
So far for logistic regression I've tried glm(MASS) and lrm (Design) and
found there is a big difference. Is there a list anywhere detailing the
options available which details the specific
2011 Jan 26
2
2 functions with same name - what to do to get the one I want
There seems to be 2 functions call ecdf...
http://lib.stat.cmu.edu/S/Harrell/help/Hmisc/html/ecdf.html
http://127.0.0.1:11885/library/stats/html/ecdf.html
How do I get the one ecdf {Hmisc} to run instead of the ecdf {stats}
A pointer in the right direction would be greatly appreciated.
Tried to instal Hmisc but got this message, so I assume I have it
> utils:::menuInstallPkgs()
Warning:
2011 May 01
1
caret - prevent resampling when no parameters to find
I want to use caret to build a model with an algorithm that actually has no
parameters to find.
How do I stop it from repeatedly building the same model 25 times?
library(caret)
data(mdrr)
LOGISTIC_model <- train(mdrrDescr,mdrrClass
,method='glm'
,family=binomial(link="logit")
)
LOGISTIC_model
528
2010 Jul 05
2
r code exchange site?
Does there exist a site where snippets of r code examples can be deposited,
such as the one that exists for matlab?
http://www.mathworks.com/matlabcentral/fileexchange/
ps
I also noted from the main r site
http://www.r-project.org/
when you click on the nabble link under the search link, I end up here
http://e-nvf.vvvay.net/-td13672.html#a13819
which I don't think is anything to do with
2012 Feb 24
4
Table into a list
Hello,
I am looking for a way to transform an array into a list (or a string).
My array has two columns 1 and 2, and I would like to create a list of the
values.
Let's say I have :
x1 x2
1 a b
2 c d
3 e f
4 g h
What I would like to obtain is a,b,c,d,e,f,g,h.
I tried without success melt and reshape ( reshape(my_array,
2010 Sep 01
1
transaction object - how to coerce this data
Hi,
I am wanting to look at frequent item sets using the arules package. I need
to transform my data into a "transactions" object. The data I read in from a
file has 2 columns, an ID and an item. How do I convert data like this into
a transactions object?
I've tried
class? transactions
but it only confuses me.
My data is like this....
basketID item
1 bread
1 cheese
1 milk
2
2010 Jul 31
1
Lags and Differences of zoo Objects
Hi,
I'm struggling to understand the documentation.
?lag.zoo
x - a "zoo" object.
k, lag - the number of lags (in units of observations). Note the sign of k
behaves as in lag.
differences - an integer indicating the order of the difference.
What does the above line actually mean? I've tried a few settings on sample
data but can't figure out what it is doing.
x <-
2012 Apr 12
3
directory of current script
I am running a series of scripts sequentially and they all need some global
parameters. These will be included in a file in a known sub directory as the
scripts themselves.
The scripts need to be run by anyone without ANY editing.
Question is:
Is there a command to return the directory of the current script, so it then
knows where to find the global parameter file?
Or is there a simpler way?
2009 Oct 11
3
passing field name parameter to function
Hi,
I am passing a data frame and field name to a function. I've figured out how
I can create the formula based on the passed in field name, but I'm
struggling to create a vector based in that field.
for example if I hard code with the actual field name
Y = df$Target, everything works fine.
but if I use the passed in parameter name, it doesn't give me what I want,
Y =
2011 Jun 18
1
can this sequence be generated easier?
I have 'x' variables that I need to find the optimum combination of, with the
constraint that the sum of all x variables needs to be exactly 100. I need
to test all combinations to get the optimal mix.
This is easy if I know how many variables I have - I can hard code as below.
But what if I don't know the number of variables and want this to be a
flexible parameter. Is there a sexy
2010 May 04
1
randomforests - how to classify
Hi,
I'm experimenting with random forests and want to perform a binary
classification task.
I've tried some of the sample codes in the help files and things run, but I
get a message to the effect 'you don't have very many unique values in the
target - are you sure you want to do regression?' (sorry, don't know exact
message but r is busy now so can't check).
In
2012 Sep 05
2
POSIXlt and daylight savings time
I have a data frame that contains dates, but when I use as.POSIXlt() I lose
the hours on all records. I traced this down to a particuar hour which
causes the issue...
> as.POSIXlt('2004-10-31 02:00:00')
[1] "2004-10-31"
> as.POSIXlt('2004-10-31 03:00:00')
[1] "2004-10-31 03:00:00"
How do I tell as.POSIXlt() to ignore daylight savings and just convert to