Você pode escrever código em linguagens diferentes do R com R Markdown, por exemplo
valid=true
count=1
while [ $valid ]
do
echo $count
if [ $count -eq 5 ];
then
break
fi
((count++))
done
## 1
## 2
## 3
## 4
## 5
É preciso instalar previamente o pacote reticulate no R
library(reticulate)
use_python("/usr/bin/python")
knitr::knit_engines$set(python = reticulate::eng_python)
import numpy as np
my_python_array = np.array([2,4,6,8])
for item in my_python_array:
print(item)
## 2
## 4
## 6
## 8
my_r_array <- py$my_python_array
class(my_r_array)
## [1] "array"
my_r_vector <- as.vector(py$my_python_array)
class((my_r_vector))
## [1] "numeric"
my_r_vector <- my_r_vector*2
my_python_array2 = r.my_r_vector
print(my_python_array2)
## [4.0, 8.0, 12.0, 16.0]
0 script abaixo foi criado por Anderson Ferreira (andersonferreira631@yahoo.com.br)
Trata-se de um Conversor de Dólar para real, bastante simples. Obs: A letra “d” indica o valor do dólar.
O número “10” indica o valor (de 0 a 10) que será convertido de Dólar para Reais.
## US$ 0.00 = R$ 0.00
## US$ 1.00 = R$ 4.29
## US$ 2.00 = R$ 8.59
## US$ 3.00 = R$ 12.88
## US$ 4.00 = R$ 17.18
## US$ 5.00 = R$ 21.47
## US$ 6.00 = R$ 25.76
## US$ 7.00 = R$ 30.06
## US$ 8.00 = R$ 34.35
## US$ 9.00 = R$ 38.65
## --------------------