Thanks.
1. For consistency: I am using / everywhere else in my script.
2. For ease of use: I am passing the string to a client application (using
rcom) where it is easeir to handle / than \\.
See ?gsub
But why would you do that? Both / and \\ are valid in a p
Given:
> filename<-paste(tempdir(),"\\","myfile.txt",sep="");
> sub("","/",filename);
[1] "C:/DOCUME~1\\AJAYAS~1\\LOCALS~1\\Temp\\Rtmp2f270T\\myfile.txt"
Note: Only the first occurence of \\ is replaced. What is the syntax for
replacing every occurence?
Thanks.
[[alternative HTML
I've definitely encountered problems when running programs without
administrator righs. Perhaps that was down to virus/spyware protection software.
At this linkhttp://forums.techarena.in/windows-software/1258938.htm there is
the following suggestion
1.Click on Start
2.Type Run in Search and h
If I create a data.frame using session variables as follows:
classResults<-data.frame(subjEnglish,gradeEnglish,subjFrench,gradeFrench,row.names=studentName)
How can I remove the variables? I tried
> rm(names(classResults))
Error in rm(names(classResults)) :
... must contain names or characte
Given
studentNumbers<-10;
subjEnglish<-sample(-1:100,studentNumbers,replace=TRUE);
when subEnglish <=0, 'U'
<=39, 'F'
<=49 'D'
<=59, 'C'
<=69, 'B'
<=79,'A'
Thank you. Yes, I did look at the help but could not get my expressions to work.
You used a data.frame with thematrix values I gave. Your solution also works
when dealing with a matrix (this my be obvious to seasoned R users, but was no
to me).
> x<-matrix(c(57,91,31,61,16,84,3,99,85,47,21,6,57
be sorted by row in ascending/descending order?
Given this matrix:
57 91 31 61 16
84 3 99 85 47
21 6 57 91 31
61 16 84 3 99
I want to end with this:
21 6 57 91 31
57 91 31 61 16
61 16 84 3 99
84 3 99 85 47
The 'order' of the sort is: 3 1 4 2
Also, what R expression will give m
aren't row names in a data frame unique?
On 03/06/2012 06:42 PM, Ajay Askoolum wrote:
> I expected the row names to be unique but a data frame appears to be able to
> hold duplicate row names. This makes me thing that there must be
> circumstances when it is necessary. However, I c
I expected the row names to be unique but a data frame appears to be able to
hold duplicate row names. This makes me thing that there must be circumstances
when it is necessary. However, I cannot think of any. Please enlighten me.
[[alternative HTML version deleted]]
___
I know how to do this when creating the time series variable in one expression,
e.g.
valuesTS1<-ts(values,start=2000); # Frequency naturally defaults to 1
How can I specify the frequency of a time series?
> values=c(12,34,65,12);
> values<-ts(values);
> frequency(values);
[1] 1
> start(values)
One line of the RServe documentation (for Java, which I do not know) is:
Rconnection c = new Rconnection();
1. Is Rserve a COM or ActiveX object? If affirmative, what is the ProgId (or
clsid)?
2. If Rserve is not an ActiveX Object, does Java (like C#) require a reference
to the EXE or DLL that
savehistory() gives me the option of saving the executable lines only. I'd like
to save everything.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting
This is copy & paste from my session:
> xyz<-as.vector(c(ls(),as.matrix(lapply(ls(),class
> dim(xyz)<-c(length(xyz)/2,2)
>
> allobj<-function(){
+ xyz<-as.vector(c(ls(),as.matrix(lapply(ls(),class;
+ dim(xyz)<-c(length(xyz)/2,2);
+ return(xyz)
+ }
> xyz
[,1] [,2]
Hi Sarah,
Thanks you for the clarifications; I had worked round the problem
by switching to a data.frame.
However, I am still unclear about 'list': as it exists, it must
have a purpose. When is the use of the list data structure appropriate?
[[alternative HTML v
Thank you Jorge & Michael.
I was being stupid - its the only explanation!
The line I had been executing was
mtcars[rownames=="Valiant"] # missing rownames argument
but the line I quoted in my post was
mtcars[rownames(mtcars) != "Valiant",] # How could I write the correct line in
the mailin
Given
dayOfWeekName<-c("Mon","Tue","Wed","Thu","Fri","Sat","Sun");
dayOfWeekOrdinal<-c(1,2,3,4,5,6,0);
dayOfWeekWorkDay<-c(TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE);
weekProfile<-list(dow=dayOfWeekName,dowI=dayOfWeekOrdinal,dowW=dayOfWeekWorkDay)
1. How can I conditionally get dow, dowI, and dowW f
data(mtcars)
mtcars[rownames(mtcars)!="Valiant",] # fails
mtcars[list(rownames(mtcars))!="Valiant",] # runs but I am not getting the
expected result
With the latter statement, I expected all rows except the one where the name is
"Valiant".
I must have got something simple wrong; what is it?
When I plot, the plot's user interface offers me a choice:
File | Copy to the Clipboard | as a Bitmap.
What is the equivalent code for achieving this but without the plot interface
becoming visible?
Thanks.
[[alternative HTML version deleted]]
_
I can write a plot to a files of a given format using this:
x<-sample(c(1:100),10)
bmp("c:/mygraph.bmp")
plot(x)
dev.off()
and then show the image file in another application. This application can also
display the image from the stream of numbers that define the image.
How I can get the plot as
Thank you. I need some clarification.
dput(AirPassengers)
gives:
structure(c(112, 118, 132, 129, 121, 135, 148, 148, 136, 119,
104, 118, 115, 126, 141, 135, 125, 149, 170, 170, 158, 133, 114,
140, 145, 150, 178, 163, 172, 178, 199, 199, 184, 162, 146, 166,
171, 180, 193, 181, 183, 218, 230, 2
Given:
data(AirPassengers)
I get a ts data structure AirPassengers in the workspace.
How can I generate the code that can create that structure? That is, given an
example of a data structure, is there a way to generate the code that can
greate that structure?
Alternatively, is there a refere
savehistory writes all the executed lines from the session.
How can I write everything (executed lines and output) from the active session
to a file?
Using Edit | Select All then Edit Copy, I can copy everything to the clipboard
and write the whole thing to a file manually.
If I just used the
I know that [] is used for indexing.
I know that [[]] is used for reference to a property of a COM object.
I cannot find any explanation of what [[1]] does or, more pertinently, where it
should be used.
Thank you.
[[alternative HTML version deleted]]
___
Thanks you,
I can get the length of aa with length(unlist(aa)). If aa has 4 dimensions, I
imagine I'd need to do
max(sapply(aa,sapply,sapply,length)
How can I do this in a generic way? That is in a loop. I am clear about the
exit condition for the loop.
d<-1
start loop
if d = length(unl
Given a variable aa in the workspace, some of its attributes are:
> typeof(aa)
[1] "list"
> mode(aa)
[1] "list"
> length(aa)
[1] 2
How do I retrieve the maximum indices, in this case 2,3,4? The variable itself
is:
> aa
[[1]]
[[1]][[1]]
[[1]][[1]][[1]]
[1] 37531.52
[[1]][[1]][[2]]
[1] 62787.32
I haven't been able to find an example of using R with interactive = FALSE.
How do I start R such that
1. it loads a workspace
2. then starts execution with a function (in that workspace) that I choose
3. exits on completion
Thanks.
[[alternative HTML version deleted]]
___
ls() gives me the vector of objects in the workspace
class(objName) gives me the class of objName
class(ls()) just returns character as many times as there are objects.
How do I get a vector of all objects in the workspace?
[[alternative HTML version deleted]]
___
Thank you.
class(AirPassengers) is what I was looking for i.e. a generic way of
identification.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting gu
data(AirPassengers) brings AirPassengers into the workspace. How can I
idenfity what the structure of AirPassengers is? Is it a data.frame, a table
etc. etc.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://st
Thanks for clarifying.
Is my (new) understanding stated below correct?
- A closure is any function (user- or system- defined) where
is.primitive(functionName) is FALSE.
- is.primitive(functionName) is FALSE when functionName is a system-defined
function that is coded in R itself.
[[
Michael, thank you, especially for the link. I think I understand.
The vocabulary is so different! I know 'closure' as 'user-defined function'.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailm
The "R Language Definition" at
http://cran.r-project.org/doc/manuals/R-lang.html states in the following
section
4.3.2 Argument matching
This subsection applies to closures but not to primitive functions.
What are 'closures'?
[[alternative HTML version deleted]]
__
Thank you very much for this information.
From: R. Michael Weylandt
Cc: Richard M. Heiberger ; R General Forum
Sent: Thursday, 19 January 2012, 19:17
Subject: Re: [R] Executable Expressions II
Glad you got it worked out -- I don't know C# but if it's porta
I am not using RExcel at all.
I have now come up with a better solution that using eval. I can construct the
data structure (like c(1,2,3,4,5)) as an object in C# and pass it as the
argument to the method inside the web service that will call R. Works fine.
[[alternative HTML version del
Thank you Michael, Sarah and Robin for the answers to my original question.
Michael you asked:"But this is rarely a good ideaperhaps you could say a
little more
about your overall goal and we could direct you to a more "R"-ish solution? "
I realise eval (known as execute in one of my other
Given
a<-"c(1,2,3,4,5)"
How can I evaluate the variable a to return a (numeric) vector comprising of
1,2,3,4,5? Thanks.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PL
Thank you. I used capture.output(); this is fine.
From: R. Michael Weylandt
Cc: R General Forum
Sent: Wednesday, 18 January 2012, 19:44
Subject: Re: [R] R Table
Capture in what file format / device?
If you want a plain text log, sink() or capture.output()
Given a table with colnames and rownames, print(mytable) displays the table
nicely formatted.
How can I capture all of what is displayed as a character matrix?
Thanks.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
ht
As far as I can see, R's system, shell etc. functions either call/launch
functionality in the core operating system (COMMAND.COM) or free standing exes.
Win32 APIs are buried inside operating system synamic link libraries (DLLs) and
can be called by other languages. An example is:
Function Pat
I am looking for a means to call Win32 API calls from R for Windows. Is that
possible?
Thanks.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting gu
Given
Mylist <- list(FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE)
Try
which(as.logical(MyList))
to return the indices where Mylist is TRUE.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mai
Is there a way to tell whether an object name 1. is valid 2. is not going to
cause a collision with an existing object by the same name?
Thanks.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mai
try:
SELECT a.UNIQUE_ID,
a.diag01
from LoadPUS a
left join CVD_ICD10 b
on a.diag01 = b.[ICD-10 Codes]
or a.diag02 = b.[ICD-10 Codes]
or a.diag03 = b.[ICD-10 Codes]
I am not sure why your table name CVD_ICD10 has a suffix $.
From: Jeff Newmil
If you use Excel and are prepared to use the RCOM package, another option for
reading Excel workbooks becomes available:
ado<-comCreateObject("ADODB.RecordSet")
sql<-"SELECT * FROM [Sheet1$]"
con<-"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=XLSDataSource.xlsx;Extended
Properties='Excel 12.0 X
44 matches
Mail list logo