[R] Declare BASH Array Using R System Function
Dario Strbenac
dstr7320 at uni.sydney.edu.au
Tue Jul 30 03:00:14 CEST 2013
Thank you. This answers my question. I am using Linux, too.
________________________________________
From: arun [smartpink111 at yahoo.com]
Sent: Monday, 29 July 2013 11:11 PM
To: Dario Strbenac
Cc: R help
Subject: Re: [R] Declare BASH Array Using R System Function
Hi,
system("names=(X Y); echo ${names[0]}")
#sh: 1: Syntax error: "(" unexpected
#this worked for me:
system("bash -c 'names=(X Y); echo ${names[0]}'")
#X
A.K.
----- Original Message -----
From: Dario Strbenac <dstr7320 at uni.sydney.edu.au>
To: "r-help at r-project.org" <r-help at r-project.org>
Cc:
Sent: Sunday, July 28, 2013 10:00 PM
Subject: [R] Declare BASH Array Using R System Function
Hello,
It is difficult searching for previous posts about this since the keywords are short and ambiguous, so I hope this is not a duplicate question.
I can easily declare an array on the command line.
$ names=(X Y)
$ echo ${names[0]}
X
I am unable to do the same from within R.
> system("names=(X Y)")
sh: Syntax error: "(" unexpected
Reading the documentation for the system function, it appears to only be relevant for executing commands. What can I do instead to declare a BASH array ? Thanks.
--------------------------------------
Dario Strbenac
PhD Student
University of Sydney
Camperdown NSW 2050
Australia
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list