i write this code in R
paste("a","b","c")
which returns the value "abc"
Variable abc
has a value of 5(say) how do i get "abc"
to give me the value 5 is there any function like as.value(paste("a","b","c"))
which will give me the answer 5? I am making my doubt sound simple and this is exactly what i want. So please help me. Thanks in advance
Int value of a string can be obtained by using inbuilt function in python called as int() . Here we can pass string as argument to this function which returns int value of a string.
Method 2: Using $$ Operator: The $$var_name is known as reference variable where $var_name is a normal variable. The $$var_name used to refer to the variable with the name as value of the variable $var_name. Example: This example uses $$ operator to get the variable name as a string. print ( $name );
We can convert numbers to strings through using the str() method. We'll pass either a number or a variable into the parentheses of the method and then that numeric value will be converted into a string value. The quotes around the number 12 signify that the number is no longer an integer but is now a string value.
To check if a variable contains a value that is a string, use the isinstance built-in function. The isinstance function takes two arguments. The first is your variable. The second is the type you want to check for.
paste("a","b","c")
gives "a b c"
not "abc"
Anyway, I think you are looking for get()
:
> abc <- 5 > get("abc") [1] 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With